@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,135 @@
1
+ import type { CanvasJsonSchema, CanvasProviderCloseRequest, CanvasProviderInvokeActionRequest, CanvasProviderOpenRequest, CanvasProviderOpenResult } from "./generated/rpc.js";
2
+ export type { CanvasJsonSchema, CanvasHostContext, CanvasHostContextCapabilities, } from "./generated/rpc.js";
3
+ /**
4
+ * Extension-owned canvases declared via
5
+ * `joinSession({ canvases: [createCanvas({...})] })`.
6
+ *
7
+ * The runtime sends provider callbacks as `canvas.open`, `canvas.close`, and
8
+ * `canvas.action.invoke` JSON-RPC requests via the codegen client session API
9
+ * pipeline. The SDK routes those requests by `canvasId` to the in-process
10
+ * handlers bound by `createCanvas`. Re-opening with an existing `instanceId`
11
+ * is how the host focuses an existing panel; reload is a renderer-only concern.
12
+ *
13
+ * @experimental Canvas types are part of an experimental wire-protocol surface
14
+ * and may change or be removed in future SDK or CLI releases.
15
+ */
16
+ /**
17
+ * A single agent-callable action contributed by a canvas. The metadata
18
+ * (`name`, `description`, `inputSchema`) is serialized over the wire on
19
+ * `session.create` / `session.resume`; the `handler` closure is stripped
20
+ * before the declaration is sent and dispatched in-process by the SDK.
21
+ *
22
+ * Names MUST NOT start with `canvas.` — that prefix is reserved for
23
+ * lifecycle verbs.
24
+ *
25
+ * @experimental This type is part of an experimental wire-protocol surface
26
+ * and may change or be removed in future SDK or CLI releases.
27
+ */
28
+ export interface CanvasAction {
29
+ /** Action identifier, unique within the canvas. */
30
+ name: string;
31
+ /** Description shown to the model when picking an action. */
32
+ description?: string;
33
+ /** Optional JSON Schema for the action's `input` payload. */
34
+ inputSchema?: CanvasJsonSchema;
35
+ /**
36
+ * Required per-action dispatch handler. The returned value becomes the
37
+ * `invoke_canvas_action` tool result. Return a `ToolResultObject`
38
+ * (with `binaryResultsForLlm`) to send text and images to the model, as a
39
+ * tool handler would; any other value is rendered to the model as JSON text.
40
+ */
41
+ handler: (ctx: CanvasProviderInvokeActionRequest) => Promise<unknown> | unknown;
42
+ }
43
+ /**
44
+ * Declarative metadata for a single canvas, serialized over the wire on
45
+ * `session.create` / `session.resume`.
46
+ *
47
+ * @experimental This type is part of an experimental wire-protocol surface
48
+ * and may change or be removed in future SDK or CLI releases.
49
+ */
50
+ export interface CanvasDeclaration {
51
+ /** Canvas id, unique within the declaring connection. */
52
+ id: string;
53
+ /** Human-readable label shown in discovery and host UI chrome. */
54
+ displayName: string;
55
+ /** Short, single-sentence description shown to the agent in canvas catalogs. */
56
+ description: string;
57
+ /** Optional icon path, resolved relative to the extension entrypoint. */
58
+ icon?: string;
59
+ /** Optional JSON Schema for the `input` payload accepted by `canvas.open`. */
60
+ inputSchema?: CanvasJsonSchema;
61
+ /** Agent-invocable actions exposed via `invoke_canvas_action`. */
62
+ actions?: Omit<CanvasAction, "handler">[];
63
+ }
64
+ /**
65
+ * Structured error returned from canvas handlers.
66
+ *
67
+ * @experimental This class is part of an experimental wire-protocol surface
68
+ * and may change or be removed in future SDK or CLI releases.
69
+ */
70
+ export declare class CanvasError extends Error {
71
+ readonly code: string;
72
+ constructor(code: string, message: string);
73
+ /** Default error when an action is declared but no `handler` is wired. */
74
+ static noHandler(): CanvasError;
75
+ }
76
+ /**
77
+ * Options accepted by {@link createCanvas}. Combines the declarative
78
+ * {@link CanvasDeclaration} fields with the in-process handler closures.
79
+ *
80
+ * @experimental This interface is part of an experimental wire-protocol surface
81
+ * and may change or be removed in future SDK or CLI releases.
82
+ */
83
+ export interface CanvasOptions {
84
+ /** @see CanvasDeclaration.id */
85
+ id: string;
86
+ /** @see CanvasDeclaration.displayName */
87
+ displayName: string;
88
+ /** @see CanvasDeclaration.description */
89
+ description: string;
90
+ /** @see CanvasDeclaration.icon */
91
+ icon?: string;
92
+ /** @see CanvasDeclaration.inputSchema */
93
+ inputSchema?: CanvasJsonSchema;
94
+ /**
95
+ * Agent-invocable actions exposed via `invoke_canvas_action`. Each action
96
+ * carries its own required `handler`; the action's wire metadata
97
+ * (`name`, `description`, `inputSchema`) is what reaches the runtime.
98
+ */
99
+ actions?: CanvasAction[];
100
+ /** Required. Open a new canvas instance. */
101
+ open: (ctx: CanvasProviderOpenRequest) => Promise<CanvasProviderOpenResult> | CanvasProviderOpenResult;
102
+ /**
103
+ * Optional. Notified when a canvas instance is closed by the user, the
104
+ * agent, or the host. Fire-and-forget: the return value is ignored and
105
+ * errors are logged but not surfaced to the runtime.
106
+ */
107
+ onClose?: (ctx: CanvasProviderCloseRequest) => Promise<void> | void;
108
+ }
109
+ /** A registered canvas: declarative metadata + in-process handler closures.
110
+ *
111
+ * Node intentionally uses a per-canvas factory pattern (mirroring
112
+ * {@link https://github.com/github/copilot-sdk | `DefineTool`}'s co-location
113
+ * ergonomics) where other SDKs (Rust, Python, Go, .NET) expose a single
114
+ * `CanvasHandler` per session that switches on `canvasId`. Both shapes target
115
+ * the same JSON-RPC wire protocol; the divergence is API ergonomics only.
116
+ *
117
+ * @experimental This class is part of an experimental wire-protocol surface
118
+ * and may change or be removed in future SDK or CLI releases.
119
+ */
120
+ export declare class Canvas {
121
+ readonly declaration: CanvasDeclaration;
122
+ readonly open: NonNullable<CanvasOptions["open"]>;
123
+ readonly onClose?: CanvasOptions["onClose"];
124
+ }
125
+ /** Create a canvas declaration with bound in-process handlers.
126
+ *
127
+ * Node intentionally uses this per-canvas factory pattern (mirroring
128
+ * `DefineTool`'s co-location ergonomics) where other SDKs (Rust, Python, Go,
129
+ * .NET) expose a single `CanvasHandler` per session that switches on
130
+ * `canvasId`. Both shapes target the same JSON-RPC wire protocol.
131
+ *
132
+ * @experimental This function is part of an experimental wire-protocol surface
133
+ * and may change or be removed in future SDK or CLI releases.
134
+ */
135
+ export declare function createCanvas(options: CanvasOptions): Canvas;
package/dist/canvas.js ADDED
@@ -0,0 +1,51 @@
1
+ class CanvasError extends Error {
2
+ constructor(code, message) {
3
+ super(message);
4
+ this.code = code;
5
+ this.name = "CanvasError";
6
+ }
7
+ code;
8
+ /** Default error when an action is declared but no `handler` is wired. */
9
+ static noHandler() {
10
+ return new CanvasError(
11
+ "canvas_action_no_handler",
12
+ "No handler implemented for this canvas action"
13
+ );
14
+ }
15
+ }
16
+ class Canvas {
17
+ declaration;
18
+ open;
19
+ onClose;
20
+ /** @internal */
21
+ actionHandlers;
22
+ /** @internal */
23
+ constructor(options) {
24
+ const actionHandlers = /* @__PURE__ */ new Map();
25
+ const wireActions = options.actions?.map(
26
+ ({ handler, ...wire }) => {
27
+ actionHandlers.set(wire.name, handler);
28
+ return wire;
29
+ }
30
+ );
31
+ this.declaration = {
32
+ id: options.id,
33
+ displayName: options.displayName,
34
+ description: options.description,
35
+ icon: options.icon,
36
+ inputSchema: options.inputSchema,
37
+ actions: wireActions
38
+ };
39
+ this.open = options.open;
40
+ this.onClose = options.onClose;
41
+ this.actionHandlers = actionHandlers;
42
+ }
43
+ }
44
+ function createCanvas(options) {
45
+ return new Canvas(options);
46
+ }
47
+ export {
48
+ Canvas,
49
+ CanvasError,
50
+ createCanvas
51
+ };
@@ -0,0 +1,77 @@
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 canvas_exports = {};
20
+ __export(canvas_exports, {
21
+ Canvas: () => Canvas,
22
+ CanvasError: () => CanvasError,
23
+ createCanvas: () => createCanvas
24
+ });
25
+ module.exports = __toCommonJS(canvas_exports);
26
+ class CanvasError extends Error {
27
+ constructor(code, message) {
28
+ super(message);
29
+ this.code = code;
30
+ this.name = "CanvasError";
31
+ }
32
+ code;
33
+ /** Default error when an action is declared but no `handler` is wired. */
34
+ static noHandler() {
35
+ return new CanvasError(
36
+ "canvas_action_no_handler",
37
+ "No handler implemented for this canvas action"
38
+ );
39
+ }
40
+ }
41
+ class Canvas {
42
+ declaration;
43
+ open;
44
+ onClose;
45
+ /** @internal */
46
+ actionHandlers;
47
+ /** @internal */
48
+ constructor(options) {
49
+ const actionHandlers = /* @__PURE__ */ new Map();
50
+ const wireActions = options.actions?.map(
51
+ ({ handler, ...wire }) => {
52
+ actionHandlers.set(wire.name, handler);
53
+ return wire;
54
+ }
55
+ );
56
+ this.declaration = {
57
+ id: options.id,
58
+ displayName: options.displayName,
59
+ description: options.description,
60
+ icon: options.icon,
61
+ inputSchema: options.inputSchema,
62
+ actions: wireActions
63
+ };
64
+ this.open = options.open;
65
+ this.onClose = options.onClose;
66
+ this.actionHandlers = actionHandlers;
67
+ }
68
+ }
69
+ function createCanvas(options) {
70
+ return new Canvas(options);
71
+ }
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ Canvas,
75
+ CanvasError,
76
+ createCanvas
77
+ });
@@ -0,0 +1,31 @@
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 cliVersion_exports = {};
20
+ __export(cliVersion_exports, {
21
+ COPILOT_CLI_USE_NPM_PACKAGE: () => COPILOT_CLI_USE_NPM_PACKAGE,
22
+ COPILOT_CLI_VERSION: () => COPILOT_CLI_VERSION
23
+ });
24
+ module.exports = __toCommonJS(cliVersion_exports);
25
+ const COPILOT_CLI_VERSION = "1.0.106-9.unstable.r43755488033.g11df7b2";
26
+ const COPILOT_CLI_USE_NPM_PACKAGE = false;
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ COPILOT_CLI_USE_NPM_PACKAGE,
30
+ COPILOT_CLI_VERSION
31
+ });