clay-server 5.2.0-beta.5 → 5.2.0-beta.6

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.
Files changed (151) hide show
  1. package/lib/claude-hook-installer.js +1 -267
  2. package/lib/claude-jsonl-watcher.js +1 -204
  3. package/lib/clay-skill-install.js +1 -33
  4. package/lib/cli-sessions.js +1 -300
  5. package/lib/codex-defaults.js +1 -28
  6. package/lib/context-usage.js +3 -2
  7. package/lib/daemon.js +5 -55
  8. package/lib/default-ai-runtime.js +4 -8
  9. package/lib/email-mcp-server.js +1 -1
  10. package/lib/kiro-defaults.js +1 -22
  11. package/lib/mcp-proxy.js +2 -32
  12. package/lib/mcp-query-bridge.js +1 -1
  13. package/lib/mcp-source-adapters.js +1 -91
  14. package/lib/mcp-source-context.js +1 -42
  15. package/lib/mcp-source-discovery.js +1 -169
  16. package/lib/mcp-source-plugins.js +1 -68
  17. package/lib/mcp-source-restrictions.js +1 -47
  18. package/lib/mcp-tool-policy.js +1 -26
  19. package/lib/os-user-diagnostics.js +2 -4
  20. package/lib/os-users.js +4 -65
  21. package/lib/project-connection.js +8 -7
  22. package/lib/project-http.js +4 -4
  23. package/lib/project-mcp.js +2 -2
  24. package/lib/project-pair-result-delivery.js +2 -2
  25. package/lib/project-pair-usage.js +12 -13
  26. package/lib/project-pending-message-queue.js +3 -1
  27. package/lib/project-session-history-actions.js +5 -3
  28. package/lib/project-session-pair.js +1 -1
  29. package/lib/project-session-runtime-actions.js +2 -1
  30. package/lib/project-session-spawn.js +2 -3
  31. package/lib/project-session-vendor.js +2 -1
  32. package/lib/project-sessions.js +18 -26
  33. package/lib/project-user-message.js +1 -0
  34. package/lib/project-vendor-login.js +6 -36
  35. package/lib/public/app.js +1 -0
  36. package/lib/public/css/messages.css +6 -2
  37. package/lib/public/modules/app-favicon.js +11 -2
  38. package/lib/public/modules/app-header.js +4 -2
  39. package/lib/public/modules/app-loop-ui.js +2 -0
  40. package/lib/public/modules/app-messages.js +36 -5
  41. package/lib/public/modules/app-notifications.js +1 -2
  42. package/lib/public/modules/app-panels.js +61 -123
  43. package/lib/public/modules/app-rate-limit.js +7 -27
  44. package/lib/public/modules/chat-render-runtime.js +3 -0
  45. package/lib/public/modules/mcp-connection-view.js +1 -1
  46. package/lib/public/modules/permission-control.js +5 -4
  47. package/lib/public/modules/scheduler.js +2 -0
  48. package/lib/public/modules/session-create-form.js +10 -10
  49. package/lib/public/modules/settings-defaults.js +27 -28
  50. package/lib/public/modules/tools.js +2 -1
  51. package/lib/public/modules/tui-grab.js +1 -2
  52. package/lib/public/modules/vendor-login-browser.js +5 -3
  53. package/lib/public/modules/vendor-login.js +2 -2
  54. package/lib/public/modules/vendor-priority.js +15 -1
  55. package/lib/public/muse-avatar.svg +4 -0
  56. package/lib/safe-bash-commands.js +3 -45
  57. package/lib/sdk-bridge.js +127 -395
  58. package/lib/sdk-foreground-admission.js +16 -0
  59. package/lib/sdk-mcp-descriptors.js +2 -37
  60. package/lib/sdk-message-processor.js +50 -17
  61. package/lib/sdk-quota-snapshot.js +1 -1
  62. package/lib/sdk-response-recovery.js +1 -155
  63. package/lib/sdk-worker.js +2 -677
  64. package/lib/server.js +1 -1
  65. package/lib/session-fork-history.js +21 -0
  66. package/lib/session-hygiene.js +3 -35
  67. package/lib/session-permission-mode.js +4 -3
  68. package/lib/session-skill-scope.js +11 -0
  69. package/lib/sessions.js +17 -89
  70. package/lib/tool-llm.js +1 -1
  71. package/lib/tui-transcript-index.js +1 -132
  72. package/lib/vendor-login-browser.js +1 -11
  73. package/lib/yoke/acp-agent-profiles.js +5 -3
  74. package/lib/yoke/adapters/antigravity.js +3 -14
  75. package/lib/yoke/adapters/claude-query-contract.js +9 -0
  76. package/lib/yoke/adapters/claude.js +7 -42
  77. package/lib/yoke/adapters/codex-query-contract.js +24 -0
  78. package/lib/yoke/adapters/codex.js +1 -0
  79. package/lib/yoke/adapters/kiro.js +3 -1
  80. package/lib/yoke/adapters/muse-query-contract.js +7 -0
  81. package/lib/yoke/adapters/muse.js +122 -0
  82. package/lib/yoke/auth-events.js +17 -0
  83. package/lib/yoke/claude-hook-installer.js +267 -0
  84. package/lib/yoke/claude-jsonl-watcher.js +204 -0
  85. package/lib/yoke/claude-maintenance.js +55 -0
  86. package/lib/yoke/claude-permission-patterns.js +53 -0
  87. package/lib/yoke/claude-response-recovery.js +155 -0
  88. package/lib/yoke/claude-transcript-hygiene.js +34 -0
  89. package/lib/yoke/clay-skill-install.js +33 -0
  90. package/lib/yoke/cli-sessions.js +300 -0
  91. package/lib/yoke/codex-app-server.js +7 -12
  92. package/lib/yoke/configuration.js +13 -0
  93. package/lib/yoke/discovery.js +70 -0
  94. package/lib/yoke/errors.js +8 -0
  95. package/lib/yoke/host-environment.js +7 -0
  96. package/lib/yoke/index.js +9 -51
  97. package/lib/yoke/interface.js +116 -0
  98. package/lib/yoke/kiro-acp-server.js +5 -5
  99. package/lib/yoke/legacy-sessions.js +89 -0
  100. package/lib/yoke/login-protocol.js +25 -0
  101. package/lib/yoke/maintenance.js +12 -0
  102. package/lib/yoke/mcp-proxy.js +32 -0
  103. package/lib/yoke/mcp-source-adapters.js +91 -0
  104. package/lib/yoke/mcp-source-context.js +42 -0
  105. package/lib/yoke/mcp-source-discovery.js +169 -0
  106. package/lib/yoke/mcp-source-plugins.js +68 -0
  107. package/lib/yoke/mcp-source-restrictions.js +47 -0
  108. package/lib/yoke/mcp-tool-policy-normalize.js +28 -0
  109. package/lib/yoke/model-preferences.js +6 -0
  110. package/lib/yoke/muse-artifacts.js +36 -0
  111. package/lib/yoke/muse-controls.js +50 -0
  112. package/lib/yoke/muse-input.js +64 -0
  113. package/lib/yoke/muse-items.js +157 -0
  114. package/lib/yoke/muse-policy.js +52 -0
  115. package/lib/yoke/muse-query.js +428 -0
  116. package/lib/yoke/muse-runtime.js +211 -0
  117. package/lib/yoke/muse-services.js +79 -0
  118. package/lib/yoke/muse-skills.js +79 -0
  119. package/lib/yoke/muse-turns.js +71 -0
  120. package/lib/yoke/options/acp.js +2 -0
  121. package/lib/yoke/options/antigravity.js +2 -0
  122. package/lib/yoke/options/claude.js +21 -0
  123. package/lib/yoke/options/codex-defaults.js +29 -0
  124. package/lib/yoke/options/codex-settings.js +21 -0
  125. package/lib/yoke/options/codex.js +6 -0
  126. package/lib/yoke/options/kiro-defaults.js +22 -0
  127. package/lib/yoke/options/kiro.js +5 -0
  128. package/lib/yoke/options/muse.js +5 -0
  129. package/lib/yoke/provider-contract.js +5 -0
  130. package/lib/yoke/providers/antigravity-executable.js +8 -0
  131. package/lib/yoke/providers/claude-executable.js +40 -0
  132. package/lib/yoke/providers/claude-model-descriptions.js +14 -0
  133. package/lib/yoke/providers/claude-process.js +97 -0
  134. package/lib/yoke/providers/claude-provision.js +75 -0
  135. package/lib/yoke/providers/codex-errors.js +8 -0
  136. package/lib/yoke/providers/muse-executable.js +17 -0
  137. package/lib/yoke/provisioning.js +6 -0
  138. package/lib/yoke/query-options.js +10 -0
  139. package/lib/yoke/response-recovery.js +41 -0
  140. package/lib/yoke/sdk-mcp-descriptors.js +37 -0
  141. package/lib/yoke/sdk-server-factory.js +7 -0
  142. package/lib/yoke/session-history.js +8 -0
  143. package/lib/yoke/session-tool-transport.js +31 -13
  144. package/lib/yoke/settings.js +23 -0
  145. package/lib/yoke/source-locations.js +4 -0
  146. package/lib/yoke/title-query.js +18 -7
  147. package/lib/yoke/tui-transcript-index.js +132 -0
  148. package/lib/yoke/usage.js +48 -0
  149. package/lib/yoke/user-input.js +13 -0
  150. package/lib/yoke/vendor-registry.js +81 -1
  151. package/package.json +3 -2
