/**
 * initSDK — SDK runtime initialization at agent boot.
 *
 * Promoted from forge/src/agents/shared/startup.ts (Vague 1.B.2).
 * Forge-specific coupling neutralized:
 * - CC_REGISTRY_URL hardcoded → parameterizable via `registryUrl` option
 * - CC_SERVICE_TOKEN env var → kept as env var (secret, cannot be in code)
 * - OTel collector URL → parameterizable
 *
 * @public @since 0.17.0
 */
import { initVaubanSDK } from "../otel/ingest.js";
// ─── initSDK ─────────────────────────────────────────────────────────────────
/**
 * Initialize OTel SDK + ports + agent registry at boot.
 *
 * Steps:
 * 1. Calls `initVaubanSDK` to set up OTel OTLP exporter + W3C propagator.
 * 2. Registers the agent in the CC registry (fire-and-forget, non-fatal).
 *
 * Returns the OTel BasicTracerProvider for introspection.
 * Registration errors are logged as warnings and never throw.
 *
 * @example
 * ```ts
 * initSDK({
 *   agentId: "forge-revenue",
 *   agentVersion: "1.0.0",
 *   orgId: "forge",
 *   capabilities: ["revenue-tracking", "gtm"],
 *   repoUrl: "https://github.com/vauban/forge",
 * });
 * ```
 *
 * @public
 */
export function initSDK(opts) {
    const registryUrl = opts.registryUrl ?? process.env["CC_REGISTRY_URL"];
    const apiKey = process.env["VAUBAN_API_KEY"] ?? "";
    const provider = initVaubanSDK({
        apiKey,
        agentId: opts.agentId,
        agentVersion: opts.agentVersion,
        orgId: opts.orgId,
        agentName: opts.agentName ?? opts.agentId,
        capabilities: opts.capabilities ?? [],
        repoUrl: opts.repoUrl,
        collectorUrl: opts.collectorUrl,
        registryUrl,
        debug: opts.debug,
    });
    // Self-registration via AgentRegistryPort (fire-and-forget, non-fatal).
    if (opts.registryOpts !== undefined) {
        const { registry, descriptor } = opts.registryOpts;
        registry.register(descriptor).catch((err) => {
            // Non-fatal — agent still boots if registry is unavailable.
            console.warn("[initSDK] registry.register failed (non-fatal):", err);
        });
    }
    return provider;
}
//# sourceMappingURL=init-sdk.js.map