@skaile/workspaces 3.23.0 → 3.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +78 -0
- package/dist/app-sdk/index.js +1 -1
- package/dist/{asset-feeds-7XNPNIHN.js → asset-feeds-6RKRMM6C.js} +4 -4
- package/dist/{asset-feeds-7XNPNIHN.js.map → asset-feeds-6RKRMM6C.js.map} +1 -1
- package/dist/asset-manager/index.js +1 -1
- package/dist/bridge/drivers/claude-sdk.js +20 -11
- package/dist/bridge/drivers/claude-sdk.js.map +1 -1
- package/dist/bridge/drivers/codex.js +1 -1
- package/dist/bridge/drivers/continue.js +2 -2
- package/dist/bridge/drivers/echo.js +3 -2
- package/dist/bridge/drivers/echo.js.map +1 -1
- package/dist/bridge/drivers/gemini.js +3 -3
- package/dist/bridge/drivers/goose.js +2 -2
- package/dist/bridge/drivers/omp.js +1 -1
- package/dist/bridge/drivers/opencode.js +2 -2
- package/dist/bridge/drivers/qwen.js +3 -3
- package/dist/bridge/index.js +4 -3
- package/dist/bridge/src/capability-dispatch.d.ts +1 -1
- package/dist/bridge/src/capability-dispatch.d.ts.map +1 -1
- package/dist/bridge/src/drivers/claude-sdk.d.ts +3 -2
- package/dist/bridge/src/drivers/claude-sdk.d.ts.map +1 -1
- package/dist/bridge/src/normalizer.d.ts +19 -1
- package/dist/bridge/src/normalizer.d.ts.map +1 -1
- package/dist/{chunk-GA2TTHBP.js → chunk-3CF5HJ6V.js} +6 -6
- package/dist/{chunk-GA2TTHBP.js.map → chunk-3CF5HJ6V.js.map} +1 -1
- package/dist/{chunk-F4ORFHB5.js → chunk-3D3BKCVQ.js} +4 -4
- package/dist/{chunk-F4ORFHB5.js.map → chunk-3D3BKCVQ.js.map} +1 -1
- package/dist/{chunk-NBXH6RTU.js → chunk-4YRRPWHY.js} +146 -45
- package/dist/chunk-4YRRPWHY.js.map +1 -0
- package/dist/{chunk-74PLEDRD.js → chunk-5PFJVZ7F.js} +2 -2
- package/dist/{chunk-74PLEDRD.js.map → chunk-5PFJVZ7F.js.map} +1 -1
- package/dist/{chunk-M2AG3GLB.js → chunk-6NTKN6QC.js} +3 -3
- package/dist/{chunk-M2AG3GLB.js.map → chunk-6NTKN6QC.js.map} +1 -1
- package/dist/{chunk-WQ7DE5UC.js → chunk-73ZXUUL6.js} +25 -8
- package/dist/chunk-73ZXUUL6.js.map +1 -0
- package/dist/{chunk-XHVAGSSY.js → chunk-BIPMCNAK.js} +3 -3
- package/dist/{chunk-XHVAGSSY.js.map → chunk-BIPMCNAK.js.map} +1 -1
- package/dist/{chunk-2WY5GFGM.js → chunk-BKUKF632.js} +3 -3
- package/dist/{chunk-2WY5GFGM.js.map → chunk-BKUKF632.js.map} +1 -1
- package/dist/{chunk-57XKQ6VA.js → chunk-HGDFQDHT.js} +6 -6
- package/dist/{chunk-57XKQ6VA.js.map → chunk-HGDFQDHT.js.map} +1 -1
- package/dist/{chunk-7ZO3MUP3.js → chunk-HTIGD3DR.js} +5 -2
- package/dist/chunk-HTIGD3DR.js.map +1 -0
- package/dist/{chunk-NCHMJPKN.js → chunk-J4WDQL42.js} +4 -3
- package/dist/chunk-J4WDQL42.js.map +1 -0
- package/dist/{chunk-OJOK4VKC.js → chunk-LRA7VUT6.js} +3 -3
- package/dist/{chunk-OJOK4VKC.js.map → chunk-LRA7VUT6.js.map} +1 -1
- package/dist/{chunk-K5BUXOBH.js → chunk-NKPDUYRH.js} +120 -12
- package/dist/chunk-NKPDUYRH.js.map +1 -0
- package/dist/{chunk-OO5ITOUC.js → chunk-UEW6C64M.js} +3 -3
- package/dist/{chunk-OO5ITOUC.js.map → chunk-UEW6C64M.js.map} +1 -1
- package/dist/chunk-V6QKAC3Z.js +125 -0
- package/dist/chunk-V6QKAC3Z.js.map +1 -0
- package/dist/{chunk-YFBDJWRA.js → chunk-WMZT7VDS.js} +62 -14
- package/dist/chunk-WMZT7VDS.js.map +1 -0
- package/dist/{chunk-6FZCQT3V.js → chunk-X3DODPMF.js} +2 -2
- package/dist/{chunk-6FZCQT3V.js.map → chunk-X3DODPMF.js.map} +1 -1
- package/dist/{chunk-NMP4POJO.js → chunk-YNO3LBRH.js} +3 -3
- package/dist/{chunk-NMP4POJO.js.map → chunk-YNO3LBRH.js.map} +1 -1
- package/dist/{chunk-3AUHU52L.js → chunk-ZQZXCVYV.js} +2 -2
- package/dist/{chunk-3AUHU52L.js.map → chunk-ZQZXCVYV.js.map} +1 -1
- package/dist/cli/index.js +33 -33
- package/dist/connectors/index.js +5 -4
- package/dist/connectors/src/connector-prompt.d.ts +32 -0
- package/dist/connectors/src/connector-prompt.d.ts.map +1 -1
- package/dist/connectors/src/index.d.ts +2 -2
- package/dist/connectors/src/index.d.ts.map +1 -1
- package/dist/{ensure-sources-KQARQTTZ.js → ensure-sources-XYDPVBSP.js} +4 -4
- package/dist/{ensure-sources-KQARQTTZ.js.map → ensure-sources-XYDPVBSP.js.map} +1 -1
- package/dist/factory-assets/connectors/box.js +5 -4
- package/dist/factory-assets/connectors/deploy.js +5 -4
- package/dist/factory-assets/connectors/devserver.js +5 -4
- package/dist/factory-assets/connectors/flow/adapter.d.ts +8 -1
- package/dist/factory-assets/connectors/flow/adapter.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/adapter.js +5 -4
- package/dist/factory-assets/connectors/flow/index.d.ts +1 -1
- package/dist/factory-assets/connectors/flow/index.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/run-flow.js +6 -5
- package/dist/factory-assets/connectors/flow.js +5 -4
- package/dist/factory-assets/connectors/git/driver.d.ts.map +1 -1
- package/dist/factory-assets/connectors/git.js +5 -4
- package/dist/factory-assets/connectors/gmail.js +5 -4
- package/dist/factory-assets/connectors/googledrive.js +5 -4
- package/dist/factory-assets/connectors/local.js +5 -4
- package/dist/factory-assets/connectors/mattermost.js +5 -4
- package/dist/factory-assets/connectors/memory.js +5 -4
- package/dist/factory-assets/connectors/minio.js +5 -4
- package/dist/factory-assets/connectors/postgres.js +5 -4
- package/dist/factory-assets/connectors/s3.js +5 -4
- package/dist/factory-assets/connectors/sharepoint.js +5 -4
- package/dist/factory-assets/connectors/sqlite.js +5 -4
- package/dist/factory-assets/connectors/static-server.js +5 -4
- package/dist/factory-assets/connectors/tunnel.js +5 -4
- package/dist/factory-assets/connectors/webdav.js +5 -4
- package/dist/factory-assets/connectors/xstate-store.js +5 -4
- package/dist/factory-assets/connectors/xstate.js +5 -4
- package/dist/{helpers-LOJY7SGY.js → helpers-47SRTVSY.js} +4 -4
- package/dist/{helpers-LOJY7SGY.js.map → helpers-47SRTVSY.js.map} +1 -1
- package/dist/{library-publish-AVLOQR4R.js → library-publish-W7CIEIJJ.js} +6 -6
- package/dist/{library-publish-AVLOQR4R.js.map → library-publish-W7CIEIJJ.js.map} +1 -1
- package/dist/{open-library-A2UKFS2M.js → open-library-B2PEJ3UT.js} +5 -5
- package/dist/{open-library-A2UKFS2M.js.map → open-library-B2PEJ3UT.js.map} +1 -1
- package/dist/{project-NELXHEXE.js → project-TOICQYNZ.js} +5 -5
- package/dist/{project-NELXHEXE.js.map → project-TOICQYNZ.js.map} +1 -1
- package/dist/runner/index.js +10 -10
- package/dist/runner/src/codex-tools.d.ts.map +1 -1
- package/dist/runner/src/compaction-gate.d.ts +2 -0
- package/dist/runner/src/compaction-gate.d.ts.map +1 -1
- package/dist/runner/src/driver-swap-gate.d.ts +13 -0
- package/dist/runner/src/driver-swap-gate.d.ts.map +1 -1
- package/dist/runner/src/flow-turn-dispatch.d.ts +40 -0
- package/dist/runner/src/flow-turn-dispatch.d.ts.map +1 -0
- package/dist/runner/src/serve.d.ts +22 -1
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/runner/src/session-builder.d.ts +11 -1
- package/dist/runner/src/session-builder.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +1 -1
- package/dist/sdk/bridge.js +4 -3
- package/dist/sdk/index.js +10 -10
- package/dist/sdk/runner.js +10 -10
- package/dist/sdk/session.js +2 -2
- package/dist/sdk/transport/ws/server.js +1 -1
- package/dist/sdk/transport/ws.js +1 -1
- package/dist/sdk/transport.js +1 -1
- package/dist/sdk/types.js +1 -1
- package/dist/session/index.js +2 -2
- package/dist/{setup-WXYQJW56.js → setup-HLKIP7XW.js} +6 -5
- package/dist/setup-HLKIP7XW.js.map +1 -0
- package/dist/{source-VXH4TL3D.js → source-HZTCDRGB.js} +6 -6
- package/dist/{source-VXH4TL3D.js.map → source-HZTCDRGB.js.map} +1 -1
- package/dist/{source-manifest-publish-6TUZGQX2.js → source-manifest-publish-KEDEMOQO.js} +7 -7
- package/dist/{source-manifest-publish-6TUZGQX2.js.map → source-manifest-publish-KEDEMOQO.js.map} +1 -1
- package/dist/transport/index.js +1 -1
- package/dist/transport/src/ws/server.d.ts +3 -1
- package/dist/transport/src/ws/server.d.ts.map +1 -1
- package/dist/transport/ws/server.js +1 -1
- package/dist/transport/ws.js +1 -1
- package/dist/tui/index.js +10 -10
- package/dist/types/index.js +1 -1
- package/dist/types/src/events.d.ts +7 -2
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/tool-activity.d.ts +58 -0
- package/dist/types/src/tool-activity.d.ts.map +1 -0
- package/dist/types/src/version.d.ts +6 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/dist/workspace-plugin/adapters/mcp.js +2 -1
- package/dist/workspace-plugin/index.js +1 -1
- package/dist/workspace-plugin/src/adapters/mcp.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-7ZO3MUP3.js.map +0 -1
- package/dist/chunk-K5BUXOBH.js.map +0 -1
- package/dist/chunk-NBXH6RTU.js.map +0 -1
- package/dist/chunk-NCHMJPKN.js.map +0 -1
- package/dist/chunk-WQ7DE5UC.js.map +0 -1
- package/dist/chunk-YFBDJWRA.js.map +0 -1
- package/dist/chunk-ZJLO6HFS.js +0 -68
- package/dist/chunk-ZJLO6HFS.js.map +0 -1
- package/dist/setup-WXYQJW56.js.map +0 -1
package/dist/chunk-ZJLO6HFS.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// types/src/mentions.ts
|
|
2
|
-
var MENTION_GROUPS = ["agent", "humans", "humans_here", "here", "all"];
|
|
3
|
-
|
|
4
|
-
// types/src/reactions.ts
|
|
5
|
-
var QUICK_REACTIONS = [
|
|
6
|
-
"\u{1F44D}",
|
|
7
|
-
"\u{1F440}",
|
|
8
|
-
"\u2705",
|
|
9
|
-
"\u2764\uFE0F",
|
|
10
|
-
"\u{1F914}",
|
|
11
|
-
"\u{1FAE1}",
|
|
12
|
-
"\u{1F44F}",
|
|
13
|
-
"\u{1F389}"
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
// types/src/capabilities.ts
|
|
17
|
-
function isRenderCapability(cap) {
|
|
18
|
-
return cap.render !== void 0;
|
|
19
|
-
}
|
|
20
|
-
function isUserInvokable(cap) {
|
|
21
|
-
if (cap.audience !== void 0) {
|
|
22
|
-
return cap.audience.includes("user");
|
|
23
|
-
}
|
|
24
|
-
if (cap.userInvokable !== void 0) {
|
|
25
|
-
return cap.userInvokable;
|
|
26
|
-
}
|
|
27
|
-
switch (cap.origin.kind) {
|
|
28
|
-
case "framework":
|
|
29
|
-
case "client":
|
|
30
|
-
case "agent":
|
|
31
|
-
case "flow":
|
|
32
|
-
case "connector":
|
|
33
|
-
case "mount":
|
|
34
|
-
case "app":
|
|
35
|
-
return false;
|
|
36
|
-
case "mcp":
|
|
37
|
-
return cap.kind === "effect";
|
|
38
|
-
case "skill":
|
|
39
|
-
return cap.kind === "effect" || cap.kind === "render";
|
|
40
|
-
default:
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// types/src/version.ts
|
|
46
|
-
var PROTOCOL_VERSION = { major: 3, minor: 12, patch: 0 };
|
|
47
|
-
var PROTOCOL_VERSION_STRING = "3.12.0";
|
|
48
|
-
function parseVersion(s) {
|
|
49
|
-
const parts = s.split(".");
|
|
50
|
-
if (parts.length !== 3) {
|
|
51
|
-
throw new Error(`Invalid ProtocolVersion: "${s}" (expected "major.minor.patch")`);
|
|
52
|
-
}
|
|
53
|
-
const [maj, min, pat] = parts;
|
|
54
|
-
const major = Number(maj);
|
|
55
|
-
const minor = Number(min);
|
|
56
|
-
const patch = Number(pat);
|
|
57
|
-
if (!Number.isInteger(major) || !Number.isInteger(minor) || !Number.isInteger(patch) || major < 0 || minor < 0 || patch < 0) {
|
|
58
|
-
throw new Error(`Invalid ProtocolVersion: "${s}" (each part must be a non-negative integer)`);
|
|
59
|
-
}
|
|
60
|
-
return { major, minor, patch };
|
|
61
|
-
}
|
|
62
|
-
function formatVersion(v) {
|
|
63
|
-
return `${v.major}.${v.minor}.${v.patch}`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { MENTION_GROUPS, PROTOCOL_VERSION, PROTOCOL_VERSION_STRING, QUICK_REACTIONS, formatVersion, isRenderCapability, isUserInvokable, parseVersion };
|
|
67
|
-
//# sourceMappingURL=chunk-ZJLO6HFS.js.map
|
|
68
|
-
//# sourceMappingURL=chunk-ZJLO6HFS.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../types/src/mentions.ts","../types/src/reactions.ts","../types/src/capabilities.ts","../types/src/version.ts"],"names":[],"mappings":";AAmBO,IAAM,iBAAiB,CAAC,OAAA,EAAS,QAAA,EAAU,aAAA,EAAe,QAAQ,KAAK;;;ACevE,IAAM,eAAA,GAAkB;AAAA,EAC7B,WAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF;;;AC8LO,SAAS,mBAAmB,GAAA,EAA0C;AAC3E,EAAA,OAAO,IAAI,MAAA,KAAW,MAAA;AACxB;AAsCO,SAAS,gBAAgB,GAAA,EAA0B;AACx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O,GAAG,CAAA;AACxB,EAAA,IACE,CAAC,OAAO,SAAA,CAAU,KAAK,KACvB,CAAC,MAAA,CAAO,UAAU,KAAK,CAAA,IACvB,CAAC,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,IACvB,KAAA,GAAQ,KACR,KAAA,GAAQ,CAAA,IACR,QAAQ,CAAA,EACR;AACA,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,0BAAA,EAA6B,CAAC,CAAA,4CAAA,CAA8C,CAAA;AAAA,EAC9F;AACA,EAAA,OAAO,EAAE,KAAA,EAAO,KAAA,EAAO,KAAA,EAAM;AAC/B;AAiBO,SAAS,cAAc,CAAA,EAA4B;AACxD,EAAA,OAAO,CAAA,EAAG,EAAE,KAAK,CAAA,CAAA,EAAI,EAAE,KAAK,CAAA,CAAA,EAAI,EAAE,KAAK,CAAA,CAAA;AACzC","file":"chunk-ZJLO6HFS.js","sourcesContent":["/**\n * Mentions — types for @-mention support in session messages.\n *\n * A Mention records who was addressed in a message, whether a specific user\n * or a well-known group. Group mentions carry a resolved array of user IDs\n * so consumers can perform membership checks without the resolver.\n */\n\n// ---------------------------------------------------------------------------\n// Groups\n// ---------------------------------------------------------------------------\n\n/**\n * Well-known group mention targets as a `const` array.\n *\n * Use this for validation or exhaustive checks against `MentionGroup`.\n *\n * @docLink packages/types/messages#mention\n */\nexport const MENTION_GROUPS = [\"agent\", \"humans\", \"humans_here\", \"here\", \"all\"] as const;\n\n/**\n * A well-known group that can be `@`-mentioned: `'agent' | 'humans' | 'humans_here' | 'here' | 'all'`.\n *\n * @docLink packages/types/messages#mention\n */\nexport type MentionGroup = (typeof MENTION_GROUPS)[number];\n\n// ---------------------------------------------------------------------------\n// Mention discriminated union\n// ---------------------------------------------------------------------------\n\n/**\n * A parsed `@`-mention in a session message. Records who was addressed — either a\n * specific user or a well-known group — along with the source text position.\n *\n * Group mentions carry a resolved array of user IDs so consumers can perform\n * membership checks without needing the resolver.\n *\n * @docLink packages/types/messages#mention\n */\nexport type Mention =\n | {\n type: \"user\";\n userId: string;\n name: string;\n /** Position of the `@` character in the source text. */\n offset: number;\n /** Length of the full `@token` string including the `@`. */\n length: number;\n }\n | {\n type: \"group\";\n group: MentionGroup;\n /** User IDs resolved at parse time (e.g. all online users for `@here`). */\n resolved: string[];\n /** Position of the `@` character in the source text. */\n offset: number;\n /** Length of the full `@token` string including the `@`. */\n length: number;\n }\n | {\n type: \"custom\";\n /** Consumer-defined mention kind, e.g. \"assistant\". */\n kind: string;\n /** User IDs this mention resolves to (so isMentioned works); may be empty. */\n resolved: string[];\n /** Optional consumer payload, e.g. { sessionId, ownerId }. */\n data?: Record<string, unknown>;\n /** Position of the `@` character in the source text. */\n offset: number;\n /** Length of the full `@token` string including the `@`. */\n length: number;\n };\n","/**\n * Reactions -- emoji reactions on session messages.\n *\n * Any session participant (user or agent) can react to any message.\n * Reactions are persisted in a dedicated DB model and broadcast as\n * transient events for real-time updates.\n */\n\n/**\n * A single emoji reaction on a message, set by any session participant (user or agent).\n *\n * Reactions are persisted in a dedicated DB model and broadcast as transient events\n * for real-time updates.\n *\n * @docLink packages/types/messages#reaction\n */\nexport type Reaction = {\n /** Unicode emoji character (e.g. \"thumbs up\", not \":thumbsup:\"). */\n emoji: string;\n /** ID of the user (or \"agent\" for agent reactions). */\n userId: string;\n /** Display name at reaction time (avoids extra lookups for tooltip rendering). */\n userName: string;\n /** Unix epoch milliseconds. */\n timestamp: number;\n};\n\n/**\n * Quick-access emojis shown in the reaction bar picker.\n *\n * An `as const` array of eight Unicode emoji characters in display order.\n *\n * @docLink packages/types/messages#reaction\n */\nexport const QUICK_REACTIONS = [\n \"\\u{1F44D}\",\n \"\\u{1F440}\",\n \"\\u2705\",\n \"\\u2764\\uFE0F\",\n \"\\u{1F914}\",\n \"\\u{1FAE1}\",\n \"\\u{1F44F}\",\n \"\\u{1F389}\",\n] as const;\n","/**\n * Capability layer — Protocol v2's unified registry of LLM-invokable entry points.\n *\n * A {@link Capability} is a named, schema-typed entry point that the LLM can call\n * during a session. Capabilities are registered into a per-session\n * registry by either side (host platform via `side: 'client'` or runtime via\n * `side: 'agent'`) and routed by the bridge at invocation time.\n *\n * This module defines the wire types only; the runtime registry, the\n * `defineCapability` helper, and the per-handler logger live in\n * `@skaile/workspaces/runner`.\n *\n * @see {@link MessageV2} envelope that carries capability commands and events\n * @see {@link ProtocolVersion} for the version contract\n *\n * @category Capabilities\n * @since 2.0.0\n */\n\n// ---------------------------------------------------------------------------\n// Capability shape\n// ---------------------------------------------------------------------------\n\n/**\n * Visibility scope for a capability. Determines which surfaces the capability\n * appears on and which callers can invoke it.\n *\n * - `'llm'`: registered as an LLM tool, surfaced in the `<CAPABILITIES>` system\n * prompt section. The agent driver can invoke it.\n * - `'user'`: appears in user-facing surfaces — the command palette (cmdK),\n * debug menus, capability lists.\n * - `'runtime'`: invocable only by trusted runner / platform code paths. Never\n * reaches the LLM tool list. Never reaches the command palette. Used for\n * host RPCs (`host.refresh_credential`, `host.audit`, `host.notify_user`,\n * `host.persist_compaction_attempt`) and runner RPCs (`runner.add_mount`,\n * `runner.set_log_level`, `runner.lifecycle`, ...).\n *\n * Multiple audiences are allowed (e.g. `['llm', 'user']`). The default when\n * {@link Capability.audience} is omitted is `['llm', 'user']`, preserving the\n * v2.x default visibility for capabilities that haven't migrated yet.\n *\n * @category Capabilities\n * @since 3.0.0\n * @docLink packages/types/capabilities#capability-audience\n */\nexport type CapabilityAudience = \"llm\" | \"user\" | \"runtime\";\n\n/**\n * Source of truth for who registered a capability. Used for trust enforcement\n * (the bridge rejects mismatches between registering side and origin kind)\n * and for the `capability:<origin>:<name>` log taxonomy.\n *\n * Variants:\n * - `framework`: built-in (e.g. `__capabilities.list`)\n * - `client`: host platform (e.g. `platform.react`)\n * - `agent`: self-registered by the agent runtime\n * - `flow`: injected by an active flow execution\n * - `skill`: from a skill's MCP surface\n * - `mcp`: from a generic MCP server\n * - `connector`: from a connector (e.g. `postgres.query`)\n * - `mount`: surfaced by a filesystem mount\n * - `app`: from an embedded, agent-controllable app (carries the originating\n * `appId`). Handlers run in the app itself — see {@link Capability.side} `'app'`.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-origin\n */\nexport type CapabilityOrigin =\n | { kind: \"framework\" }\n | { kind: \"client\" }\n | { kind: \"agent\" }\n | { kind: \"flow\"; flowId: string }\n | { kind: \"skill\"; skillId: string }\n | { kind: \"mcp\"; serverId: string }\n | { kind: \"connector\"; connectorId: string }\n | { kind: \"mount\"; mountId: string }\n | { kind: \"app\"; appId: string };\n\n/**\n * Render contract for a capability that produces a UI surface when invoked.\n *\n * When the LLM invokes a capability whose `render` is set, the bridge emits\n * a {@link RenderInvokedEvent} carrying the capability name and props. The\n * client renders the configured `source` at the chosen `target`. Clients\n * without a render layer can fall back to the markdown `fallback` template.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#render-spec\n */\nexport type RenderSpec = {\n /** Where the rendered component lives. */\n source: { kind: \"web-component\"; url: string; tagName: string } | { kind: \"iframe\"; url: string };\n /** Render placements supported by the component. */\n targets: (\"chat\" | \"preview\" | \"modal\" | \"input-extension\")[];\n /** Markdown template with `{{prop}}` placeholders for clients without a render layer. */\n fallback?: string;\n /** True when props may be partial during streaming. */\n streaming?: boolean;\n /** Interaction names the rendered component may fire back as state events. */\n interactions?: string[];\n};\n\n/**\n * A named, schema-typed entry point that the LLM can invoke during a session.\n *\n * Capabilities can be declared statically (via `ConfigureCommand.capabilities`)\n * or dynamically (via {@link CapabilityRegisterCommand} /\n * {@link CapabilityRegisterEvent}). They are cached for replay across\n * subscriber reconnects and session hibernation.\n *\n * @example Defining a client-side fire-and-forget tool (uses the runner's\n * `defineCapability` helper, which serializes a {@link Capability} to the wire):\n * ```ts\n * const reactTool = defineCapability({\n * name: 'platform.react',\n * description: 'Acknowledge a user message with a Unicode emoji.',\n * side: 'client',\n * origin: { kind: 'client' },\n * fireAndForget: true,\n * input: z.object({ emoji: z.string(), targetSeq: z.number().optional() }),\n * handler: async ({ emoji, targetSeq }, ctx) => { ... },\n * });\n * ```\n *\n * @see {@link RenderCapability} for capabilities that render UI components\n * @see {@link CapabilityOrigin} for who-registered-it metadata\n * @see {@link isRenderCapability} for the type-guard\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability\n */\nexport type Capability = {\n /** Unique within a session. Convention: namespaced as `<origin>.<name>` (e.g. `platform.react`, `ui.gif`). */\n name: string;\n /**\n * Human-readable label for user-facing surfaces (cmdK action palette,\n * capability menus, debug panels). Falls back to {@link Capability.name}\n * when omitted. Pure presentation — the LLM sees `name`, not `displayName`.\n */\n displayName?: string;\n /** Human/LLM-readable summary. Shown to the LLM as part of tool registration. */\n description: string;\n /** JSON Schema validating the invocation arguments. Authored as Zod, converted at register time. */\n inputSchema: Record<string, unknown>;\n /** Optional return shape. Omit for fire-and-forget effects. */\n outputSchema?: Record<string, unknown>;\n /** Where the handler runs. `client` = host platform, `agent` = runtime/skill/connector, `app` = embedded app. */\n side: \"client\" | \"agent\" | \"app\";\n /** Discriminated tag identifying who registered the capability. Used for trust enforcement and audit. */\n origin: CapabilityOrigin;\n /** Lifetime: `session` survives the whole session, `turn` is dropped at end-of-turn. */\n scope?: \"session\" | \"turn\";\n /** When true, the bridge auto-resolves with `{}` immediately and runs the handler in the background. */\n fireAndForget?: boolean;\n /** When true, the platform shows a confirm UI before dispatch and waits for {@link CapabilityApproveCommand}. */\n requiresApproval?: boolean;\n /** Documentation hint (not enforced) describing whether this is a side-effect, render, or pure query. */\n kind?: \"effect\" | \"render\" | \"query\";\n /**\n * Whether this capability should be exposed in user-facing surfaces (cmdK\n * action palette, capability menus). When omitted, the consumer applies a\n * default per-origin via {@link isUserInvokable}.\n *\n * - `true`: surface in cmdK and capability menus.\n * - `false`: hide from user surfaces (LLM-only or low-level).\n * - `undefined`: defer to {@link isUserInvokable}'s inference rules.\n *\n * @deprecated Set {@link Capability.audience} instead. `userInvokable` is\n * kept as a read-only shim for v2.x consumers and is honoured by\n * {@link isUserInvokable} when {@link Capability.audience} is absent.\n */\n userInvokable?: boolean;\n /**\n * Audience scoping for this capability. See {@link CapabilityAudience} for\n * the meaning of each value and combinations.\n *\n * When omitted, consumers treat the capability as `['llm', 'user']` (the\n * v2.x default). Host RPCs and runner RPCs MUST set this to `['runtime']`\n * so they never leak to the LLM tool list or the user-facing surfaces.\n *\n * @category Capabilities\n * @since 3.0.0\n */\n audience?: CapabilityAudience[];\n /** Appended to the system prompt's `<CAPABILITIES>` section. Use for usage hints the LLM should always see. */\n promptFragment?: string;\n /**\n * Per-capability override for how long the runner waits on the\n * `capability_result` round-trip before timing out. When omitted the\n * runner applies its default (`DEFAULT_CAPABILITY_CALL_TIMEOUT_MS`, 60s).\n *\n * Set this for capabilities that legitimately block far longer than a\n * normal tool call — e.g. `platform.ask_session` suspends the caller's\n * turn until a peer session answers, which can take minutes.\n *\n * @category Capabilities\n * @since 3.3.0\n */\n callTimeoutMs?: number;\n /** Present iff this is a render capability — see {@link RenderCapability}. */\n render?: RenderSpec;\n};\n\n/**\n * A {@link Capability} that produces a UI surface when invoked. The narrowed\n * type guarantees `render` is set, which simplifies frontend lookup.\n *\n * @see {@link isRenderCapability}\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#render-capability\n */\nexport type RenderCapability = Capability & { render: NonNullable<Capability[\"render\"]> };\n\n/**\n * Type-guard for {@link RenderCapability}. Use after {@link Capability}\n * lookup to narrow the type before reading `render`.\n *\n * @example\n * ```ts\n * for (const cap of registry.list()) {\n * if (isRenderCapability(cap)) console.log(cap.render.targets);\n * }\n * ```\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#is-render-capability\n */\nexport function isRenderCapability(cap: Capability): cap is RenderCapability {\n return cap.render !== undefined;\n}\n\n/**\n * Decide whether a capability should be surfaced in user-facing actions\n * (cmdK action palette, capability menus).\n *\n * Resolution order (first match wins):\n *\n * 1. {@link Capability.audience} is set — return `audience.includes('user')`.\n * Capabilities scoped to `'runtime'` only never appear in user surfaces.\n * 2. {@link Capability.userInvokable} is set (v2.x shim) — return that value.\n * 3. Default per-origin inference table below.\n *\n * Default-inference rules (when both `audience` and `userInvokable` are\n * omitted):\n * | Origin | Default |\n * | ------------ | ---------------------------------------------------------------------- |\n * | `framework` | `false` (LLM discovery surfaces, e.g. `__capabilities.list`) |\n * | `client` | `false` (platform ack tools — `platform.react`, `platform.pass`) |\n * | `agent` | `false` (agent-defined; assume internal unless flagged) |\n * | `flow` | `false` (per-cap opt-in) |\n * | `connector` | `false` (low-level FS / data ops) |\n * | `mount` | `false` (low-level FS ops) |\n * | `app` | `false` (LLM-only; app authors opt in via `audience: ['llm','user']`) |\n * | `mcp` | `true` if `kind === 'effect'`, else `false` |\n * | `skill` | `true` if `kind` ∈ {`effect`, `render`}, else `false` |\n *\n * @example\n * ```ts\n * for (const cap of capabilities.values()) {\n * if (isUserInvokable(cap)) registerCommandPaletteAction(cap);\n * }\n * ```\n *\n * @category Capabilities\n * @since 2.1.0\n * @docLink packages/types/capabilities#is-user-invokable\n */\nexport function isUserInvokable(cap: Capability): boolean {\n if (cap.audience !== undefined) {\n return cap.audience.includes(\"user\");\n }\n if (cap.userInvokable !== undefined) {\n return cap.userInvokable;\n }\n switch (cap.origin.kind) {\n case \"framework\":\n case \"client\":\n case \"agent\":\n case \"flow\":\n case \"connector\":\n case \"mount\":\n case \"app\":\n return false;\n case \"mcp\":\n return cap.kind === \"effect\";\n case \"skill\":\n return cap.kind === \"effect\" || cap.kind === \"render\";\n default:\n return false;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Capability commands (client → agent)\n// ---------------------------------------------------------------------------\n\n/**\n * Register one or more capabilities mid-session (client → agent).\n *\n * The platform sends this when a new client-side tool becomes available\n * after `configure` has already returned (e.g. a user installs a new\n * extension during the session).\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-register-command\n */\nexport type CapabilityRegisterCommand = {\n type: \"capability_register\";\n capabilities: Capability[];\n};\n\n/**\n * Deregister capabilities by name (client → agent). Names that are not\n * currently registered are ignored silently.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-deregister-command\n */\nexport type CapabilityDeregisterCommand = {\n type: \"capability_deregister\";\n names: string[];\n};\n\n/**\n * Return the result of a previously {@link CapabilityInvokedEvent | invoked} client-side\n * capability (client → agent). Bridges that registered the capability with\n * `fireAndForget: true` MAY skip this command; the bridge auto-resolves with `{}`.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-result-command\n */\nexport type CapabilityResultCommand = {\n type: \"capability_result\";\n /** Correlation token matching the {@link CapabilityInvokedEvent.callId}. */\n callId: string;\n /** Successful result payload, or an error envelope. */\n result: unknown | { error: string };\n};\n\n/**\n * Invoke an **agent-side** capability (client → agent). The host names the\n * capability and supplies its input; the runner answers with a matching\n * {@link CapabilityResultEvent}. The mirror of {@link CapabilityInvokedEvent},\n * which reports the LLM invoking a client-side capability in the opposite\n * direction and shares this discriminant.\n *\n * @category Capabilities\n * @since 3.23.0\n * @docLink packages/types/capabilities#capability-invoke-command\n */\nexport type CapabilityInvokeCommand = {\n type: \"capability_invoked\";\n /** Correlation token the answering {@link CapabilityResultEvent} echoes. */\n callId: string;\n /** Name of the {@link Capability} to invoke. */\n name: string;\n /** Input payload, validated against the capability's schema by the registry. */\n input: unknown;\n};\n\n/**\n * Return the result of a platform-invoked **agent-side** capability\n * (agent → client). The mirror of {@link CapabilityResultCommand}, which\n * carries the same shape in the opposite direction for client-side\n * capabilities; `runner.attach_instance` and its `runner.*` siblings answer\n * with this one.\n *\n * Both directions share the `capability_result` discriminant, so the sender\n * decides which type applies — they are never both valid on one hop.\n *\n * @category Capabilities\n * @since 3.23.0\n * @docLink packages/types/capabilities#capability-result-event\n */\nexport type CapabilityResultEvent = {\n type: \"capability_result\";\n /** Correlation token matching the invoking call. */\n callId: string;\n /** Successful result payload, or an error envelope. */\n result: unknown | { error: string };\n};\n\n/**\n * Approve or reject a capability call that was invoked with\n * `requiresApproval: true` (client → agent). The platform shows a confirm\n * UI and forwards the user's decision via this command.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-approve-command\n */\nexport type CapabilityApproveCommand = {\n type: \"capability_approve\";\n /** Correlation token matching the {@link CapabilityInvokedEvent.callId}. */\n callId: string;\n /** User's decision. */\n decision: \"approved\" | \"rejected\";\n /** Optional rationale stored alongside the decision for audit. */\n feedback?: string;\n /** User ID of the decider (informational — framework enforces no policy). */\n decidedBy: string;\n};\n\n// ---------------------------------------------------------------------------\n// Capability events (agent → client)\n// ---------------------------------------------------------------------------\n\n/**\n * Register one or more capabilities mid-session (agent → client). Mirrors\n * {@link CapabilityRegisterCommand} for the agent-initiated direction; used\n * when the runtime adds a capability after `configure` (e.g. when a flow\n * starts and injects flow-scoped tools).\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-register-event\n */\nexport type CapabilityRegisterEvent = {\n type: \"capability_register\";\n capabilities: Capability[];\n};\n\n/**\n * Deregister capabilities by name (agent → client).\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-deregister-event\n */\nexport type CapabilityDeregisterEvent = {\n type: \"capability_deregister\";\n names: string[];\n};\n\n/**\n * Notify the client that a capability has been invoked by the LLM (agent →\n * client). For client-side capabilities the platform's handler runs in\n * response to this event and replies with {@link CapabilityResultCommand}.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-invoked-event\n */\nexport type CapabilityInvokedEvent = {\n type: \"capability_invoked\";\n /** Correlation token for the eventual {@link CapabilityResultCommand}. */\n callId: string;\n /** Name of the invoked {@link Capability}. */\n name: string;\n /** Validated input payload (already conforms to the capability's `inputSchema`). */\n input: unknown;\n /** In v2.0.0 the LLM is the only invoker. */\n invokedBy: \"agent\";\n};\n\n/**\n * Notify the client that a render capability should be drawn (agent →\n * client). Emitted alongside {@link CapabilityInvokedEvent} when the\n * invoked capability's `render` block is populated.\n *\n * Clients without a render layer can fall back to the capability's\n * `render.fallback` markdown template.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#render-invoked-event\n */\nexport type RenderInvokedEvent = {\n type: \"render_invoked\";\n /** Name of the invoked render capability. */\n capabilityName: string;\n /** Props passed to the rendered component (already conforms to `inputSchema`). */\n props: unknown;\n /** Correlation token shared with the matching {@link CapabilityInvokedEvent}. */\n callId: string;\n};\n","/**\n * Protocol versioning primitives for Skaile Agent Protocol v2.\n *\n * The protocol is versioned by a structured {@link ProtocolVersion} record\n * (`major.minor.patch`). The compatibility rule applied at handshake is\n * **major-equality**: a runner emits {@link IncompatibleProtocolEvent} and\n * shuts down when its declared major does not match the platform's announced\n * major. Minor and patch differences ride through transparently because\n * unknown fields are preserved on round-trip (see `MessageMeta` round-trip\n * contract in `messaging.ts`).\n *\n * @category Protocol\n * @since 2.0.0\n */\n\n/**\n * Structured semantic version triple for the agent protocol.\n *\n * @example\n * ```ts\n * const v: ProtocolVersion = { major: 2, minor: 0, patch: 0 };\n * ```\n *\n * @category Protocol\n * @since 2.0.0\n * @docLink packages/types/protocol-v2#protocol-version\n */\nexport type ProtocolVersion = {\n /** Incremented on breaking wire-format changes (field removed, semantics changed, required field added). */\n major: number;\n /** Incremented on additive wire-format changes (new optional fields, new event types). */\n minor: number;\n /** Incremented on bug-fix or doc-only changes that do not affect the wire. */\n patch: number;\n};\n\n/**\n * The protocol version the framework currently speaks. Runners and platforms\n * compare this against the peer's announced version at session boot via\n * `SessionInitCommand.protocolVersion`.\n *\n * @example\n * ```ts\n * import { PROTOCOL_VERSION } from '@skaile/workspaces/types';\n * if (cmd.protocolVersion.major !== PROTOCOL_VERSION.major) {\n * emit({ type: 'incompatible_protocol', agentVersion: PROTOCOL_VERSION, platformVersion: cmd.protocolVersion });\n * }\n * ```\n *\n * @category Protocol\n * @since 3.0.0\n *\n * Changed in 3.12.0:\n * Optional structured prompt attachments and question/reply requestId correlation.\n * Older peers retain text prompts and ignore unknown optional fields. Managed\n * question hosts must echo requestId; this minor does not advertise or admit the\n * separately gated codex-app-server-v1 runtime.\n *\n * Changed in 3.10.0:\n * Additive rejection cause on the AI-credential refresh input. The\n * `host.refresh_credential` `ai-credentials` input gains an optional\n * `rejection?: CredentialRejection` (`'auth' | 'usage-limit'`), sent only\n * alongside `reason: 'retry-401'` and only from the two runner call sites that\n * genuinely classified the failure — the driver's auth self-heal (`'auth'`) and\n * its usage-limit failover (`'usage-limit'`). `reason: 'retry-401'` collapsed\n * both, so a limit-blocked session on a config that is not opted into\n * `autoActivate` never re-resolved; the field is what lets the platform tell\n * them apart. `auth` asserts only that the rejection was auth-shaped, never\n * that capacity is fine (Anthropic mislabels OAuth quota exhaustion as\n * `authentication_error`); only `usage-limit` is a positive assertion. The\n * connector and MCP refresh paths classify nothing and keep emitting exactly\n * today's bytes. There is no peer-version gate, so a 3.9 peer does receive the\n * key on those two inputs; it is unaffected because nothing was removed or\n * reshaped and it must ignore an unknown key — and an unrecognised value —\n * rather than reject the input, which is also what allows a third rejection\n * later without a major bump. A 3.10 host against a 3.9 runner never sees the\n * field and must not read its absence as \"not a limit\" (feature-detect on\n * `major === 3 && minor >= 10`).\n * Spec: skaile-ai/platform#3562.\n *\n * Changed in 3.9.0:\n * Additive live AI-provider-seat signals, all optional under the\n * major-equality rule:\n * - `AgentEvent` gains `provider_response_seen`, emitted when the runner\n * observes a 401 or a 429 / subscription-limit rejection from the AI\n * provider, attributed to the pinned `AIProviderConfig`. A platform with\n * no handler broadcasts it harmlessly; consumers must ignore unknown\n * fields, since the platform half ships independently.\n * - The `CredentialMint` success branch gains an optional `configId` — the\n * seat the platform actually minted for. When it differs from the one the\n * runner asked for, the runner repoints the live session at it. A platform\n * that omits the field produces exactly 3.8 behaviour (no switch is ever\n * detected).\n * - The `credentialRotated` broadcast may carry `entry.data.configId` to\n * move a running session to a different seat rather than merely rotating\n * the token on the current one. Absent → today's re-pull.\n * A 3.8 peer is unaffected: nothing was removed or re-shaped, every addition is\n * opt-in on a field a 3.8 peer never sets. A 3.9 host against a 3.8 runner sees\n * no `provider_response_seen` and must not read that as \"no limits were hit\"\n * (feature-detect on `major === 3 && minor >= 9`).\n *\n * Changed in 3.8.0:\n * Additive `prompt` receipt acknowledgement. The `prompt` command gains an\n * optional `messageId`; when set the runner emits exactly one new `prompt_ack`\n * event echoing it, as the first act of handling the frame — before the\n * session-readiness gate, the secrets check and the driver start, each of which\n * could previously drop a prompt with no trace at all. When absent nothing is\n * emitted, so a 3.7 host sees byte-identical behaviour. A 3.8 host against a\n * 3.7 runner gets no ack and must not read that as a lost prompt — feature-detect\n * on `major === 3 && minor >= 8`. The ack is receipt-only: it says the frame\n * arrived, never that the turn ran.\n *\n * Changed in 3.7.0:\n * Additive `connector_mutate` acknowledgement + flow-hydrate reconciliation.\n * Three changes, all additive under the major-equality rule:\n * - `ConnectorMutateCommand` gains an optional `requestId`. When set, the\n * runner emits exactly one new `connector_mutate_response` event (with\n * `ok` / `result` / `error` / `code` / `reconciled`) on every terminal path,\n * including the paths that previously only logged. When absent nothing is\n * emitted, so a 3.6 host sees byte-identical behaviour.\n * - `flow.hydrate` accepts an optional `payload.pendingDecisions` —\n * `PendingGateDecision[]` the runner replays against the snapshot in the\n * same invocation that creates the flow connector, reporting the outcome as\n * `reconciled`. A host that omits the key gets today's hydrate.\n * - A flow-targeted mutate whose connector is not yet registered now waits\n * (bounded, `SKAILE_FLOW_MUTATE_CONNECTOR_WAIT_MS`, default 8000 ms) and\n * re-plans instead of failing — a behaviour change on a path that used to\n * fail silently, visible to a 3.6 host only as the op succeeding.\n * A 3.6 peer is unaffected: no symbol was removed or re-shaped, the ack is\n * opt-in on a field a 3.6 host never sets, and unknown fields ride through the\n * round-trip. A 3.7 host against a 3.6 runner sees `requestId` ignored and no\n * response, which it must treat as \"unacknowledged\" (feature-detect on\n * `major === 3 && minor >= 7`). Spec: `runner/MIGRATION-flow-connector.md`.\n *\n * Changed in 3.6.0:\n * Additive resolved-agent-config wire field. `ResolvedSkaileConfig` gains an\n * optional `agentConfig?: ResolvedAgentConfig` carrying the platform-resolved\n * driver / provider / model / cloud / cloudConfig / thinking / effort — the\n * same values the platform bakes into the generated skaile.yaml\n * `agent-config.default`. The runner applies it disk-first: any on-disk\n * `agent-config` profile with at least one agent setting disables the wire\n * value outright, so yaml-on-disk (docker-mode) sessions are byte-identical.\n * Additive under the major-equality rule: an older runner ignores the field\n * and an older platform simply omits it.\n *\n * Changed in 3.5.0:\n * Flow-connector host-contract fix (workspaces#379). Three coordinated changes,\n * all additive under the major-equality rule:\n * - `op:\"hydrate\"` on the bare `\"flow\"` connector now auto-creates the\n * `flow:<runId>` connector on a cold container from its `{ state, flow }`\n * payload, so a persisted run rehydrates in one op. A peer that still issues\n * `start` then `hydrate` keeps working unchanged.\n * - The dead `SessionInit.activeFlows` field (never read by the runner) and its\n * `ActiveFlowRehydration` type are removed — wire-compatible (nothing produced\n * or consumed them) but source-breaking for typed hosts, hence the bump.\n * - Malformed / conflicting flow `start` and `hydrate` payloads now fail loudly\n * (warn with a reason) instead of silently falling through.\n * Because the handshake compares only `major`, a 3.4 host and a 3.5 runner\n * interoperate: the auto-create path is opt-in on the payload the host sends, and\n * the removed field was already inert. Spec: `runner/MIGRATION-flow-connector.md`.\n *\n * Changed in 3.4.0:\n * Additive embedded-app capability source. `CapabilityOrigin` gains a\n * `{ kind: 'app'; appId: string }` variant and `Capability.side` gains `'app'`\n * (\"the handler runs in the embedded app\"). Both are additive: a peer that does\n * not understand `origin:'app'` / `side:'app'` never produces or routes them, so\n * they ride through transparently under the major-equality rule. No new message\n * types — `capability_register` / `capability_invoked` / `capability_result` /\n * `capability_approve` / `render_invoked` are reused verbatim. Spec:\n * `_devlog/specs/2026-07-07-app-capability-source.md`.\n *\n * Changed in 3.3.0:\n * Additive agent-to-agent (session-to-session) communication extension.\n * `AgentEvent` gains an `a2a_message` variant carrying cross-session messages\n * (`direction`, `peerSessionId`, `peerName`, `exchangeId`, `text`). `Capability`\n * gains an optional `callTimeoutMs?: number` so a long-running capability call\n * (e.g. a 5-minute `platform.ask_session`) can exceed the default capability-call\n * timeout. Both are additive: a peer that does not understand them ignores the\n * event / falls back to the default timeout, so they ride through transparently\n * under the major-equality rule.\n *\n * Changed in 3.2.0:\n * Additive wake-time resume cascade. `AgentReconfigureOptions` gains optional\n * `resumeSessionId` and `expectedCapabilitySignature` fields driving the tier-1\n * native SDK resume path; `AgentEvent` gains `ResumeAttemptedEvent` and\n * `ResumeFailedEvent`. `FinishedEvent` gains optional `customType` /\n * `customData` for capability-routed custom payloads. All additive — clients\n * that omit the resume hint or ignore the new events keep working unchanged.\n *\n * Changed in 3.1.0:\n * Additive cost / token usage extension. `FinishedEvent` gains an optional\n * `tokens?: TokenUsage` field carrying per-turn input / output / cache-read /\n * cache-creation / reasoning token counts. `AgentDriver.getTokenUsage()` is\n * widened to return the same `TokenUsage` shape (existing consumers reading\n * `inputTokens` / `outputTokens` keep working unchanged). Drivers that do not\n * surface token usage continue to return `null` / omit the field.\n *\n * Changed in 3.0.0:\n * Major bump for the deterministic session bootstrap rewrite. `ConfigureCommandV2`,\n * `provision_secrets`, `request_access_token`, `add_resource`, `remove_resource`,\n * `set_log_level`, `state_action`, `lifecycle`, `remount_mount`, `compact`, and\n * `reconfigure_agent` are removed from the `AgentCommand` union. Their semantics\n * are reachable through:\n * - `session_init` (one deterministic envelope at session start that delivers\n * identity, resolved config, pre-minted credentials, secrets, capabilities,\n * shared state, active flows, resume hints, and logging config),\n * - `host.refresh_credential` (capability invocation that replaces the\n * refresh-on-401 path of `request_access_token`), and\n * - `runner.*` capabilities (`runner.add_mount`, `runner.add_connector`,\n * `runner.remove_resource`, `runner.update_credential`, `runner.set_log_level`,\n * `runner.set_state`, `runner.lifecycle`) invoked by the platform via the\n * bidirectional capability registry.\n *\n * Capabilities gain an `audience: ('llm' | 'user' | 'runtime')[]` field that\n * scopes visibility: host RPCs (`host.*`) and runner RPCs (`runner.*`) are\n * `['runtime']` and never reach the LLM tool list or the user-facing command\n * palette. v2.x capabilities without an explicit `audience` default to\n * `['llm', 'user']`, preserving prior behaviour.\n *\n * Spec: `_devlog/specs/2026-05-10-deterministic-session-bootstrap.md`.\n *\n * @docLink packages/types/protocol-v3#protocol-version\n */\nexport const PROTOCOL_VERSION: ProtocolVersion = { major: 3, minor: 12, patch: 0 };\n\n/**\n * String form of {@link PROTOCOL_VERSION}, kept in lock-step. Useful for\n * `package.json` version fields and HTTP `User-Agent` strings.\n *\n * @category Protocol\n * @since 3.0.0\n * @docLink packages/types/protocol-v3#protocol-version\n */\nexport const PROTOCOL_VERSION_STRING = \"3.12.0\";\n\n/**\n * Parse a `\"major.minor.patch\"` string into a {@link ProtocolVersion}.\n *\n * @param s - the version string to parse, exactly three dot-separated non-negative integers\n * @returns the parsed protocol version\n * @throws {Error} if the string is not exactly three dot-separated non-negative integers\n *\n * @example\n * ```ts\n * parseVersion('2.0.0'); // { major: 2, minor: 0, patch: 0 }\n * parseVersion('2.1'); // throws\n * ```\n *\n * @category Protocol\n * @since 2.0.0\n * @docLink packages/types/protocol-v2#parse-version\n */\nexport function parseVersion(s: string): ProtocolVersion {\n const parts = s.split(\".\");\n if (parts.length !== 3) {\n throw new Error(`Invalid ProtocolVersion: \"${s}\" (expected \"major.minor.patch\")`);\n }\n const [maj, min, pat] = parts;\n const major = Number(maj);\n const minor = Number(min);\n const patch = Number(pat);\n if (\n !Number.isInteger(major) ||\n !Number.isInteger(minor) ||\n !Number.isInteger(patch) ||\n major < 0 ||\n minor < 0 ||\n patch < 0\n ) {\n throw new Error(`Invalid ProtocolVersion: \"${s}\" (each part must be a non-negative integer)`);\n }\n return { major, minor, patch };\n}\n\n/**\n * Format a {@link ProtocolVersion} record into its `\"major.minor.patch\"` string form.\n *\n * @param v - the protocol version to format\n * @returns the dot-joined string form\n *\n * @example\n * ```ts\n * formatVersion({ major: 2, minor: 0, patch: 0 }); // '2.0.0'\n * ```\n *\n * @category Protocol\n * @since 2.0.0\n * @docLink packages/types/protocol-v2#format-version\n */\nexport function formatVersion(v: ProtocolVersion): string {\n return `${v.major}.${v.minor}.${v.patch}`;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/src/setup.ts"],"names":["p","isCancel","result"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAM,aAAA,GAAgB,cAAc,MAAA,CAAO,CAACA,OAAMA,EAAAA,KAAM,UAAA,IAAcA,OAAM,YAAY,CAAA;AAExF,IAAM,eAAA,GAA0C;AAAA,EAC9C,SAAA,EAAW,oBAAA;AAAA,EACX,MAAA,EAAQ,cAAA;AAAA,EACR,MAAA,EAAQ,iBAAA;AAAA,EACR,OAAA,EAAS,YAAA;AAAA,EACT,IAAA,EAAM,uBAAA;AAAA,EACN,UAAA,EAAY,qCAAA;AAAA,EACZ,QAAA,EAAU,UAAA;AAAA,EACV,GAAA,EAAK,YAAA;AAAA,EACL,QAAA,EAAU,aAAA;AAAA,EACV,SAAA,EAAW;AACb,CAAA;AAEA,IAAM,iBAAA,GAA4C;AAAA,EAChD,SAAA,EAAW,6CAAA;AAAA,EACX,MAAA,EAAQ,sCAAA;AAAA,EACR,MAAA,EAAQ,oCAAA;AAAA,EACR,OAAA,EAAS,qCAAA;AAAA,EACT,IAAA,EAAM,+BAAA;AAAA,EACN,UAAA,EAAY,qCAAA;AAAA,EACZ,QAAA,EAAU,wCAAA;AAAA,EACV,GAAA,EAAK,uBAAA;AAAA,EACL,QAAA,EAAU,2CAAA;AAAA,EACV,SAAA,EAAW;AACb,CAAA;AAuBA,SAASC,UAAS,KAAA,EAAiC;AACjD,EAAA,OAAS,WAAS,KAAK,CAAA;AACzB;AAEA,SAAS,aAAgB,KAAA,EAA+C;AACtE,EAAA,IAAIA,SAAAA,CAAS,KAAK,CAAA,EAAG;AACnB,IAAE,SAAO,kBAAkB,CAAA;AAC3B,IAAA,OAAA,CAAQ,KAAK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;AAC3C,EAAA,MAAM,QAAA,GAAW,MAAM,eAAA,CAAgB,UAAU,CAAA;AAGjD,EAAA,MAAM,gBAAA,CAAiB,UAAU,OAAO,CAAA;AAGxC,EAAA,MAAM,aAAA,GAAgB,MAAM,YAAA,CAAa,QAAA,CAAS,MAAM,CAAA;AAExD,EAAA,MAAM,OAAA,GAAU,QAAA,CAAS,OAAA,IAAW,EAAC;AAGrC,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI,kBAAkB,YAAA,EAAc;AAClC,IAAA,MAAA,GAAS,MAAM,iBAAA,CAAkB,QAAA,EAAU,OAAA,EAAS,OAAO,CAAA;AAAA,EAC7D,CAAA,MAAA,IAAW,kBAAkB,OAAA,EAAS;AACpC,IAAA,MAAA,GAAS,MAAM,aAAA,CAAc,QAAA,EAAU,OAAA,EAAS,OAAO,CAAA;AAAA,EACzD,CAAA,MAAO;AACL,IAAA,MAAA,GAAS,MAAM,qBAAA,CAAsB,QAAA,EAAU,OAAA,EAAS,OAAO,CAAA;AAAA,EACjE;AAGA,EAAA,MAAM,cAAA,GAAiB,MAAM,oBAAA,CAAqB,UAAU,CAAA;AAG5D,EAAA,MAAM,aAAA;AAAA,IACJ;AAAA,MACE,WAAW,MAAA,CAAO,SAAA;AAAA,MAClB,SAAS,MAAA,CAAO,OAAA;AAAA,MAChB,eAAe,MAAA,CAAO,aAAA;AAAA,MACtB,cAAA;AAAA,MACA,iBAAiB,MAAA,CAAO,eAAA;AAAA,MACxB,cAAc,MAAA,CAAO,YAAA;AAAA,MACrB;AAAA,KACF;AAAA,IACA;AAAA,GACF;AAEA,EAAE,QAAM,iBAAiB,CAAA;AAC3B","file":"setup-WXYQJW56.js","sourcesContent":["/**\n * skaile setup — Interactive provider setup wizard\n *\n * Discovers existing config, lets the user pick providers, enter/validate API keys,\n * choose where to store them, and set defaults.\n */\n\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { getModels, validateApiKey } from \"@skaile/workspaces/bridge\";\nimport {\n ALL_PROVIDERS,\n detectEnvApiKeys,\n loadSettings,\n maskApiKey,\n projectSettingsPath,\n providerEnvKey,\n resolveSettings,\n type SkaileSettings,\n saveSettings,\n WorkspaceYamlEditor,\n} from \"@skaile/workspaces/core\";\n\n// ---------------------------------------------------------------------------\n// Provider metadata\n// ---------------------------------------------------------------------------\n\n/** LLM providers only (excludes voice providers) */\nconst LLM_PROVIDERS = ALL_PROVIDERS.filter((p) => p !== \"deepgram\" && p !== \"elevenlabs\");\n\nconst PROVIDER_LABELS: Record<string, string> = {\n anthropic: \"Anthropic (Claude)\",\n openai: \"OpenAI (GPT)\",\n google: \"Google (Gemini)\",\n mistral: \"Mistral AI\",\n groq: \"Groq (fast inference)\",\n openrouter: \"OpenRouter (multi-provider gateway)\",\n deepseek: \"DeepSeek\",\n xai: \"xAI (Grok)\",\n together: \"Together AI\",\n fireworks: \"Fireworks AI\",\n};\n\nconst PROVIDER_KEY_URLS: Record<string, string> = {\n anthropic: \"https://console.anthropic.com/settings/keys\",\n openai: \"https://platform.openai.com/api-keys\",\n google: \"https://aistudio.google.com/apikey\",\n mistral: \"https://console.mistral.ai/api-keys\",\n groq: \"https://console.groq.com/keys\",\n openrouter: \"https://openrouter.ai/settings/keys\",\n deepseek: \"https://platform.deepseek.com/api_keys\",\n xai: \"https://console.x.ai/\",\n together: \"https://api.together.ai/settings/api-keys\",\n fireworks: \"https://fireworks.ai/api-keys\",\n};\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ntype StorageTarget = \"settings\" | \"env-project\" | \"env-global\" | \"skip\";\ntype DefaultsTarget = \"project\" | \"personal\";\n\ninterface SetupPlan {\n providers: string[];\n newKeys: Record<string, string>;\n storageTarget: StorageTarget;\n defaultsTarget: DefaultsTarget;\n defaultProvider: string;\n defaultModel: string;\n defaultDriver: string;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction isCancel(value: unknown): value is symbol {\n return p.isCancel(value);\n}\n\nfunction exitOnCancel<T>(value: T): asserts value is Exclude<T, symbol> {\n if (isCancel(value)) {\n p.cancel(\"Setup cancelled.\");\n process.exit(0);\n }\n}\n\n/** Load .env files from common locations and parse key=value pairs */\nfunction loadDotenvKeys(): Record<string, string> {\n const locations = [path.join(process.cwd(), \".env\"), path.join(os.homedir(), \".env\")];\n const result: Record<string, string> = {};\n for (const loc of locations) {\n try {\n const content = fs.readFileSync(loc, \"utf-8\");\n for (const line of content.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eq = trimmed.indexOf(\"=\");\n if (eq === -1) continue;\n const key = trimmed.slice(0, eq).trim();\n let val = trimmed.slice(eq + 1).trim();\n // Strip surrounding quotes\n if (\n (val.startsWith('\"') && val.endsWith('\"')) ||\n (val.startsWith(\"'\") && val.endsWith(\"'\"))\n ) {\n val = val.slice(1, -1);\n }\n result[key] = val;\n }\n } catch {\n // file doesn't exist, skip\n }\n }\n return result;\n}\n\n/** Append key=value entries to a .env file without overwriting existing keys */\nfunction appendEnvFile(filePath: string, entries: Record<string, string>): void {\n let existing = \"\";\n try {\n existing = fs.readFileSync(filePath, \"utf-8\");\n } catch {\n // file doesn't exist yet\n }\n\n const existingKeys = new Set<string>();\n for (const line of existing.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eq = trimmed.indexOf(\"=\");\n if (eq !== -1) existingKeys.add(trimmed.slice(0, eq).trim());\n }\n\n const lines: string[] = [];\n for (const [key, value] of Object.entries(entries)) {\n if (existingKeys.has(key)) {\n p.log.warn(` ${key} already exists in ${filePath} — skipping`);\n continue;\n }\n lines.push(`${key}=${value}`);\n }\n\n if (lines.length === 0) return;\n\n const separator = existing.endsWith(\"\\n\") || existing === \"\" ? \"\" : \"\\n\";\n const content = `${separator + lines.join(\"\\n\")}\\n`;\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n fs.appendFileSync(filePath, content, \"utf-8\");\n}\n\n// ---------------------------------------------------------------------------\n// Wizard steps\n// ---------------------------------------------------------------------------\n\nasync function showCurrentState(\n settings: SkaileSettings,\n envKeys: Record<string, string>,\n): Promise<void> {\n const apiKeys = settings.apiKeys ?? {};\n const lines: string[] = [\"Provider keys:\"];\n for (const provider of LLM_PROVIDERS) {\n const envVal = envKeys[provider];\n const storedVal = apiKeys[provider];\n if (envVal) {\n lines.push(` ${provider.padEnd(12)} [env] ${maskApiKey(envVal)}`);\n } else if (storedVal) {\n lines.push(` ${provider.padEnd(12)} [stored] ${maskApiKey(storedVal)}`);\n } else {\n lines.push(` ${provider.padEnd(12)} (not configured)`);\n }\n }\n lines.push(\"\");\n lines.push(\"Current defaults:\");\n lines.push(` Provider: ${settings.provider ?? \"(not set)\"}`);\n lines.push(` Model: ${settings.model ?? \"(not set)\"}`);\n lines.push(` Driver: ${settings.driver ?? \"(not set)\"}`);\n\n p.note(lines.join(\"\\n\"), \"Current configuration\");\n}\n\nasync function selectProviders(\n envKeys: Record<string, string>,\n storedKeys: Record<string, string>,\n): Promise<string[]> {\n const result = await p.multiselect({\n message: \"Which providers do you want to configure?\",\n options: LLM_PROVIDERS.map((id) => ({\n value: id,\n label: PROVIDER_LABELS[id] ?? id,\n hint: envKeys[id]\n ? `env: ${maskApiKey(envKeys[id])}`\n : storedKeys[id]\n ? `stored: ${maskApiKey(storedKeys[id])}`\n : undefined,\n })),\n initialValues: LLM_PROVIDERS.filter((id) => envKeys[id] || storedKeys[id]),\n required: true,\n });\n exitOnCancel(result);\n return result as string[];\n}\n\n/**\n * Run the optional validation step for a freshly entered key.\n * Returns true if the key should be kept (valid, or user opted to keep anyway),\n * false if it should be discarded.\n */\nasync function confirmKeyAfterValidation(provider: string, key: string): Promise<boolean> {\n const shouldValidate = await p.confirm({\n message: \"Validate this key?\",\n initialValue: true,\n });\n exitOnCancel(shouldValidate);\n\n if (!shouldValidate) return true;\n\n const s = p.spinner();\n s.start(`Validating ${provider} key...`);\n const result = await validateApiKey(provider, key);\n if (result.ok) {\n s.stop(`${provider} key is valid`);\n return true;\n }\n s.stop(`${provider} validation failed: ${result.error}`);\n const retry = await p.confirm({\n message: \"Use this key anyway?\",\n initialValue: false,\n });\n exitOnCancel(retry);\n return retry;\n}\n\n/**\n * Collect (or skip) the API key for a single provider.\n * Returns the entered key, or undefined when the provider is already configured,\n * the user declines to update, leaves it blank, or rejects a failed validation.\n */\nasync function collectProviderKey(\n provider: string,\n envKeys: Record<string, string>,\n storedKeys: Record<string, string>,\n): Promise<string | undefined> {\n const envVar = providerEnvKey(provider);\n\n if (envKeys[provider]) {\n p.log.info(`${PROVIDER_LABELS[provider] ?? provider}: already set via ${envVar}`);\n return undefined;\n }\n\n if (storedKeys[provider]) {\n const update = await p.confirm({\n message: `${PROVIDER_LABELS[provider] ?? provider}: key already stored (${maskApiKey(storedKeys[provider])}). Update it?`,\n initialValue: false,\n });\n exitOnCancel(update);\n if (!update) return undefined;\n }\n\n const keyUrl = PROVIDER_KEY_URLS[provider];\n const key = await p.password({\n message: `${PROVIDER_LABELS[provider] ?? provider} API key${keyUrl ? ` (get one at ${keyUrl})` : \"\"}:`,\n });\n exitOnCancel(key);\n\n if (!key) return undefined;\n\n const keep = await confirmKeyAfterValidation(provider, key);\n if (!keep) return undefined;\n\n return key;\n}\n\nasync function collectApiKeys(\n providers: string[],\n envKeys: Record<string, string>,\n storedKeys: Record<string, string>,\n): Promise<Record<string, string>> {\n const newKeys: Record<string, string> = {};\n\n for (const provider of providers) {\n const key = await collectProviderKey(provider, envKeys, storedKeys);\n if (key !== undefined) newKeys[provider] = key;\n }\n\n return newKeys;\n}\n\nasync function selectStorageTarget(): Promise<StorageTarget> {\n const result = await p.select({\n message: \"Where should API keys be stored?\",\n options: [\n { value: \"settings\" as const, label: \".skaile/settings.json (project-local, gitignored)\" },\n { value: \"env-project\" as const, label: `${process.cwd()}/.env (project-level)` },\n { value: \"env-global\" as const, label: `${os.homedir()}/.env (global)` },\n { value: \"skip\" as const, label: \"Skip — I'll set env vars myself\" },\n ],\n });\n exitOnCancel(result);\n return result as StorageTarget;\n}\n\nasync function selectDefaultProvider(providers: string[], current?: string): Promise<string> {\n const result = await p.select({\n message: \"Default LLM provider:\",\n options: providers.map((id) => ({\n value: id,\n label: PROVIDER_LABELS[id] ?? id,\n })),\n initialValue: current && providers.includes(current) ? current : providers[0],\n });\n exitOnCancel(result);\n return result as string;\n}\n\nasync function selectDefaultModel(\n provider: string,\n current?: string,\n apiKey?: string,\n): Promise<string> {\n // Try live model list from provider API, fall back to static catalog\n const s = apiKey ? p.spinner() : undefined;\n if (s) s.start(`Fetching models from ${provider}...`);\n\n const fetchResult = await getModels(provider, apiKey);\n\n if (s) {\n if (fetchResult.source === \"api\") {\n s.stop(`Loaded ${fetchResult.models.length} models from ${provider} API`);\n } else if (fetchResult.error) {\n s.stop(`Could not fetch live models (${fetchResult.error}) — using built-in catalog`);\n } else {\n s.stop(`Using built-in model catalog`);\n }\n }\n\n const models = fetchResult.models;\n if (models.length === 0) {\n p.log.warn(`No models found for ${provider} — enter a model ID manually`);\n const result = await p.text({\n message: \"Model ID:\",\n initialValue: current ?? \"\",\n });\n exitOnCancel(result);\n return result as string;\n }\n\n const result = await p.select({\n message: `Default model (${provider}):`,\n options: models.map((m) => ({\n value: m.id,\n label: `${m.name} (${m.id})`,\n })),\n initialValue: current && models.some((m) => m.id === current) ? current : models[0].id,\n });\n exitOnCancel(result);\n return result as string;\n}\n\nasync function selectDriver(current?: string): Promise<string> {\n const result = await p.select({\n message: \"Default agent driver:\",\n options: [\n { value: \"omp\", label: \"omp (oh-my-pi — multi-provider, recommended)\" },\n { value: \"claude-sdk\", label: \"claude-sdk (Anthropic Agent SDK, Claude only)\" },\n { value: \"codex\", label: \"codex (OpenAI Codex SDK, OpenAI only)\" },\n ],\n initialValue: current ?? \"omp\",\n });\n exitOnCancel(result);\n return result as string;\n}\n\nasync function selectDefaultsTarget(projectDir: string): Promise<DefaultsTarget> {\n const yamlPath = path.join(projectDir, \"skaile.yaml\");\n const hasYaml = fs.existsSync(yamlPath);\n\n if (!hasYaml) {\n // No skaile.yaml — can only save personally\n return \"personal\";\n }\n\n const result = await p.select({\n message: \"Where should driver, provider, and model defaults be saved?\",\n options: [\n {\n value: \"project\" as const,\n label: \"skaile.yaml (project-wide, shared with team)\",\n hint: \"recommended\",\n },\n {\n value: \"personal\" as const,\n label: \".skaile/settings.json (personal only, gitignored)\",\n },\n ],\n initialValue: \"project\" as const,\n });\n exitOnCancel(result);\n return result as DefaultsTarget;\n}\n\n/** Build the human-readable summary shown before applying the plan. */\nfunction buildSummaryLines(plan: SetupPlan, settingsFile: string): string[] {\n const lines: string[] = [];\n\n if (Object.keys(plan.newKeys).length > 0) {\n lines.push(\"New API keys:\");\n for (const [provider, key] of Object.entries(plan.newKeys)) {\n lines.push(` ${provider.padEnd(12)} ${maskApiKey(key)}`);\n }\n const targetLabels: Record<StorageTarget, string> = {\n settings: `.skaile/settings.json (${settingsFile})`,\n \"env-project\": `${process.cwd()}/.env`,\n \"env-global\": `${os.homedir()}/.env`,\n skip: \"not saved (set env vars manually)\",\n };\n lines.push(` Storage: ${targetLabels[plan.storageTarget]}`);\n lines.push(\"\");\n }\n\n const defaultsLabel =\n plan.defaultsTarget === \"project\"\n ? \"skaile.yaml (project-wide)\"\n : \".skaile/settings.json (personal)\";\n lines.push(\"Defaults:\");\n lines.push(` Provider: ${plan.defaultProvider}`);\n lines.push(` Model: ${plan.defaultModel}`);\n lines.push(` Driver: ${plan.defaultDriver}`);\n lines.push(` Saved to: ${defaultsLabel}`);\n\n return lines;\n}\n\n/**\n * Write the new API keys to the chosen storage target.\n * For the `settings` target the keys are merged into `merged.apiKeys` (mutated\n * in place); for the env targets they are appended to the relevant `.env` file.\n */\nfunction persistApiKeys(plan: SetupPlan, merged: SkaileSettings): void {\n const hasNewKeys = Object.keys(plan.newKeys).length > 0;\n\n if (hasNewKeys && plan.storageTarget === \"settings\") {\n const apiKeys = { ...(merged.apiKeys ?? {}) };\n for (const [provider, key] of Object.entries(plan.newKeys)) {\n apiKeys[provider] = key;\n }\n merged.apiKeys = apiKeys;\n } else if (hasNewKeys && plan.storageTarget === \"env-project\") {\n const envEntries: Record<string, string> = {};\n for (const [provider, key] of Object.entries(plan.newKeys)) {\n envEntries[providerEnvKey(provider)] = key;\n }\n appendEnvFile(path.join(process.cwd(), \".env\"), envEntries);\n p.log.success(`Appended keys to ${process.cwd()}/.env`);\n } else if (hasNewKeys && plan.storageTarget === \"env-global\") {\n const envEntries: Record<string, string> = {};\n for (const [provider, key] of Object.entries(plan.newKeys)) {\n envEntries[providerEnvKey(provider)] = key;\n }\n appendEnvFile(path.join(os.homedir(), \".env\"), envEntries);\n p.log.success(`Appended keys to ${os.homedir()}/.env`);\n }\n}\n\n/**\n * Apply the plan's defaults: write them to skaile.yaml when saving project-wide,\n * and set/strip the corresponding personal settings fields on `merged` (mutated\n * in place) so they don't shadow project-wide values.\n */\nfunction applyDefaults(plan: SetupPlan, projectDir: string, merged: SkaileSettings): void {\n // Save defaults to skaile.yaml or settings.json depending on user choice\n if (plan.defaultsTarget === \"project\") {\n const yamlPath = path.join(projectDir, \"skaile.yaml\");\n const editor = WorkspaceYamlEditor.load(yamlPath);\n editor.setAgentConfig(\"default\", {\n provider: plan.defaultProvider,\n model: plan.defaultModel,\n driver: plan.defaultDriver,\n });\n editor.save();\n p.log.success(`Saved defaults to ${yamlPath}`);\n }\n\n // Personal settings: only include defaults if saving personally, always include API keys.\n // When saving to project (skaile.yaml), strip driver/provider/model from settings.json\n // so they don't shadow the project-wide values.\n if (plan.defaultsTarget === \"personal\") {\n merged.provider = plan.defaultProvider;\n merged.model = plan.defaultModel;\n merged.driver = plan.defaultDriver;\n } else {\n delete merged.provider;\n delete merged.model;\n delete merged.driver;\n }\n}\n\nasync function reviewAndSave(plan: SetupPlan, projectDir: string): Promise<void> {\n const settingsFile = projectSettingsPath(projectDir);\n\n p.note(buildSummaryLines(plan, settingsFile).join(\"\\n\"), \"Summary\");\n\n const confirmed = await p.confirm({\n message: \"Apply these settings?\",\n initialValue: true,\n });\n exitOnCancel(confirmed);\n\n if (!confirmed) {\n p.cancel(\"Setup cancelled — no changes were made.\");\n process.exit(0);\n }\n\n // Load existing project settings (or empty)\n const existing = await loadSettings(settingsFile);\n\n const merged: SkaileSettings = { ...existing };\n applyDefaults(plan, projectDir, merged);\n persistApiKeys(plan, merged);\n\n // Write unified settings file\n await saveSettings(merged, settingsFile);\n p.log.success(`Saved settings to ${settingsFile}`);\n}\n\n// ---------------------------------------------------------------------------\n// Main entry\n// ---------------------------------------------------------------------------\n\n/** Check whether Claude Code OAuth credentials exist on disk */\nfunction hasClaudeCodeCredentials(): boolean {\n const credPath = path.join(os.homedir(), \".claude\", \".credentials.json\");\n try {\n const content = fs.readFileSync(credPath, \"utf-8\");\n const parsed = JSON.parse(content);\n // Check that it has at least one non-empty field\n return parsed && (parsed.accessToken || parsed.refreshToken || parsed.oauthToken);\n } catch {\n return false;\n }\n}\n\n/** The provider/key/model portion of a SetupPlan produced by a per-driver flow. */\ninterface DriverSetupResult {\n providers: string[];\n newKeys: Record<string, string>;\n storageTarget: StorageTarget;\n defaultProvider: string;\n defaultModel: string;\n}\n\n/**\n * Claude SDK path: Anthropic only. Honours an existing API key (env or stored)\n * or Claude Code OAuth credentials, otherwise offers to enter a key.\n */\nasync function runClaudeSdkSetup(\n settings: SkaileSettings,\n envKeys: Record<string, string>,\n apiKeys: Record<string, string>,\n): Promise<DriverSetupResult> {\n const defaultProvider = \"anthropic\";\n let newKeys: Record<string, string>;\n let storageTarget: StorageTarget = \"skip\";\n\n // Check for existing auth: API key or Claude Code OAuth credentials\n const hasEnvKey = !!envKeys.anthropic;\n const hasStoredKey = !!apiKeys.anthropic;\n const hasOAuth = hasClaudeCodeCredentials();\n\n if (hasEnvKey) {\n p.log.info(`Anthropic API key found in environment (${maskApiKey(envKeys.anthropic)})`);\n newKeys = {};\n } else if (hasStoredKey) {\n p.log.info(`Anthropic API key found in settings (${maskApiKey(apiKeys.anthropic)})`);\n newKeys = {};\n } else if (hasOAuth) {\n p.log.info(\"Claude Code subscription detected (OAuth credentials found)\");\n p.log.info(\"The Claude SDK will use your Claude Code login — no API key needed.\");\n newKeys = {};\n } else {\n // No auth found — prompt for Anthropic API key\n p.log.warn(\"No Anthropic API key or Claude Code subscription found.\");\n p.log.info(\"You can either:\");\n p.log.info(\" 1. Enter an Anthropic API key now\");\n p.log.info(\" 2. Run `claude login` to authenticate with Claude Code\");\n\n const wantsKey = await p.confirm({\n message: \"Enter an Anthropic API key?\",\n initialValue: true,\n });\n exitOnCancel(wantsKey);\n\n if (wantsKey) {\n newKeys = await collectApiKeys([\"anthropic\"], envKeys, apiKeys);\n } else {\n newKeys = {};\n }\n }\n\n // Storage target (only ask if there are new keys)\n if (Object.keys(newKeys).length > 0) {\n storageTarget = await selectStorageTarget();\n }\n\n // Model selection — only Anthropic models (try live fetch with available key)\n const anthropicKey = newKeys.anthropic ?? envKeys.anthropic ?? apiKeys.anthropic;\n const defaultModel = await selectDefaultModel(\"anthropic\", settings.model, anthropicKey);\n\n return { providers: [\"anthropic\"], newKeys, storageTarget, defaultProvider, defaultModel };\n}\n\n/** Codex path: OpenAI only. Honours an existing key, otherwise prompts for one. */\nasync function runCodexSetup(\n settings: SkaileSettings,\n envKeys: Record<string, string>,\n apiKeys: Record<string, string>,\n): Promise<DriverSetupResult> {\n const defaultProvider = \"openai\";\n let newKeys: Record<string, string>;\n let storageTarget: StorageTarget = \"skip\";\n\n const hasEnvKey = !!envKeys.openai;\n const hasStoredKey = !!apiKeys.openai;\n\n if (hasEnvKey) {\n p.log.info(`OpenAI API key found in environment (${maskApiKey(envKeys.openai)})`);\n newKeys = {};\n } else if (hasStoredKey) {\n p.log.info(`OpenAI API key found in settings (${maskApiKey(apiKeys.openai)})`);\n newKeys = {};\n } else {\n p.log.warn(\"No OpenAI API key found.\");\n newKeys = await collectApiKeys([\"openai\"], envKeys, apiKeys);\n }\n\n if (Object.keys(newKeys).length > 0) {\n storageTarget = await selectStorageTarget();\n }\n\n const openaiKey = newKeys.openai ?? envKeys.openai ?? apiKeys.openai;\n const defaultModel = await selectDefaultModel(\"openai\", settings.model, openaiKey);\n\n return { providers: [\"openai\"], newKeys, storageTarget, defaultProvider, defaultModel };\n}\n\n/** omp / pi path: multi-provider flow (existing behavior). */\nasync function runMultiProviderSetup(\n settings: SkaileSettings,\n envKeys: Record<string, string>,\n apiKeys: Record<string, string>,\n): Promise<DriverSetupResult> {\n let storageTarget: StorageTarget = \"skip\";\n\n // 4. Select providers\n const providers = await selectProviders(envKeys, apiKeys);\n\n // 5. Collect API keys\n const newKeys = await collectApiKeys(providers, envKeys, apiKeys);\n\n // 6. Storage target (only ask if there are new keys)\n if (Object.keys(newKeys).length > 0) {\n storageTarget = await selectStorageTarget();\n }\n\n // 7. Default provider (from selected providers + any already configured)\n const allConfigured = [\n ...new Set([\n ...providers,\n ...Object.keys(envKeys),\n ...Object.keys(apiKeys).filter((k) => apiKeys[k]),\n ]),\n ].filter((p) => LLM_PROVIDERS.includes(p as any));\n const defaultProvider = await selectDefaultProvider(\n allConfigured.length > 0 ? allConfigured : providers,\n settings.provider,\n );\n\n // 8. Default model (try live fetch with available key)\n const providerKey =\n newKeys[defaultProvider] ?? envKeys[defaultProvider] ?? apiKeys[defaultProvider];\n const defaultModel = await selectDefaultModel(defaultProvider, settings.model, providerKey);\n\n return { providers, newKeys, storageTarget, defaultProvider, defaultModel };\n}\n\n/**\n * Interactive provider setup wizard: discovers existing config, prompts for\n * provider/model/driver preferences and API keys, then writes the results to\n * `skaile.yaml` or `.skaile/settings.json` depending on the user's choice.\n *\n * @param _args - Unused positional args (reserved for future use).\n * @param opts - Options including an optional `projectDir` override.\n * @docLink cli/dev-guide#setup\n */\nexport async function cmdSetup(_args: string[], opts: { projectDir?: string }): Promise<void> {\n p.intro(\"skaile setup\");\n\n const projectDir = opts.projectDir ?? process.cwd();\n\n // 1. Detect existing state via layered resolution\n const dotenvKeys = loadDotenvKeys();\n const envKeys = detectEnvApiKeys(dotenvKeys);\n const settings = await resolveSettings(projectDir);\n\n // 2. Show current state\n await showCurrentState(settings, envKeys);\n\n // 3. Select driver FIRST — it determines which providers/models are relevant\n const defaultDriver = await selectDriver(settings.driver);\n\n const apiKeys = settings.apiKeys ?? {};\n\n // Per-driver provider/key/model flow\n let result: DriverSetupResult;\n if (defaultDriver === \"claude-sdk\") {\n result = await runClaudeSdkSetup(settings, envKeys, apiKeys);\n } else if (defaultDriver === \"codex\") {\n result = await runCodexSetup(settings, envKeys, apiKeys);\n } else {\n result = await runMultiProviderSetup(settings, envKeys, apiKeys);\n }\n\n // 9. Choose where to save defaults (project-wide vs personal)\n const defaultsTarget = await selectDefaultsTarget(projectDir);\n\n // 10. Review and save\n await reviewAndSave(\n {\n providers: result.providers,\n newKeys: result.newKeys,\n storageTarget: result.storageTarget,\n defaultsTarget,\n defaultProvider: result.defaultProvider,\n defaultModel: result.defaultModel,\n defaultDriver,\n },\n projectDir,\n );\n\n p.outro(\"Setup complete!\");\n}\n"]}
|