@@ -0,0 +1,211 @@
1
+ var queryAbort = require("./query-abort");
2
+
3
+ var initializeTimeoutMs = require("./interface").INITIALIZE_TIMEOUT_MS;
4
+
5
+ function isAuthError(error) {
6
+ var kind = error && (error.kind || error.data && error.data.kind);
7
+ return kind === "authRequired" || /authentication|not authenticated|sign[ -]?in|log[ -]?in|credential|unauthorized|forbidden|api.?key|401/i.test(String(error && error.message || error || ""));
8
+ }
9
+
10
+ function closeResource(resource) {
11
+ if (!resource || typeof resource.close !== "function") return Promise.resolve();
12
+ return Promise.resolve().then(function() {
13
+ return resource.close();
14
+ });
15
+ }
16
+ // Own the process before initialize starts, including callers still opening a session.
17
+
18
+ function createRuntime(adapter, sdk, options) {
19
+ var scope = queryAbort.createAbortScope();
20
+ var handshake = sdk.spawnMspConnection(Object.assign({}, options, {
21
+ shutdownTimeoutMs: adapter.shutdownTimeoutMs
22
+ }));
23
+ var closing = null;
24
+ var runtime = {
25
+ handshake: handshake,
26
+ spawned: null,
27
+ connection: null,
28
+ session: null,
29
+ held: [],
30
+ opening: true,
31
+ dead: false,
32
+ wait: scope.wait,
33
+ check: scope.check,
34
+ waitRequest: async function(promise, timeoutMs) {
35
+ var timer;
36
+ try {
37
+ return await scope.wait(Promise.race([ promise, new Promise(function(resolve, reject) {
38
+ timer = setTimeout(function() {
39
+ reject(new Error("Muse Code request timed out"));
40
+ }, timeoutMs || adapter.requestTimeoutMs);
41
+ }) ]));
42
+ } finally {
43
+ clearTimeout(timer);
44
+ }
45
+ },
46
+ fail: function(error) {},
47
+ onFrame: function(frame) {},
48
+ apply: function(frame) {
49
+ if (!runtime.session || scope.stopped()) return;
50
+ var named = frame.params && frame.params.sessionId;
51
+ if (named !== runtime.session.sessionId) return;
52
+ if (frame.method === "view/gap") {
53
+ runtime.fail(new Error("Muse view stream has a gap; Stop retired this attempt. Resume explicitly to reconcile the session."));
54
+ return;
55
+ }
56
+ try {
57
+ var applied = runtime.session.apply(frame);
58
+ if (applied.fold.kind !== "item" || applied.fold.outcome.kind !== "ignoredStaleRevision") runtime.onFrame(frame);
59
+ } catch (error) {
60
+ runtime.fail(error);
61
+ }
62
+ },
63
+ close: function() {
64
+ if (closing) return closing;
65
+ scope.stop();
66
+ if (runtime.session) runtime.session.hostExited({
67
+ kind: "transportEof"
68
+ });
69
+ closing = closeResource(handshake).finally(function() {
70
+ adapter.clients.delete(runtime);
71
+ });
72
+ return closing;
73
+ },
74
+ initialize: async function() {
75
+ try {
76
+ runtime.spawned = await runtime.waitRequest(handshake.initialize({
77
+ clientInfo: {
78
+ name: "clay",
79
+ title: "Clay",
80
+ version: "1.0.0"
81
+ },
82
+ capabilities: {
83
+ requestedCapabilities: [ "sessionMcp" ],
84
+ userInputDialogs: options.userInputDialogs === true
85
+ }
86
+ }), initializeTimeoutMs);
87
+ runtime.connection = runtime.spawned.connection;
88
+ runtime.connection.onProtocolError(function(error) {
89
+ runtime.fail(error);
90
+ });
91
+ runtime.connection.closed.then(function() {
92
+ if (scope.stopped()) return;
93
+ runtime.dead = true;
94
+ if (runtime.session) runtime.session.hostExited({
95
+ kind: "transportEof"
96
+ });
97
+ runtime.fail(new Error("Muse Code transport closed unexpectedly"));
98
+ });
99
+ return runtime.spawned;
100
+ } catch (error) {
101
+ await runtime.close();
102
+ throw error;
103
+ }
104
+ }
105
+ };
106
+ function route(frame) {
107
+ if (scope.stopped()) return;
108
+ if (frame.method === "usage/changed") { runtime.onFrame(frame); return; }
109
+ if (runtime.opening) runtime.held.push(frame); else runtime.apply(frame);
110
+ }
111
+ handshake.onServerRequest(async function(request) {
112
+ if (request.method === "approval/request") {
113
+ route({
114
+ method: "approval/requested",
115
+ params: request.params
116
+ });
117
+ return {};
118
+ }
119
+ if (request.method === "userInput/request" && typeof runtime.onUserInput === "function") {
120
+ route({ method: "userInput/requested", params: request.params });
121
+ return {};
122
+ }
123
+ var error = new Error("Muse host requested an unsupported client dialog: " + request.method);
124
+ runtime.fail(error);
125
+ throw error;
126
+ });
127
+ adapter.clients.add(runtime);
128
+ handshake.onNotification(route);
129
+ if (typeof handshake.onProtocolError === "function") handshake.onProtocolError(function(error) {
130
+ runtime.fail(error);
131
+ });
132
+ if (handshake.child && handshake.child.exit) handshake.child.exit.then(function(exit) {
133
+ runtime.dead = true;
134
+ if (runtime.session) runtime.session.hostExited(exit);
135
+ if (!scope.stopped()) runtime.fail(new Error("Muse Code host exited: " + exit.kind));
136
+ }, function(error) {
137
+ if (!scope.stopped()) runtime.fail(error);
138
+ });
139
+ return runtime;
140
+ }
141
+
142
+ function normalizeCatalog(result) {
143
+ return (result.models || []).map(function(model) {
144
+ return {
145
+ value: model.modelId,
146
+ displayName: model.displayLabel || model.modelId,
147
+ description: model.description || "",
148
+ supportedEffortLevels: Array.isArray(model.variants) ? model.variants.filter(function(tier) {
149
+ return ["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"].includes(tier);
150
+ }) : [],
151
+ providerId: model.providerId || result.providerId,
152
+ profileId: model.profileId == null ? result.profileId : model.profileId,
153
+ defaultReasoningEffort: model.defaultReasoningEffort,
154
+ isDefault: model.isDefault === true,
155
+ effortUnknown: !Array.isArray(model.variants),
156
+ catalogSource: result.source
157
+ };
158
+ });
159
+ }
160
+
161
+ function modelSelection(catalog, model) {
162
+ for (var i = 0; i < catalog.length; i++) {
163
+ if (catalog[i].value !== model) continue;
164
+ var selection = {
165
+ modelId: model,
166
+ displayLabel: catalog[i].displayName
167
+ };
168
+ if (catalog[i].providerId) selection.providerId = catalog[i].providerId;
169
+ if (catalog[i].profileId != null) selection.profileId = catalog[i].profileId;
170
+ return selection;
171
+ }
172
+ throw new Error("Muse model is not in the live model catalog: " + model);
173
+ }
174
+ // SDK 1.4.7 retains opening metadata but does not ingest its history. Seed once,
175
+ // before the buffered live suffix; pending pointers await the host's full reissue.
176
+
177
+ function seedHistory(session, opening, onFrame) {
178
+ if (opening.verb !== "session/resume") return;
179
+ var history = opening.result.history || {};
180
+ var snapshot = history.snapshot;
181
+ if (snapshot && snapshot.schemaVersion !== 1) throw new Error("Unsupported Muse snapshot schema version");
182
+ var items = history.items || snapshot && snapshot.state.items || [];
183
+ for (var i = 0; i < items.length; i++) {
184
+ var frame = {
185
+ method: "item/updated",
186
+ params: {
187
+ sessionId: session.sessionId,
188
+ item: items[i],
189
+ viewCursor: opening.result.viewCursor
190
+ }
191
+ };
192
+ session.apply(frame);
193
+ if (onFrame) onFrame(frame);
194
+ }
195
+ var active = snapshot && snapshot.state.activeTurn;
196
+ if (active) session.apply({
197
+ method: "turn/started",
198
+ params: Object.assign({}, active, {
199
+ sessionId: session.sessionId,
200
+ viewCursor: snapshot.viewCursor
201
+ })
202
+ });
203
+ }
204
+
205
+ module.exports = {
206
+ isAuthError: isAuthError,
207
+ createRuntime: createRuntime,
208
+ normalizeCatalog: normalizeCatalog,
209
+ modelSelection: modelSelection,
210
+ seedHistory: seedHistory
211
+ };
@@ -0,0 +1,79 @@
1
+ // Typed MSP operations; no arbitrary command forwarding or automatic effect replay.
2
+ var runtimeTools = require("./muse-runtime");
3
+ function attach(adapter) {
4
+ async function withRuntime(options, operation) {
5
+ options = options || {};
6
+ if (options.linuxUser || options.osUsers) throw new Error("Muse Code does not support OS-owner isolation");
7
+ if (adapter.shuttingDown) throw new Error("Muse Code adapter is shutting down");
8
+ if (!adapter.binaryPath) await adapter.init(options);
9
+ var sdk = await adapter.loadSdk();
10
+ if (adapter.shuttingDown) throw new Error("Muse Code adapter is shutting down");
11
+ var runtime = runtimeTools.createRuntime(adapter, sdk, {
12
+ command: adapter.binaryPath, args: ["serve"], cwd: options.dir || adapter.cwd,
13
+ env: Object.assign({}, process.env),
14
+ });
15
+ runtime.fail = function() { runtime.close().catch(function(error) { adapter.lastCloseError = error; }); };
16
+ try {
17
+ var spawned = await runtime.initialize();
18
+ return await operation(runtime, spawned);
19
+ } finally { await runtime.close(); }
20
+ }
21
+ adapter.listSessionPage = function(options) {
22
+ options = options || {};
23
+ return withRuntime(options, async function(runtime, spawned) {
24
+ var params = { workspaceRoot: options.dir || adapter.cwd, limit: options.limit || 50 };
25
+ if (options.cursor != null) params.cursor = options.cursor;
26
+ var page = await runtime.waitRequest(spawned.connection.request("session/list", params));
27
+ if (!Array.isArray(page.sessions)) throw new Error("Invalid Muse session list");
28
+ return page;
29
+ });
30
+ };
31
+ adapter.listSessions = async function(options) {
32
+ var page = await adapter.listSessionPage(options);
33
+ page.sessions.nextCursor = page.nextCursor;
34
+ return page.sessions;
35
+ };
36
+ adapter.readSession = function(sessionId, options) {
37
+ if (typeof sessionId !== "string" || !sessionId) return Promise.reject(new Error("Muse read requires an exact session id"));
38
+ return withRuntime(options, function(runtime, spawned) {
39
+ return runtime.waitRequest(spawned.connection.request("session/read", { sessionId: sessionId, excludeItems: !(options && options.includeItems) }));
40
+ });
41
+ };
42
+ adapter.renameSession = function(sessionId, name, options) {
43
+ if (typeof sessionId !== "string" || !sessionId || typeof name !== "string" || !name.trim()) return Promise.reject(new Error("Muse rename requires an exact session and name"));
44
+ return withRuntime(options, async function(runtime, spawned) {
45
+ if (sdkDurability(spawned) !== "durable") throw new Error("Muse rename is unsupported by an ephemeral host");
46
+ await runtime.waitRequest(spawned.connection.command("session/resume", { sessionId: sessionId, excludeItems: true }));
47
+ return runtime.waitRequest(spawned.connection.command("session/rename", { sessionId: sessionId, name: name }));
48
+ });
49
+ };
50
+ adapter.forkSession = function(sessionId, options) {
51
+ options = options || {};
52
+ return withRuntime(options, async function(runtime, spawned) {
53
+ var params = { sessionId: sessionId, excludeItems: true };
54
+ if (options.upToMessageId) params.cutPoint = { lastTurnId: options.upToMessageId };
55
+ var result = await runtime.waitRequest(spawned.connection.command("session/fork", params));
56
+ if (!result.session || !result.session.sessionId) throw new Error("Muse fork returned no session id; inspect before retrying");
57
+ return { sessionId: result.session.sessionId, useLocalHistory: true };
58
+ });
59
+ };
60
+ adapter.readUsage = function(options) {
61
+ return withRuntime(options, async function(runtime, spawned) {
62
+ var result = await runtime.waitRequest(spawned.connection.request("usage/read", {}));
63
+ return result.usage || null;
64
+ });
65
+ };
66
+ }
67
+ function sdkDurability(spawned) { return spawned.initializeResult.sessionDurability; }
68
+ function quotaEvent(usage) {
69
+ if (!usage || !Number.isFinite(usage.observedAtMs)) return null;
70
+ var windows = [];
71
+ ["window", "weekly"].forEach(function(key) {
72
+ var value = usage[key];
73
+ if (!value || !Number.isFinite(value.usedPercent) || value.usedPercent < 0 || !Number.isFinite(value.resetsAtMs)) return;
74
+ windows.push({ key: key, usedPercent: value.usedPercent, resetsAt: value.resetsAtMs / 1000,
75
+ windowDurationMins: key === "weekly" ? 10080 : value.windowDurationMins || null });
76
+ });
77
+ return { yokeType: "rate_limit", rateLimitInfo: { source: "account_snapshot", limitId: "muse", observedAtMs: usage.observedAtMs, windows: windows } };
78
+ }
79
+ module.exports = { attach: attach, quotaEvent: quotaEvent };
@@ -0,0 +1,79 @@
1
+ var discovery = require("./skill-discovery");
2
+ function create(queryOpts, getRuntime, push, assertLive) {
3
+ var options = queryOpts.skillOptions;
4
+ var delivered = false;
5
+ var lastCatalog = "";
6
+ var lastIndex = "";
7
+ function available() {
8
+ assertLive();
9
+ var readOnly = queryOpts.adapterOptions && queryOpts.adapterOptions.MUSE && queryOpts.adapterOptions.MUSE.readOnly;
10
+ var allowed = !queryOpts.skipSkills && !readOnly && options && !options.disable && typeof options.isAvailable === "function" && options.isAvailable() === true;
11
+ if (!allowed && delivered) throw new Error("The skill query scope is no longer available");
12
+ return !!allowed;
13
+ }
14
+ function check() {
15
+ if (!available()) throw new Error("Skills require an authorized Clay query scope");
16
+ }
17
+ async function listNative() {
18
+ check();
19
+ var runtime = getRuntime();
20
+ if (!runtime || !runtime.session) throw new Error("Muse skills require an opened session");
21
+ var result = await runtime.waitRequest(runtime.connection.request("skill/list", { sessionId: runtime.session.sessionId }));
22
+ check();
23
+ if (!result || !Array.isArray(result.skills)) throw new Error("Muse returned an invalid native skill catalog");
24
+ return { skills: result.skills.filter(function(skill) {
25
+ // Clay-only names are delivered from private roots, never native installs.
26
+ return skill && typeof skill.selector === "string" && !/(?:^|:)clay-/.test(skill.selector);
27
+ }) };
28
+ }
29
+ function scopedOptions() {
30
+ var fs = require("fs");
31
+ return Object.assign({}, options, {
32
+ readDir: function(dir) { check(); return options.readDir ? options.readDir(dir) : fs.readdirSync(dir, { withFileTypes: true }); },
33
+ readFile: function(file) { check(); var content = options.readFile ? options.readFile(file) : fs.readFileSync(file, "utf8"); check(); return content; },
34
+ realpath: function(file) { check(); return options.realpath ? options.realpath(file) : fs.realpathSync(file); },
35
+ });
36
+ }
37
+ async function prepare(text, selected) {
38
+ if (!available()) {
39
+ if (selected) throw new Error("Skills require an authorized Clay query scope");
40
+ return { text: text, skill: null, scoped: false };
41
+ }
42
+ var native = await listNative();
43
+ var readOpts = scopedOptions();
44
+ var shared = discovery.discoverSkills(queryOpts.cwd, readOpts).filter(function(skill) {
45
+ return !/^clay-/.test(skill.name) || /^clay-/.test(skill.source);
46
+ });
47
+ check();
48
+ var slash = typeof text === "string" && /^\/([^\s/]+)(?:[ \t]([\s\S]*))?$/.exec(text);
49
+ var explicit = selected;
50
+ var referenceText = text;
51
+ if (slash) {
52
+ if (native.skills.some(function(skill) { return skill.selector === slash[1]; })) {
53
+ explicit = { selector: slash[1], arguments: slash[2] || "" };
54
+ text = "";
55
+ } else if (shared.some(function(skill) { return skill.name === slash[1]; })) {
56
+ referenceText = "$" + slash[1] + (slash[2] ? " " + slash[2] : "");
57
+ text = referenceText;
58
+ } else throw new Error("Skill is not in the current Muse or shared catalog: " + slash[1]);
59
+ }
60
+ if (explicit && !native.skills.some(function(skill) { return skill.selector === explicit.selector; })) throw new Error("Muse skill is not in the live session catalog");
61
+ var index = discovery.buildSkillIndex(shared);
62
+ var content = discovery.readReferencedSkills(referenceText, shared, 32768, readOpts);
63
+ if (discovery.findSkillReferences(referenceText, shared).length && !content) throw new Error("Shared skill instructions are unavailable");
64
+ check();
65
+ var commands = native.skills.map(function(skill) { return skill.selector; });
66
+ var names = shared.map(function(skill) { return skill.name; });
67
+ var catalog = JSON.stringify([commands, names]);
68
+ if (catalog !== lastCatalog) {
69
+ push({ yokeType: "commands_changed", commandNames: commands, skills: names });
70
+ lastCatalog = catalog;
71
+ }
72
+ var guidance = index && index !== lastIndex ? index + "\nNative /selector commands invoke Muse skills; $name references load shared instructions. If names collide, /name is native and $name is shared." : "";
73
+ lastIndex = index;
74
+ delivered = true;
75
+ return { text: [text, guidance, content].filter(Boolean).join("\n\n"), skill: explicit || null, scoped: true };
76
+ }
77
+ return { prepare: prepare, listNative: listNative, check: check };
78
+ }
79
+ module.exports = { create: create };
@@ -0,0 +1,71 @@
1
+ // Foreground completion is a non-terminal SDK fact. Continue following every
2
+ // turn to its real outcome while releasing only the next submission boundary.
3
+ function create(options) {
4
+ var state = options.state;
5
+ var turns = new Map();
6
+ function started(entry) {
7
+ if (entry.started || !entry.turn.observedStart) return;
8
+ entry.started = true;
9
+ options.push({ yokeType: 'turn_start', uuid: entry.turn.turnId, messageType: 'user', turnId: entry.turn.turnId });
10
+ options.push({ yokeType: 'turn_activity', phase: 'running', turnId: entry.turn.turnId });
11
+ }
12
+ function foreground(entry, params) {
13
+ if (entry.yielded || !params || !Array.isArray(params.blockingAgents) || !params.blockingAgents.length) return;
14
+ entry.yielded = true;
15
+ entry.release({ kind: 'foreground' });
16
+ }
17
+ function onFrame(frame) {
18
+ if (frame.method !== 'turn/foregroundCompleted' && frame.method !== 'turn/started') return;
19
+ var entry = turns.get(frame.params.turnId);
20
+ if (entry && frame.method === 'turn/started') { started(entry); return; }
21
+ var folded = state.session.fold.turn(frame.params.turnId);
22
+ if (entry && folded && folded.state === 'running') foreground(entry, folded.foregroundCompleted);
23
+ }
24
+ function follow(turn, report, sequence) {
25
+ var entry = { turn: turn, yielded: false };
26
+ var boundary = new Promise(function (resolve) { entry.release = resolve; });
27
+ turns.set(turn.turnId, entry);
28
+ state.liveTurnIds.add(turn.turnId);
29
+ started(entry);
30
+ var admission = state.session.pending.list().find(function (pending) { return pending.ack && pending.ack.turnId === turn.turnId; });
31
+ var existing = state.session.fold.turn(turn.turnId);
32
+ if (!entry.started && (!existing || existing.state === 'running')) options.push({
33
+ yokeType: 'turn_activity', phase: 'waiting', turnId: turn.turnId,
34
+ disposition: admission && admission.ack.disposition
35
+ });
36
+ options.ready();
37
+ var terminal = (async function () {
38
+ try {
39
+ for await (var item of turn.items()) {
40
+ if (state.stopped) return { kind: 'stopped' };
41
+ if (!options.renderer.hasItem(item.itemId)) options.renderer.emitItem(item);
42
+ await options.emitArtifact(item);
43
+ }
44
+ var outcome = await options.runtime().wait(turn.completed);
45
+ if (state.stopped) return { kind: 'stopped' };
46
+ options.renderer.closeBlocks(turn.turnId);
47
+ var event = options.outcomeEvent(outcome);
48
+ // A retired foreground turn cannot settle a newer turn's reviews or
49
+ // user-work completion callbacks when its reminder checks finish late.
50
+ if (event.yokeType === 'result' && entry.yielded && sequence < state.messageSequence) event.backgroundOnly = true;
51
+ if (report || event.yokeType !== 'result') options.push(event);
52
+ if (event.yokeType !== 'result') await options.close();
53
+ return { kind: 'terminal', outcome: outcome, event: event };
54
+ } catch (error) {
55
+ options.fail(error);
56
+ return { kind: 'failed' };
57
+ } finally {
58
+ turns.delete(turn.turnId);
59
+ state.liveTurnIds.delete(turn.turnId);
60
+ if (!state.stopped && !state.active && state.inputEnded && !turns.size) options.close().catch(options.fail);
61
+ }
62
+ })();
63
+ // Session.apply can receive this event before turn/start's acknowledgement.
64
+ var folded = state.session.fold.turn(turn.turnId);
65
+ if (folded && folded.state === 'running') foreground(entry, folded.foregroundCompleted);
66
+ return Promise.race([terminal, boundary]);
67
+ }
68
+ return { follow: follow, onFrame: onFrame, pending: function () { return turns.size > 0; },
69
+ background: function () { return Array.from(turns.values()).some(function (entry) { return entry.yielded; }); } };
70
+ }
71
+ module.exports = { create: create };
@@ -0,0 +1,2 @@
1
+ function map(intent) { return { ACP: { mcpServers: intent.sessionBridge } }; }
2
+ module.exports = { map: map };
@@ -0,0 +1,2 @@
1
+ function map(intent) { return { ANTIGRAVITY: { dangerouslySkipPermissions: !intent.readOnly && (intent.nativeBypass || intent.permissionMode === "bypassPermissions") } }; }
2
+ module.exports = { map: map };
@@ -0,0 +1,21 @@
1
+ function map(intent) {
2
+ var options = { settingSources: intent.instructionSources || ["user", "project", "local"], includePartialMessages: true,
3
+ enableFileCheckpointing: true, extraArgs: { "replay-user-messages": null }, promptSuggestions: true, agentProgressSummaries: true };
4
+ if (intent.betas && intent.betas.length) options.betas = intent.betas;
5
+ var thinking = intent.thinking || {};
6
+ if (thinking.mode === "disabled") options.thinking = { type: "disabled" };
7
+ else if (thinking.mode === "budget" && thinking.budget) options.thinking = { type: "enabled", budgetTokens: thinking.budget };
8
+ else options.thinking = { type: "adaptive", display: "summarized" };
9
+ if (intent.disableHooks !== undefined) options.settings = { disableAllHooks: intent.disableHooks };
10
+ options.permissionMode = intent.nativePermissionMode || "default";
11
+ if (intent.nativeBypass && !intent.readOnly) { options.permissionMode = "bypassPermissions"; options.allowDangerouslySkipPermissions = true; }
12
+ if (intent.readOnly) { options.permissionMode = "default"; options.allowDangerouslySkipPermissions = false; }
13
+ if (intent.resumeAt) options.resumeSessionAt = intent.resumeAt;
14
+ if (intent.isolation && intent.isolation.user) {
15
+ var isolation = intent.isolation;
16
+ Object.assign(options, { linuxUser: isolation.user, originalHome: isolation.home, singleTurn: intent.singleTurn,
17
+ projectPath: isolation.projectPath, _perfT0: intent.startedAt, _workerState: isolation.workerState });
18
+ }
19
+ return { CLAUDE: options };
20
+ }
21
+ module.exports = { map: map };
@@ -0,0 +1,29 @@
1
+ var CODEX_DEFAULTS = {
2
+ approval: "on-request",
3
+ sandbox: "danger-full-access",
4
+ webSearch: "live",
5
+ };
6
+
7
+ var CODEX_APPROVAL_POLICIES = ["untrusted", "on-request", "granular", "never"];
8
+
9
+ function normalizeCodexApproval(value) {
10
+ if (value === "on-failure") return CODEX_DEFAULTS.approval;
11
+ if (CODEX_APPROVAL_POLICIES.indexOf(value) === -1) return CODEX_DEFAULTS.approval;
12
+ return value;
13
+ }
14
+
15
+ function getCodexConfig(sm) {
16
+ sm = sm || {};
17
+ return {
18
+ approval: normalizeCodexApproval(sm && sm.codexApproval),
19
+ sandbox: (sm && sm.codexSandbox) === undefined ? CODEX_DEFAULTS.sandbox : ["read-only", "workspace-write", "danger-full-access"].indexOf(sm.codexSandbox) >= 0 ? sm.codexSandbox : "read-only",
20
+ webSearch: (sm && sm.codexWebSearch) === undefined ? CODEX_DEFAULTS.webSearch : ["disabled", "cached", "live"].indexOf(sm.codexWebSearch) >= 0 ? sm.codexWebSearch : "disabled",
21
+ };
22
+ }
23
+
24
+ module.exports = {
25
+ CODEX_DEFAULTS: CODEX_DEFAULTS,
26
+ CODEX_APPROVAL_POLICIES: CODEX_APPROVAL_POLICIES,
27
+ normalizeCodexApproval: normalizeCodexApproval,
28
+ getCodexConfig: getCodexConfig,
29
+ };
@@ -0,0 +1,21 @@
1
+ // Provider setting validation and legacy wire projection. The host owns
2
+ // permission checks, the actual settings store and publication.
3
+ var config = require('./codex-defaults');
4
+ var actions = {
5
+ set_codex_approval: { key: 'codexApproval', input: 'approval', choices: config.CODEX_APPROVAL_POLICIES, fallback: config.CODEX_DEFAULTS.approval },
6
+ set_codex_sandbox: { key: 'codexSandbox', input: 'sandbox', choices: ['read-only', 'workspace-write', 'danger-full-access'], fallback: config.CODEX_DEFAULTS.sandbox },
7
+ set_codex_websearch: { key: 'codexWebSearch', input: 'webSearch', choices: ['disabled', 'cached', 'live'], fallback: config.CODEX_DEFAULTS.webSearch },
8
+ };
9
+ function defaults() { return { codexApproval: config.CODEX_DEFAULTS.approval, codexSandbox: config.CODEX_DEFAULTS.sandbox, codexWebSearch: config.CODEX_DEFAULTS.webSearch }; }
10
+ function messages(settings) { return [Object.assign({ type: 'codex_config' }, config.getCodexConfig(settings))]; }
11
+ function change(message, settings) {
12
+ var action = actions[message.type];
13
+ if (!action) return null;
14
+ var value = message[action.input];
15
+ if (value == null || value === '') value = action.fallback;
16
+ if (action.key === 'codexApproval' && value === 'on-failure') value = action.fallback;
17
+ if (action.choices.indexOf(value) < 0) throw new Error('Unsupported provider setting value.');
18
+ var patch = {}; patch[action.key] = value;
19
+ return { patch: patch, messages: messages(Object.assign({}, settings, patch)) };
20
+ }
21
+ module.exports = { defaults: defaults, messages: messages, change: change };
@@ -0,0 +1,6 @@
1
+ function map(intent) {
2
+ var config = require("./codex-defaults").getCodexConfig(intent.settings);
3
+ return { CODEX: { approvalPolicy: "never", sandboxMode: intent.readOnly ? "read-only" : config.sandbox,
4
+ webSearchMode: intent.readOnly ? "disabled" : config.webSearch } };
5
+ }
6
+ module.exports = { map: map };
@@ -0,0 +1,22 @@
1
+ // Kiro-specific default values. Single source of truth — do not duplicate
2
+ // elsewhere. Consumed by the server-side vendor plumbing and sent to clients
3
+ // via the config state so the UI renders the right controls.
4
+
5
+ var KIRO_DEFAULTS = {
6
+ // Kiro CLI 2.18.1 exposes the next-generation agent as the v3 engine. Its
7
+ // general-purpose mode id is "vibe" (displayed as "Default").
8
+ engine: "v3",
9
+ mode: "vibe",
10
+ };
11
+
12
+ function getKiroConfig(sm) {
13
+ return {
14
+ engine: (sm && sm.kiroEngine) || KIRO_DEFAULTS.engine,
15
+ mode: (sm && sm.kiroMode) || KIRO_DEFAULTS.mode,
16
+ };
17
+ }
18
+
19
+ module.exports = {
20
+ KIRO_DEFAULTS: KIRO_DEFAULTS,
21
+ getKiroConfig: getKiroConfig,
22
+ };
@@ -0,0 +1,5 @@
1
+ function map(intent) {
2
+ var config = require("./kiro-defaults").getKiroConfig(intent.settings);
3
+ return { KIRO: { engine: config.engine, mode: config.mode, mcpServers: intent.sessionBridge } };
4
+ }
5
+ module.exports = { map: map };
@@ -0,0 +1,5 @@
1
+ function map(intent) {
2
+ if (intent.readOnly) throw new Error("Muse SDK 1.4.7 cannot enforce the curator read-only sandbox contract");
3
+ return { MUSE: { mcpServers: intent.readOnly ? [] : intent.sessionBridge || [], readOnly: intent.readOnly === true } };
4
+ }
5
+ module.exports = { map: map };
@@ -0,0 +1,5 @@
1
+ function resolve(provider) {
2
+ if (provider && typeof provider === "object" && provider.providerContract) return provider.providerContract;
3
+ return require("./vendor-registry").getVendorInfo(typeof provider === "string" ? provider : provider && provider.vendor) || {};
4
+ }
5
+ module.exports = { resolve: resolve };
@@ -0,0 +1,8 @@
1
+ // One authoritative resolver for both installation discovery and adapter init.
2
+ var resolvePath = require("../discovery").pathResolver("agy", "ANTIGRAVITY_CLI_PATH");
3
+ function resolve(options) {
4
+ options = options || {};
5
+ if (options.user) return null;
6
+ return resolvePath(options);
7
+ }
8
+ module.exports = { resolve: resolve };
@@ -0,0 +1,40 @@
1
+ var fs = require("fs");
2
+ function resolveClaudeBinaryPath() {
3
+ // 1. Explicit env var override
4
+ var discovery = require("../discovery");
5
+ var explicit = discovery.explicitEntry(process.env, "CLAUDE_CODE_PATH", true);
6
+ if (explicit !== undefined) return explicit;
7
+
8
+ // 2. `which claude` in the daemon's PATH
9
+ try {
10
+ var result = require("child_process").execSync("which claude", { encoding: "utf8", timeout: 5000 }).trim();
11
+ if (discovery.validEntry(result, false)) return result;
12
+ } catch (e) {}
13
+
14
+ // 3. Common per-user and system locations (best-effort fallback for the daemon user)
15
+ var home = process.env.HOME || "";
16
+ var candidates = [];
17
+ if (home) {
18
+ candidates.push(home + "/.npm-global/bin/claude");
19
+ candidates.push(home + "/.local/bin/claude");
20
+ candidates.push(home + "/.volta/bin/claude");
21
+ candidates.push(home + "/.bun/bin/claude");
22
+ candidates.push(home + "/bin/claude");
23
+ }
24
+ candidates.push("/usr/local/bin/claude");
25
+ candidates.push("/usr/bin/claude");
26
+ candidates.push("/opt/homebrew/bin/claude");
27
+ for (var i = 0; i < candidates.length; i++) {
28
+ try { if (discovery.validEntry(candidates[i], false)) return candidates[i]; } catch (e) {}
29
+ }
30
+
31
+ // 4. Bundled CLI entry from the SDK's peer
32
+ try {
33
+ var resolved = require.resolve("@anthropic-ai/claude-code/cli.js");
34
+ if (discovery.validEntry(resolved, true)) return resolved;
35
+ } catch (e) {}
36
+
37
+ return null;
38
+ }
39
+
40
+ module.exports = { resolve: resolveClaudeBinaryPath };
@@ -0,0 +1,14 @@
1
+ // Preserve existing model descriptions and beta availability at the provider boundary.
2
+ var DESCRIPTIONS = { default: "Automatically selects the best model for the task.", sonnet: "Fast and capable. Great balance of speed and intelligence.", haiku: "Fastest model. Best for quick tasks and simple questions.", opus: "Most powerful model. Best for complex reasoning and analysis." };
3
+ function describe(entry) {
4
+ var model = typeof entry === "string" ? { value: entry, displayName: entry } : Object.assign({}, entry);
5
+ var name = String(model.value || "").toLowerCase();
6
+ if (model.supportsBetaContext === undefined) model.supportsBetaContext = name.indexOf("sonnet") !== -1;
7
+ if (!model.description) {
8
+ var family = Object.keys(DESCRIPTIONS).find(function(key) { return name.indexOf(key) !== -1; });
9
+ if (family) model.description = DESCRIPTIONS[family];
10
+ }
11
+ return model;
12
+ }
13
+ function list(models) { return (models || []).map(describe); }
14
+ module.exports = { describe: describe, list: list };