@microsoft/copilot-sdk 0.0.0-stage → 2.0.0-preview.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.
Files changed (91) hide show
  1. package/README.md +2531 -2
  2. package/dist/canvas.d.ts +135 -0
  3. package/dist/canvas.js +51 -0
  4. package/dist/cjs/canvas.js +77 -0
  5. package/dist/cjs/cliVersion.js +31 -0
  6. package/dist/cjs/client.js +3941 -0
  7. package/dist/cjs/copilotRequestHandler.js +815 -0
  8. package/dist/cjs/decisions.js +139 -0
  9. package/dist/cjs/entra.js +83 -0
  10. package/dist/cjs/extension.js +79 -0
  11. package/dist/cjs/ffiRuntimeHost.js +400 -0
  12. package/dist/cjs/generated/lifecycle-diagnostics.js +16 -0
  13. package/dist/cjs/generated/rpc.js +5883 -0
  14. package/dist/cjs/generated/session-events.js +16 -0
  15. package/dist/cjs/host.js +83 -0
  16. package/dist/cjs/index.js +100 -0
  17. package/dist/cjs/installationConfirmation.js +98 -0
  18. package/dist/cjs/jsonrpcTypes.js +41 -0
  19. package/dist/cjs/localModelJson.js +103 -0
  20. package/dist/cjs/package.json +1 -0
  21. package/dist/cjs/providerConfiguration.js +39 -0
  22. package/dist/cjs/rpcCancellation.js +49 -0
  23. package/dist/cjs/runtimeArtifacts.js +255 -0
  24. package/dist/cjs/schema.js +40 -0
  25. package/dist/cjs/sdkProtocolVersion.js +33 -0
  26. package/dist/cjs/session.js +2764 -0
  27. package/dist/cjs/sessionFsProvider.js +283 -0
  28. package/dist/cjs/taskAnalyticsJson.js +47 -0
  29. package/dist/cjs/telemetry.js +35 -0
  30. package/dist/cjs/toolSet.js +107 -0
  31. package/dist/cjs/types.js +204 -0
  32. package/dist/cjs/workflow.js +278 -0
  33. package/dist/cliVersion.d.ts +2 -0
  34. package/dist/cliVersion.js +6 -0
  35. package/dist/client.d.ts +576 -0
  36. package/dist/client.js +3924 -0
  37. package/dist/copilotRequestHandler.d.ts +91 -0
  38. package/dist/copilotRequestHandler.js +787 -0
  39. package/dist/decisions.d.ts +65 -0
  40. package/dist/decisions.js +113 -0
  41. package/dist/entra.d.ts +3 -0
  42. package/dist/entra.js +59 -0
  43. package/dist/extension.d.ts +69 -0
  44. package/dist/extension.js +59 -0
  45. package/dist/ffiRuntimeHost.d.ts +44 -0
  46. package/dist/ffiRuntimeHost.js +366 -0
  47. package/dist/generated/lifecycle-diagnostics.d.ts +232 -0
  48. package/dist/generated/lifecycle-diagnostics.js +0 -0
  49. package/dist/generated/rpc.d.ts +47706 -0
  50. package/dist/generated/rpc.js +5854 -0
  51. package/dist/generated/session-events.d.ts +17349 -0
  52. package/dist/generated/session-events.js +0 -0
  53. package/dist/host.d.ts +143 -0
  54. package/dist/host.js +59 -0
  55. package/dist/index.d.ts +23 -0
  56. package/dist/index.js +74 -0
  57. package/dist/installationConfirmation.d.ts +19 -0
  58. package/dist/installationConfirmation.js +74 -0
  59. package/dist/jsonrpcTypes.d.ts +16 -0
  60. package/dist/jsonrpcTypes.js +17 -0
  61. package/dist/localModelJson.d.ts +1 -0
  62. package/dist/localModelJson.js +69 -0
  63. package/dist/providerConfiguration.d.ts +3 -0
  64. package/dist/providerConfiguration.js +15 -0
  65. package/dist/rpcCancellation.d.ts +3 -0
  66. package/dist/rpcCancellation.js +25 -0
  67. package/dist/runtimeArtifacts.d.ts +18 -0
  68. package/dist/runtimeArtifacts.js +233 -0
  69. package/dist/schema.d.ts +4 -0
  70. package/dist/schema.js +14 -0
  71. package/dist/sdkProtocolVersion.d.ts +10 -0
  72. package/dist/sdkProtocolVersion.js +8 -0
  73. package/dist/session.d.ts +524 -0
  74. package/dist/session.js +2751 -0
  75. package/dist/sessionFsProvider.d.ts +130 -0
  76. package/dist/sessionFsProvider.js +257 -0
  77. package/dist/taskAnalyticsJson.d.ts +8 -0
  78. package/dist/taskAnalyticsJson.js +12 -0
  79. package/dist/telemetry.d.ts +14 -0
  80. package/dist/telemetry.js +11 -0
  81. package/dist/toolSet.d.ts +75 -0
  82. package/dist/toolSet.js +82 -0
  83. package/dist/types.d.ts +3864 -0
  84. package/dist/types.js +169 -0
  85. package/dist/workflow.d.ts +413 -0
  86. package/dist/workflow.js +248 -0
  87. package/docs/agent-author.md +372 -0
  88. package/docs/examples.md +747 -0
  89. package/docs/extensions.md +121 -0
  90. package/docs/workflows.md +303 -0
  91. package/package.json +135 -5
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var sessionFsProvider_exports = {};
20
+ __export(sessionFsProvider_exports, {
21
+ SessionFsSqliteTransactionFailure: () => SessionFsSqliteTransactionFailure,
22
+ SessionFsWriteFailure: () => SessionFsWriteFailure,
23
+ createSessionFsAdapter: () => createSessionFsAdapter
24
+ });
25
+ module.exports = __toCommonJS(sessionFsProvider_exports);
26
+ const MAX_BINARY_BYTES = (64 * 1024 * 1024 - 1024) / 4 * 3;
27
+ const MAX_BINARY_CONTENT_LENGTH = Math.ceil(MAX_BINARY_BYTES / 3) * 4;
28
+ class SessionFsSqliteTransactionFailure extends Error {
29
+ /** Failure classification reported to the runtime. */
30
+ errorClass;
31
+ constructor(message, errorClass = "fatal") {
32
+ super(message);
33
+ this.name = "SessionFsSqliteTransactionFailure";
34
+ this.errorClass = errorClass;
35
+ }
36
+ }
37
+ class SessionFsWriteFailure extends Error {
38
+ writeChanged = true;
39
+ }
40
+ function normalizeSqliteParams(params) {
41
+ if (!params) {
42
+ return void 0;
43
+ }
44
+ const normalized = {};
45
+ for (const [key, value] of Object.entries(params)) {
46
+ if (value !== void 0) {
47
+ normalized[key] = value;
48
+ }
49
+ }
50
+ return normalized;
51
+ }
52
+ function createSessionFsAdapter(provider) {
53
+ return {
54
+ readFileRange: async ({ path, offset, length }) => {
55
+ try {
56
+ if (!Number.isSafeInteger(offset) || offset < 0 || length !== void 0 && (!Number.isSafeInteger(length) || length < 0)) {
57
+ throw new RangeError(
58
+ "SessionFs byte offset and length must be non-negative safe integers"
59
+ );
60
+ }
61
+ if (!provider.readFileRange) {
62
+ throw new Error(
63
+ "Byte-range reads are not supported by this SessionFs provider"
64
+ );
65
+ }
66
+ const result = await provider.readFileRange(path, offset, length);
67
+ if (!Number.isSafeInteger(result.byteLength) || result.byteLength < 0) {
68
+ throw new Error("SessionFs byte length must be a non-negative safe integer");
69
+ }
70
+ const available = Math.max(0, result.byteLength - offset);
71
+ if (result.content.byteLength !== Math.min(length ?? available, available)) {
72
+ throw new Error("SessionFs returned an incorrect byte range length");
73
+ }
74
+ return {
75
+ content: Buffer.from(result.content).toString("base64"),
76
+ byteLength: result.byteLength
77
+ };
78
+ } catch (err) {
79
+ return { content: "", byteLength: 0, error: toSessionFsError(err) };
80
+ }
81
+ },
82
+ readFile: async ({ path }) => {
83
+ try {
84
+ const content = await provider.readFile(path);
85
+ return { content };
86
+ } catch (err) {
87
+ return { content: "", error: toSessionFsError(err) };
88
+ }
89
+ },
90
+ readFileBytes: async ({ path }) => {
91
+ if (!provider.readFileBytes) {
92
+ return {
93
+ content: "",
94
+ error: { code: "UNKNOWN", message: "Binary reads are not supported" }
95
+ };
96
+ }
97
+ try {
98
+ const bytes = await provider.readFileBytes(path);
99
+ if (bytes.length > MAX_BINARY_BYTES) {
100
+ return {
101
+ content: "",
102
+ error: {
103
+ code: "UNKNOWN",
104
+ message: "sessionFs.readFileBytes content exceeds the binary read limit"
105
+ }
106
+ };
107
+ }
108
+ return {
109
+ content: Buffer.from(bytes).toString("base64")
110
+ };
111
+ } catch (err) {
112
+ return { content: "", error: toSessionFsError(err) };
113
+ }
114
+ },
115
+ writeFile: async ({ path, content, mode }) => {
116
+ try {
117
+ await provider.writeFile(path, content, mode);
118
+ return void 0;
119
+ } catch (err) {
120
+ const error = toSessionFsError(err);
121
+ return err instanceof SessionFsWriteFailure ? { ...error, writeChanged: true } : error;
122
+ }
123
+ },
124
+ writeFileBytes: async ({ path, content, mode }) => {
125
+ if (!provider.writeFileBytes) {
126
+ return { code: "UNKNOWN", message: "Binary writes are not supported" };
127
+ }
128
+ if (content.length > MAX_BINARY_CONTENT_LENGTH) {
129
+ return {
130
+ code: "UNKNOWN",
131
+ message: "sessionFs.writeFileBytes content exceeds the binary write limit"
132
+ };
133
+ }
134
+ const bytes = Buffer.from(content, "base64");
135
+ if (bytes.toString("base64") !== content || bytes.length > MAX_BINARY_BYTES) {
136
+ return {
137
+ code: "UNKNOWN",
138
+ message: "invalid sessionFs.writeFileBytes base64 content"
139
+ };
140
+ }
141
+ try {
142
+ await provider.writeFileBytes(path, bytes, mode);
143
+ return void 0;
144
+ } catch (err) {
145
+ return toSessionFsError(err);
146
+ }
147
+ },
148
+ appendFile: async ({ path, content, mode }) => {
149
+ try {
150
+ await provider.appendFile(path, content, mode);
151
+ return void 0;
152
+ } catch (err) {
153
+ return toSessionFsError(err);
154
+ }
155
+ },
156
+ exists: async ({ path }) => {
157
+ try {
158
+ return { exists: await provider.exists(path) };
159
+ } catch {
160
+ return { exists: false };
161
+ }
162
+ },
163
+ stat: async ({ path }) => {
164
+ try {
165
+ return await provider.stat(path);
166
+ } catch (err) {
167
+ return {
168
+ isFile: false,
169
+ isDirectory: false,
170
+ size: 0,
171
+ mtime: (/* @__PURE__ */ new Date()).toISOString(),
172
+ birthtime: (/* @__PURE__ */ new Date()).toISOString(),
173
+ error: toSessionFsError(err)
174
+ };
175
+ }
176
+ },
177
+ mkdir: async ({ path, recursive, mode }) => {
178
+ try {
179
+ await provider.mkdir(path, recursive ?? false, mode);
180
+ return void 0;
181
+ } catch (err) {
182
+ return toSessionFsError(err);
183
+ }
184
+ },
185
+ readdir: async ({ path }) => {
186
+ try {
187
+ const entries = await provider.readdir(path);
188
+ return { entries };
189
+ } catch (err) {
190
+ return { entries: [], error: toSessionFsError(err) };
191
+ }
192
+ },
193
+ readdirWithTypes: async ({ path }) => {
194
+ try {
195
+ const entries = await provider.readdirWithTypes(path);
196
+ return { entries };
197
+ } catch (err) {
198
+ return { entries: [], error: toSessionFsError(err) };
199
+ }
200
+ },
201
+ rm: async ({ path, recursive, force }) => {
202
+ try {
203
+ await provider.rm(path, recursive ?? false, force ?? false);
204
+ return void 0;
205
+ } catch (err) {
206
+ return toSessionFsError(err);
207
+ }
208
+ },
209
+ rename: async ({ src, dest }) => {
210
+ try {
211
+ await provider.rename(src, dest);
212
+ return void 0;
213
+ } catch (err) {
214
+ return toSessionFsError(err);
215
+ }
216
+ },
217
+ // Unlike the FS methods above, SQLite methods let errors propagate to the JSON-RPC layer
218
+ // rather than catching and mapping via toSessionFsError. The FS error mapping is specifically
219
+ // for translating Node.js errno codes (e.g., ENOENT) into SessionFsError, which isn't
220
+ // meaningful for SQL errors. Letting exceptions propagate preserves the original error
221
+ // message in the JSON-RPC error response.
222
+ sqliteQuery: async ({ queryType, query, params: bindParams }) => {
223
+ if (!provider.sqlite) {
224
+ throw new Error("SQLite is not supported by this provider");
225
+ }
226
+ const result = await provider.sqlite.query(
227
+ queryType,
228
+ query,
229
+ normalizeSqliteParams(bindParams)
230
+ );
231
+ return result ?? { rows: [], columns: [], rowsAffected: 0 };
232
+ },
233
+ sqliteTransaction: async ({ statements }) => {
234
+ if (!provider.sqlite?.transaction) {
235
+ return {
236
+ results: [],
237
+ error: {
238
+ errorClass: "fatal",
239
+ message: "SQLite transactions are not supported by this provider"
240
+ }
241
+ };
242
+ }
243
+ try {
244
+ const results = await provider.sqlite.transaction(
245
+ statements.map((statement) => ({
246
+ queryType: statement.queryType,
247
+ query: statement.query,
248
+ params: normalizeSqliteParams(statement.params)
249
+ }))
250
+ );
251
+ return { results: results.map((result) => ({ ...result })) };
252
+ } catch (err) {
253
+ return { results: [], error: toSqliteTransactionError(err) };
254
+ }
255
+ },
256
+ sqliteExists: async () => {
257
+ if (!provider.sqlite) {
258
+ throw new Error("SQLite is not supported by this provider");
259
+ }
260
+ return { exists: await provider.sqlite.exists() };
261
+ }
262
+ };
263
+ }
264
+ function toSessionFsError(err) {
265
+ const e = err;
266
+ const code = e.code === "ENOENT" ? "ENOENT" : "UNKNOWN";
267
+ return { code, message: e.message ?? String(err) };
268
+ }
269
+ function toSqliteTransactionError(err) {
270
+ if (err instanceof SessionFsSqliteTransactionFailure) {
271
+ return { errorClass: err.errorClass, message: err.message };
272
+ }
273
+ return {
274
+ errorClass: "fatal",
275
+ message: err instanceof Error ? err.message : String(err)
276
+ };
277
+ }
278
+ // Annotate the CommonJS export names for ESM import in node:
279
+ 0 && (module.exports = {
280
+ SessionFsSqliteTransactionFailure,
281
+ SessionFsWriteFailure,
282
+ createSessionFsAdapter
283
+ });
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var taskAnalyticsJson_exports = {};
30
+ __export(taskAnalyticsJson_exports, {
31
+ parseTrajectoryJson: () => parseTrajectoryJson,
32
+ rawHistoryResponse: () => rawHistoryResponse
33
+ });
34
+ module.exports = __toCommonJS(taskAnalyticsJson_exports);
35
+ const rawHistoryResponse = /* @__PURE__ */ Symbol("rawHistoryResponse");
36
+ async function parseTrajectoryJson(text) {
37
+ const { parse, parseNumberAndBigInt } = await import("lossless-json");
38
+ return parse(text, void 0, (token) => {
39
+ const value = parseNumberAndBigInt(token);
40
+ return typeof value === "bigint" && Number.isSafeInteger(Number(value)) ? Number(value) : value;
41
+ });
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ parseTrajectoryJson,
46
+ rawHistoryResponse
47
+ });
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var telemetry_exports = {};
20
+ __export(telemetry_exports, {
21
+ getTraceContext: () => getTraceContext
22
+ });
23
+ module.exports = __toCommonJS(telemetry_exports);
24
+ async function getTraceContext(provider) {
25
+ if (!provider) return {};
26
+ try {
27
+ return await provider() ?? {};
28
+ } catch {
29
+ return {};
30
+ }
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ getTraceContext
35
+ });
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var toolSet_exports = {};
20
+ __export(toolSet_exports, {
21
+ BuiltInTools: () => BuiltInTools,
22
+ ToolSet: () => ToolSet
23
+ });
24
+ module.exports = __toCommonJS(toolSet_exports);
25
+ const VALID_TOOL_NAME = /^[a-zA-Z0-9_-]+$/;
26
+ function validateName(kind, name) {
27
+ if (name === "*") {
28
+ return;
29
+ }
30
+ if (!VALID_TOOL_NAME.test(name)) {
31
+ throw new Error(
32
+ `Invalid ${kind} tool name '${name}': tool names must match /^[a-zA-Z0-9_-]+$/ or be the wildcard '*'.`
33
+ );
34
+ }
35
+ }
36
+ class ToolSet {
37
+ items = [];
38
+ addBuiltIn(nameOrNames) {
39
+ const names = typeof nameOrNames === "string" ? [nameOrNames] : nameOrNames;
40
+ for (const name of names) {
41
+ validateName("builtin", name);
42
+ this.items.push(`builtin:${name}`);
43
+ }
44
+ return this;
45
+ }
46
+ /**
47
+ * Adds a custom tool pattern. Matches tools registered via the SDK's
48
+ * `tools` option or via custom agents.
49
+ *
50
+ * @param name A specific custom tool name or `"*"` to match all custom tools.
51
+ */
52
+ addCustom(name) {
53
+ validateName("custom", name);
54
+ this.items.push(`custom:${name}`);
55
+ return this;
56
+ }
57
+ /**
58
+ * Adds an MCP tool pattern. Matches tools advertised by any configured
59
+ * MCP server.
60
+ *
61
+ * @param toolName The runtime's canonical wire name for the MCP tool
62
+ * (e.g. `"github-list_issues"`), or `"*"` to match all MCP tools from
63
+ * any server.
64
+ */
65
+ addMcp(toolName) {
66
+ validateName("mcp", toolName);
67
+ this.items.push(`mcp:${toolName}`);
68
+ return this;
69
+ }
70
+ /**
71
+ * Returns a defensive copy of the accumulated filter strings, suitable for
72
+ * passing as {@link SessionConfigBase.availableTools}.
73
+ */
74
+ toArray() {
75
+ return [...this.items];
76
+ }
77
+ }
78
+ const BuiltInTools = {
79
+ /**
80
+ * Built-in tools that operate only within the bounds of a single session —
81
+ * no host filesystem access outside the session, no cross-session state,
82
+ * no host environment access, no network. Safe to enable in `Mode = "empty"`
83
+ * scenarios (e.g. multi-tenant servers) without leaking host capabilities.
84
+ *
85
+ * **Contract:** tools in this set MUST NOT be extended (even behind options
86
+ * or args) to read or write state outside the session boundary. Adding
87
+ * cross-session or host-state behavior to one of these tools is a
88
+ * breaking change that requires removing it from this set.
89
+ */
90
+ Isolated: [
91
+ "ask_user",
92
+ "task_complete",
93
+ "exit_plan_mode",
94
+ "task",
95
+ "read_agent",
96
+ "write_agent",
97
+ "list_agents",
98
+ "send_inbox",
99
+ "context_board",
100
+ "skill"
101
+ ]
102
+ };
103
+ // Annotate the CommonJS export names for ESM import in node:
104
+ 0 && (module.exports = {
105
+ BuiltInTools,
106
+ ToolSet
107
+ });
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var types_exports = {};
20
+ __export(types_exports, {
21
+ CopilotRequestHandler: () => import_copilotRequestHandler.CopilotRequestHandler,
22
+ CopilotWebSocketCloseStatus: () => import_copilotRequestHandler.CopilotWebSocketCloseStatus,
23
+ CopilotWebSocketForwarder: () => import_copilotRequestHandler.CopilotWebSocketForwarder,
24
+ CopilotWebSocketHandler: () => import_copilotRequestHandler.CopilotWebSocketHandler,
25
+ DisableBypassPermissionsModes: () => DisableBypassPermissionsModes,
26
+ RuntimeConnection: () => RuntimeConnection,
27
+ SYSTEM_MESSAGE_SECTIONS: () => SYSTEM_MESSAGE_SECTIONS,
28
+ SessionFsSqliteTransactionFailure: () => import_sessionFsProvider2.SessionFsSqliteTransactionFailure,
29
+ SessionFsWriteFailure: () => import_sessionFsProvider3.SessionFsWriteFailure,
30
+ approveAll: () => approveAll,
31
+ convertMcpCallToolResult: () => convertMcpCallToolResult,
32
+ createAttributedPermissionResult: () => createAttributedPermissionResult,
33
+ createAttributedResult: () => createAttributedResult,
34
+ createSessionFsAdapter: () => import_sessionFsProvider.createSessionFsAdapter,
35
+ defaultJoinSessionPermissionHandler: () => defaultJoinSessionPermissionHandler,
36
+ defineTool: () => defineTool,
37
+ isAttributedPermissionResult: () => isAttributedPermissionResult
38
+ });
39
+ module.exports = __toCommonJS(types_exports);
40
+ var import_sessionFsProvider = require("./sessionFsProvider.js");
41
+ var import_sessionFsProvider2 = require("./sessionFsProvider.js");
42
+ var import_sessionFsProvider3 = require("./sessionFsProvider.js");
43
+ var import_copilotRequestHandler = require("./copilotRequestHandler.js");
44
+ const RuntimeConnection = {
45
+ /**
46
+ * Spawn a runtime child process and communicate over its stdin/stdout.
47
+ */
48
+ forStdio(opts = {}) {
49
+ return { kind: "stdio", path: opts.path, args: opts.args, env: opts.env };
50
+ },
51
+ /**
52
+ * Spawn a runtime child process that listens on a TCP socket and connect to it.
53
+ */
54
+ forTcp(opts = {}) {
55
+ return {
56
+ kind: "tcp",
57
+ port: opts.port,
58
+ connectionToken: opts.connectionToken,
59
+ path: opts.path,
60
+ args: opts.args,
61
+ env: opts.env
62
+ };
63
+ },
64
+ /**
65
+ * Connect to an already-running runtime at the given URL. The SDK does not
66
+ * spawn a process in this mode.
67
+ */
68
+ forUri(url, opts = {}) {
69
+ return { kind: "uri", url, connectionToken: opts.connectionToken };
70
+ },
71
+ /**
72
+ * Host the runtime in-process over the native runtime library's C ABI (FFI).
73
+ *
74
+ * The default when no connection or environment override is supplied.
75
+ * Runtime configuration from `gitHubToken`, `telemetry` and
76
+ * `baseDirectory` is scoped to this host, not the process environment.
77
+ * Client-level `env` and `workingDirectory` are unsupported.
78
+ */
79
+ forInProcess(options = {}) {
80
+ return { kind: "inprocess", ...options };
81
+ }
82
+ };
83
+ function convertMcpCallToolResult(callResult) {
84
+ const textParts = [];
85
+ const binaryResults = [];
86
+ for (const block of callResult.content) {
87
+ switch (block.type) {
88
+ case "text":
89
+ if (typeof block.text === "string") {
90
+ textParts.push(block.text);
91
+ }
92
+ break;
93
+ case "image":
94
+ if (typeof block.data === "string" && block.data && typeof block.mimeType === "string") {
95
+ binaryResults.push({
96
+ data: block.data,
97
+ mimeType: block.mimeType,
98
+ type: "image"
99
+ });
100
+ }
101
+ break;
102
+ case "resource": {
103
+ if (block.resource?.text) {
104
+ textParts.push(block.resource.text);
105
+ }
106
+ if (block.resource?.blob) {
107
+ const mimeType = block.resource.mimeType;
108
+ binaryResults.push({
109
+ data: block.resource.blob,
110
+ mimeType: typeof mimeType === "string" && mimeType ? mimeType : "application/octet-stream",
111
+ type: "resource",
112
+ description: block.resource.uri
113
+ });
114
+ }
115
+ break;
116
+ }
117
+ }
118
+ }
119
+ return {
120
+ textResultForLlm: textParts.join("\n"),
121
+ resultType: callResult.isError ? "failure" : "success",
122
+ ...binaryResults.length > 0 ? { binaryResultsForLlm: binaryResults } : {}
123
+ };
124
+ }
125
+ function defineTool(name, config) {
126
+ return { name, ...config };
127
+ }
128
+ const SYSTEM_MESSAGE_SECTIONS = {
129
+ preamble: { description: "Agent identity preamble and mode statement" },
130
+ identity: {
131
+ description: "Section group covering the identity preamble and its sibling sub-sections (tone, tool efficiency, etc.)"
132
+ },
133
+ tone: { description: "Response style, conciseness rules, output formatting preferences" },
134
+ tool_efficiency: { description: "Tool usage patterns, parallel calling, batching guidelines" },
135
+ environment_context: { description: "CWD, OS, git root, directory listing, available tools" },
136
+ code_change_rules: { description: "Coding rules, linting/testing, ecosystem tools, style" },
137
+ guidelines: { description: "Tips, behavioral best practices, behavioral guidelines" },
138
+ safety: { description: "Environment limitations, prohibited actions, security policies" },
139
+ tool_instructions: { description: "Per-tool usage instructions" },
140
+ custom_instructions: { description: "Repository and organization custom instructions" },
141
+ runtime_instructions: {
142
+ description: "Runtime-provided system-prompt context and instructions, such as system notifications, memories, workspace context, and content-exclusion policy. Mode-specific instructions can travel in transition messages instead."
143
+ },
144
+ last_instructions: {
145
+ description: "End-of-prompt instructions: parallel tool calling, persistence, task completion, and configured subagent-model guidance when the task tool is available"
146
+ }
147
+ };
148
+ function isAttributedPermissionResult(result) {
149
+ return result.kind === "attributed";
150
+ }
151
+ function createAttributedPermissionResult(result, decisionContext) {
152
+ const inner = isAttributedPermissionResult(result) ? result.result : result;
153
+ return { kind: "attributed", result: inner, decisionContext };
154
+ }
155
+ function createAttributedResult(result, decisionContext) {
156
+ if ("kind" in result && typeof result.kind === "string") {
157
+ return createAttributedPermissionResult(
158
+ result,
159
+ decisionContext
160
+ );
161
+ }
162
+ return { ...result, decisionContext };
163
+ }
164
+ const approveAll = (request, invocation) => {
165
+ if (invocation.managedSettingsEnabled) {
166
+ throw new Error("approveAll cannot be used when managed settings are enabled");
167
+ }
168
+ if ("managedApprovalRequired" in request) {
169
+ const managedApprovalRequired = request.managedApprovalRequired;
170
+ if (managedApprovalRequired !== void 0 && managedApprovalRequired !== false) {
171
+ return { kind: "no-result" };
172
+ }
173
+ }
174
+ return { kind: "approve-once" };
175
+ };
176
+ const defaultJoinSessionPermissionHandler = () => ({
177
+ kind: "no-result"
178
+ });
179
+ const DisableBypassPermissionsModes = {
180
+ /** Turn off bypass-permissions mode entirely. */
181
+ Disable: "disable",
182
+ /** Permit automatic bypass but block full allow-all. */
183
+ AllowAutoOnly: "allow-auto-only"
184
+ };
185
+ // Annotate the CommonJS export names for ESM import in node:
186
+ 0 && (module.exports = {
187
+ CopilotRequestHandler,
188
+ CopilotWebSocketCloseStatus,
189
+ CopilotWebSocketForwarder,
190
+ CopilotWebSocketHandler,
191
+ DisableBypassPermissionsModes,
192
+ RuntimeConnection,
193
+ SYSTEM_MESSAGE_SECTIONS,
194
+ SessionFsSqliteTransactionFailure,
195
+ SessionFsWriteFailure,
196
+ approveAll,
197
+ convertMcpCallToolResult,
198
+ createAttributedPermissionResult,
199
+ createAttributedResult,
200
+ createSessionFsAdapter,
201
+ defaultJoinSessionPermissionHandler,
202
+ defineTool,
203
+ isAttributedPermissionResult
204
+ });