@github/copilot-sdk 1.0.13-preview.2 → 1.0.13-preview.4

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.
@@ -10,6 +10,16 @@ export type JsonValue = null | boolean | number | string | JsonValue[] | {
10
10
  * Union of all session event variants emitted by the Copilot CLI runtime.
11
11
  */
12
12
  export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | ScheduleCreatedEvent | ScheduleCancelledEvent | ScheduleRearmedEvent | AutopilotObjectiveChangedEvent | InfoEvent | WarningEvent | ModelChangeEvent | ModeChangedEvent | SessionLimitsChangedEvent | PermissionsChangedEvent | PlanChangedEvent | TodosChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | UsageCheckpointEvent | ContextChangedEvent | UsageInfoEvent | ContextClearedEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | FusionRouteStartedEvent | FusionRouteFailedEvent | FusionResolvedEvent | FusionCompletedEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantIntentEvent | AssistantFusionPhaseStartedEvent | AssistantFusionPhaseCompletedEvent | AssistantFusionPhaseFailedEvent | AssistantServerToolProgressEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantToolCallDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageStartEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantIdleEvent | AssistantUsageEvent | ModelCallFailureEvent | ModelCallFinishedEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | ToolSearchActivatedEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentConfiguredEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | HookProgressEvent | BinaryAssetEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | McpHeadersRefreshRequiredEvent | McpHeadersRefreshCompletedEvent | CustomNotificationEvent | UIEphemeralQueryEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | SessionLimitsExhaustedRequestedEvent | SessionLimitsExhaustedCompletedEvent | AutoModeResolvedEvent | ManagedSettingsResolvedEvent | ManagedSettingsEnforcedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | FactoryRunUpdatedEvent | FactoryRunStartedEvent | FactoryRunSettledEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | McpToolsListChangedEvent | McpResourcesListChangedEvent | McpPromptsListChangedEvent | ExtensionsLoadedEvent | CanvasOpenedEvent | CanvasRegistryChangedEvent | CanvasClosedEvent | CanvasUnavailableEvent | CanvasRecordedEvent | CanvasRemovedEvent | ExtensionsAttachmentsPushedEvent | McpAppToolCallCompleteEvent;
13
+ /**
14
+ * Routing preference used when the session model is `auto`.
15
+ */
16
+ export type AutoTier =
17
+ /** Optimize for efficiency. */
18
+ "efficiency"
19
+ /** Balance efficiency and intelligence. */
20
+ | "balance"
21
+ /** Optimize for intelligence. */
22
+ | "intelligence";
13
23
  /**
14
24
  * Hosting platform type of the repository (github or ado)
15
25
  */
@@ -317,6 +327,10 @@ export type CitationProvider =
317
327
  */
318
328
  /** @experimental */
319
329
  export type CitationLocation = CitationLocationChar | CitationLocationPage | CitationLocationBlock;
330
+ /**
331
+ * Hosted program caller type
332
+ */
333
+ export type AssistantMessageToolRequestCallerType = "program";
320
334
  /**
321
335
  * API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
322
336
  */
@@ -894,6 +908,7 @@ export interface StartData {
894
908
  * Whether the session was already in use by another client at start time
895
909
  */
896
910
  alreadyInUse?: boolean;
911
+ autoTier?: AutoTier;
897
912
  context?: WorkingDirectoryContext;
898
913
  /**
899
914
  * Context tier selected at session creation time for models with tiered context pricing; null when no tier is selected (e.g., non-tiered model)
@@ -1046,6 +1061,7 @@ export interface ResumeData {
1046
1061
  * Whether the session was already in use by another client at resume time
1047
1062
  */
1048
1063
  alreadyInUse?: boolean;
1064
+ autoTier?: AutoTier;
1049
1065
  context?: WorkingDirectoryContext;
1050
1066
  /**
1051
1067
  * Context tier currently selected at resume time; null when no tier is active
@@ -4537,6 +4553,7 @@ export interface AssistantMessageToolRequest {
4537
4553
  * Arguments to pass to the tool, format depends on the tool
4538
4554
  */
4539
4555
  arguments?: JsonValue;
4556
+ caller?: AssistantMessageToolRequestCaller;
4540
4557
  /**
4541
4558
  * Resolved intention summary describing what this specific call does
4542
4559
  */
@@ -4563,6 +4580,16 @@ export interface AssistantMessageToolRequest {
4563
4580
  toolTitle?: string;
4564
4581
  type?: AssistantMessageToolRequestType;
4565
4582
  }
4583
+ /**
4584
+ * Hosted program that requested this client tool call
4585
+ */
4586
+ export interface AssistantMessageToolRequestCaller {
4587
+ /**
4588
+ * Provider-assigned identifier for the hosted caller.
4589
+ */
4590
+ callerId: string;
4591
+ type: AssistantMessageToolRequestCallerType;
4592
+ }
4566
4593
  /**
4567
4594
  * Session event "assistant.message_start". Streaming assistant message start metadata
4568
4595
  */
@@ -6553,7 +6580,7 @@ export interface HookStartData {
6553
6580
  */
6554
6581
  hookType: string;
6555
6582
  /**
6556
- * Input data passed to the hook
6583
+ * Input data passed to the hook. For postToolUse hooks the retained copy served by session.eventLog.read (and by a resumed session) elides the tool result's inline `contents`/`uiResource` and replaces an over-long `textResultForLlm` with a `[copilot:elided ...]` marker, to keep a multi-megabyte payload out of the durable event log; the live subscription stream still delivers the full value. Read the adjacent tool.execution_complete event for the tool result itself.
6557
6584
  */
6558
6585
  input?: JsonValue;
6559
6586
  /**
package/dist/index.d.ts CHANGED
@@ -11,5 +11,5 @@ export { defineFactory, FactoryResumeError, isFactoryRunTerminal } from "./facto
11
11
  export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
12
12
  export { defineTool, approveAll, createAttributedPermissionResult, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
13
13
  export type * from "./generated/session-events.js";
14
- export type { CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
15
- export type { RunOptions, ResumeOptions, FactoryResumeErrorCode, SessionFactoryApi, FactoryAgentOptions, FactoryContext, FactoryDefinition, FactoryHandle, FactoryJsonSchema, JsonValue, FactoryPipelineStage, FactoryStepOptions, FactoryRunResult, FactoryRunStatus, FactoryRunSummary, FactoryRunDetail, FactoryProgressPage, FactoryProgressLine, FactoryPhaseObservation, FactoryPhaseStatus, FactoryAgentSummary, } from "./factory.js";
14
+ export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
15
+ export type { RunOptions, ResumeOptions, FactoryResumeErrorCode, SessionFactoryApi, FactoryAgentOptions, FactoryContext, FactoryDefinition, FactoryHandle, FactoryJsonSchema, JsonValue, FactoryPipelineStage, FactoryStepOptions, FactoryRunResult, FactoryRunStatus, FactoryRunSummary, FactoryListRunsOptions, FactoryRunsPage, FactoryRunDetail, FactoryProgressPage, FactoryProgressLine, FactoryPhaseObservation, FactoryPhaseStatus, FactoryAgentSummary, } from "./factory.js";
@@ -0,0 +1,6 @@
1
+ export interface RuntimeArtifactSources {
2
+ packageRoot: string;
3
+ platform: string;
4
+ }
5
+ export declare function defaultRuntimeCacheRoot(platform?: NodeJS.Platform, home?: string, environment?: NodeJS.ProcessEnv): string;
6
+ export declare function materializeRuntimeBundle(sources: RuntimeArtifactSources, cacheRoot?: string): string;
@@ -0,0 +1,145 @@
1
+ import { createHash } from "node:crypto";
2
+ import {
3
+ chmodSync,
4
+ copyFileSync,
5
+ existsSync,
6
+ lstatSync,
7
+ mkdirSync,
8
+ mkdtempSync,
9
+ readdirSync,
10
+ renameSync,
11
+ rmSync,
12
+ statSync
13
+ } from "node:fs";
14
+ import { homedir } from "node:os";
15
+ import { dirname, join, relative, sep } from "node:path";
16
+ const EXCLUDED_TOP_LEVEL = /* @__PURE__ */ new Set([
17
+ "app.js",
18
+ "assets",
19
+ "changelog.json",
20
+ "copilot",
21
+ "copilot.exe",
22
+ "copilot-sdk",
23
+ "foundry-local-sdk",
24
+ "index.js",
25
+ "LICENSE.md",
26
+ "napi-oop-runtime",
27
+ "npm-loader.js",
28
+ "package.json",
29
+ "preloads",
30
+ "pvrecorder",
31
+ "queries",
32
+ "README.md",
33
+ "sdk",
34
+ "sea-loader.js",
35
+ "webview"
36
+ ]);
37
+ function validateFile(path, label) {
38
+ if (!existsSync(path)) {
39
+ throw new Error(`${label} not found at ${path}.`);
40
+ }
41
+ if (statSync(path).size === 0) {
42
+ throw new Error(`${label} at ${path} is empty.`);
43
+ }
44
+ }
45
+ function validateRuntimeBundle(wrapper, runtimeNode) {
46
+ validateFile(wrapper, "Copilot runtime wrapper");
47
+ validateFile(runtimeNode, "Copilot runtime.node");
48
+ }
49
+ function isExcluded(relativePath) {
50
+ const parts = relativePath.split(sep);
51
+ const topLevel = parts[0];
52
+ const fileName = parts.at(-1) ?? "";
53
+ return EXCLUDED_TOP_LEVEL.has(topLevel) || /^tree-sitter.*\.wasm$/.test(topLevel) || /^voice-.*\.js$/.test(topLevel) || fileName === "cli-native.node" || parts.includes("mediaremote-adapter") || fileName.startsWith("copilot-runtime-bin");
54
+ }
55
+ function collectRuntimeAssets(sources) {
56
+ const assets = [];
57
+ const visit = (directory) => {
58
+ for (const entry of readdirSync(directory, { withFileTypes: true })) {
59
+ const source = join(directory, entry.name);
60
+ const sourceRelative = relative(sources.packageRoot, source);
61
+ if (isExcluded(sourceRelative)) {
62
+ continue;
63
+ }
64
+ if (entry.isDirectory()) {
65
+ visit(source);
66
+ continue;
67
+ }
68
+ if (!entry.isFile() && !entry.isSymbolicLink()) {
69
+ continue;
70
+ }
71
+ const parts = sourceRelative.split(sep);
72
+ let relativePath = sourceRelative;
73
+ if (parts[0] === "prebuilds") {
74
+ if (parts[1] !== sources.platform || parts.length < 3) {
75
+ continue;
76
+ }
77
+ relativePath = parts.slice(2).join(sep);
78
+ }
79
+ assets.push({ source, relativePath });
80
+ }
81
+ };
82
+ visit(sources.packageRoot);
83
+ return assets.sort((left, right) => left.relativePath.localeCompare(right.relativePath));
84
+ }
85
+ function sourceFingerprint(assets) {
86
+ const hash = createHash("sha256");
87
+ for (const asset of assets) {
88
+ const stat = lstatSync(asset.source);
89
+ hash.update(asset.relativePath).update("\0");
90
+ hash.update(`${stat.size}:${stat.mtimeMs}`).update("\0");
91
+ }
92
+ return hash.digest("hex").slice(0, 20);
93
+ }
94
+ function makeExecutable(path) {
95
+ if (process.platform === "win32") {
96
+ return;
97
+ }
98
+ const mode = statSync(path).mode;
99
+ if ((mode & 73) === 0) {
100
+ chmodSync(path, mode | 73);
101
+ }
102
+ }
103
+ function defaultRuntimeCacheRoot(platform = process.platform, home = homedir(), environment = process.env) {
104
+ const cacheDirectory = platform === "win32" ? environment.LOCALAPPDATA ?? join(home, "AppData", "Local") : platform === "darwin" ? join(home, "Library", "Caches") : environment.XDG_CACHE_HOME ?? join(home, ".cache");
105
+ return join(cacheDirectory, "github-copilot-sdk", "runtime");
106
+ }
107
+ function materializeRuntimeBundle(sources, cacheRoot = defaultRuntimeCacheRoot()) {
108
+ const assets = collectRuntimeAssets(sources);
109
+ const wrapperName = process.platform === "win32" ? "copilot-runtime.exe" : "copilot-runtime";
110
+ const sourceWrapper = assets.find((asset) => asset.relativePath === wrapperName)?.source;
111
+ const sourceRuntimeNode = assets.find((asset) => asset.relativePath === "runtime.node")?.source;
112
+ validateRuntimeBundle(sourceWrapper ?? "", sourceRuntimeNode ?? "");
113
+ const installDir = join(cacheRoot, `${sources.platform}-${sourceFingerprint(assets)}`);
114
+ const installedWrapper = join(installDir, wrapperName);
115
+ const installedRuntimeNode = join(installDir, "runtime.node");
116
+ if (existsSync(installDir)) {
117
+ validateRuntimeBundle(installedWrapper, installedRuntimeNode);
118
+ makeExecutable(installedWrapper);
119
+ return installedWrapper;
120
+ }
121
+ mkdirSync(cacheRoot, { recursive: true });
122
+ const stagingDir = mkdtempSync(join(cacheRoot, ".runtime-"));
123
+ try {
124
+ for (const asset of assets) {
125
+ const destination = join(stagingDir, asset.relativePath);
126
+ mkdirSync(dirname(destination), { recursive: true });
127
+ copyFileSync(asset.source, destination);
128
+ }
129
+ const stagedWrapper = join(stagingDir, wrapperName);
130
+ makeExecutable(stagedWrapper);
131
+ renameSync(stagingDir, installDir);
132
+ } catch (error) {
133
+ if (!existsSync(installDir)) {
134
+ throw error;
135
+ }
136
+ validateRuntimeBundle(installedWrapper, installedRuntimeNode);
137
+ } finally {
138
+ rmSync(stagingDir, { recursive: true, force: true });
139
+ }
140
+ return installedWrapper;
141
+ }
142
+ export {
143
+ defaultRuntimeCacheRoot,
144
+ materializeRuntimeBundle
145
+ };
package/dist/session.js CHANGED
@@ -265,14 +265,18 @@ class CopilotSession {
265
265
  const name = typeof nameOrHandle === "string" ? nameOrHandle : getFactoryDefinition(nameOrHandle).meta.name;
266
266
  if (options?.resumeFromRunId !== void 0) {
267
267
  return this.factory.resume(options.resumeFromRunId, {
268
- limits: options.limits
268
+ limits: options.limits,
269
+ notifyOnComplete: options.notifyOnComplete,
270
+ logPhaseNames: options.logPhaseNames
269
271
  });
270
272
  }
271
273
  const envelope = await this.rpc.factory.run({
272
274
  name,
273
275
  args: options?.args === void 0 ? {} : options.args,
274
276
  options: {
275
- limits: options?.limits
277
+ limits: options?.limits,
278
+ notifyOnComplete: options?.notifyOnComplete,
279
+ logPhaseNames: options?.logPhaseNames
276
280
  }
277
281
  });
278
282
  return this.settleFactoryRun(envelope);
@@ -283,7 +287,9 @@ class CopilotSession {
283
287
  try {
284
288
  response = await this.rpc.factory.resume({
285
289
  runId,
286
- limits: options?.limits
290
+ limits: options?.limits,
291
+ notifyOnComplete: options?.notifyOnComplete,
292
+ logPhaseNames: options?.logPhaseNames
287
293
  });
288
294
  } catch (error) {
289
295
  if (error instanceof ResponseError && typeof error.data === "object" && error.data !== null) {
@@ -298,7 +304,10 @@ class CopilotSession {
298
304
  }),
299
305
  getRun: async (runId) => this.rpc.factory.getRun({ runId }),
300
306
  waitForRun: (runId, options) => this.waitForFactoryRun(runId, options?.signal),
301
- listRuns: async () => (await this.rpc.factory.listRuns({})).runs,
307
+ listRuns: (async (options) => {
308
+ const page = await this.rpc.factory.listRuns(options ?? {});
309
+ return options === void 0 ? page.runs : page;
310
+ }),
302
311
  getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
303
312
  getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
304
313
  cancel: async (runId) => this.rpc.factory.cancel({ runId })
package/dist/types.d.ts CHANGED
@@ -943,7 +943,7 @@ export type PermissionHandler = (request: PermissionRequest, invocation: {
943
943
  export declare const approveAll: PermissionHandler;
944
944
  export declare const defaultJoinSessionPermissionHandler: PermissionHandler;
945
945
  /**
946
- * Request for user input from the agent (enables ask_user tool)
946
+ * Legacy question-and-answer request from the `ask_user` tool.
947
947
  */
948
948
  export interface UserInputRequest {
949
949
  /**
@@ -1813,6 +1813,8 @@ export interface ManagedSettings {
1813
1813
  /** Managed permission policy for the session. */
1814
1814
  permissions?: ManagedSettingsPermissions;
1815
1815
  }
1816
+ /** Selects the model-facing shape of the built-in `ask_user` tool. */
1817
+ export type AskUserVariant = "legacy" | "elicitation";
1816
1818
  /**
1817
1819
  * Shared configuration fields used by both {@link SessionConfig} (for
1818
1820
  * creating a new session) and {@link ResumeSessionConfig} (for resuming
@@ -2085,9 +2087,18 @@ export interface SessionConfigBase {
2085
2087
  onMcpAuthRequest?: McpAuthHandler;
2086
2088
  /**
2087
2089
  * Handler for user input requests from the agent.
2088
- * When provided, enables the ask_user tool allowing the agent to ask questions.
2090
+ * When provided with the default `legacy` {@link AskUserVariant}, enables the
2091
+ * question-and-answer form of the `ask_user` tool.
2089
2092
  */
2090
2093
  onUserInputRequest?: UserInputHandler;
2094
+ /**
2095
+ * Selects the model-facing shape of the built-in `ask_user` tool.
2096
+ *
2097
+ * The default is `"legacy"`. To use `"elicitation"`, also provide
2098
+ * {@link onElicitationRequest} so the host can answer structured forms.
2099
+ * The runtime resolves this option when it creates or cold-resumes the session.
2100
+ */
2101
+ askUserVariant?: AskUserVariant;
2091
2102
  /**
2092
2103
  * Handler for elicitation requests from the agent.
2093
2104
  * When provided, the server calls back to this client for form-based UI dialogs.
package/docs/factories.md CHANGED
@@ -139,6 +139,8 @@ Run by registered name or handle:
139
139
  const run = await session.factory.run("review-changed", {
140
140
  args: { files: ["src/a.ts"] },
141
141
  limits: { maxAiCredits: 3 },
142
+ notifyOnComplete: true,
143
+ logPhaseNames: true,
142
144
  });
143
145
 
144
146
  if (run.status === "completed") {
@@ -153,7 +155,12 @@ The name overload is:
153
155
  ```ts
154
156
  session.factory.run(
155
157
  name: string,
156
- options?: { args?: JsonValue; limits?: FactoryLimits },
158
+ options?: {
159
+ args?: JsonValue;
160
+ limits?: FactoryLimits;
161
+ notifyOnComplete?: boolean;
162
+ logPhaseNames?: boolean;
163
+ },
157
164
  ): Promise<FactoryRunResult>;
158
165
  ```
159
166
 
@@ -162,6 +169,8 @@ Resume by run ID without resending the name or arguments:
162
169
  ```ts
163
170
  const run = await session.factory.resume(runId, {
164
171
  limits: { maxAiCredits: 6 },
172
+ notifyOnComplete: true,
173
+ logPhaseNames: true,
165
174
  });
166
175
  ```
167
176
 
@@ -170,10 +179,16 @@ The signature is:
170
179
  ```ts
171
180
  session.factory.resume(
172
181
  runId: string,
173
- options?: { limits?: FactoryLimits },
182
+ options?: {
183
+ limits?: FactoryLimits;
184
+ notifyOnComplete?: boolean;
185
+ logPhaseNames?: boolean;
186
+ },
174
187
  ): Promise<FactoryRunResult>;
175
188
  ```
176
189
 
190
+ Set `notifyOnComplete` to `true` for factories that are likely to be invoked by an agent, so the originating session is notified when the factory completes. Set it to `false` for factories intended to be invoked programmatically, where the caller awaits the result directly. Set `logPhaseNames` to emit factory phase names to the session transcript. Both options apply to new and resumed runs.
191
+
177
192
  Both resolve with the run envelope (`FactoryRunResult`) for **every** outcome — `completed`, `error`, `halted`, and `cancelled` alike. Inspect `status` and read `result` only when the run completed; a limit breach carries a typed `failure`. SDK-initiated `run` and `resume` do not request permission, so they have no declined outcome. The model's `run_factory` tool requests permission before the durable row exists; declining it creates no run row. An SDK-initiated run is refused only when the session already has its maximum number of active top-level runs. Pre-execution resume failures throw `FactoryResumeError`, whose `code` is one of `not_found`, `non_resumable`, `already_active`, `factory_already_running`, `factory_limits_invalid`, `factory_session_disposed`, `factory_storage_unavailable`, or `factory_storage_corrupt`.
178
193
 
179
194
  An agent that no longer has a prior run's ID in context can recover it with `factories_manage` and `operation: "runs"`, which lists the session's factory runs with their IDs and statuses. This matters for resume: a run that reached a limit keeps its journal, so resuming it replays completed work for free, while restarting it from scratch pays for that work twice.
@@ -219,8 +234,13 @@ The calling session can inspect its own factory runs:
219
234
 
220
235
  ```ts
221
236
  const runs = await session.factory.listRuns();
237
+ const runsPage = await session.factory.listRuns({
238
+ afterSeq,
239
+ beforeSeq,
240
+ limit,
241
+ });
222
242
  const detail = await session.factory.getRunDetail(runId);
223
- const page = await session.factory.getRunProgress(runId, {
243
+ const progressPage = await session.factory.getRunProgress(runId, {
224
244
  phaseId,
225
245
  afterSeq,
226
246
  beforeSeq,
@@ -228,7 +248,8 @@ const page = await session.factory.getRunProgress(runId, {
228
248
  });
229
249
  ```
230
250
 
231
- - `listRuns()` returns the newest default page of this session's durable factory runs.
251
+ - `listRuns()` returns only the runs array from the newest default page of this session's durable factory runs. This overload preserves the original convenience API.
252
+ - `listRuns({ afterSeq, beforeSeq, limit })` returns the full page. Its `oldestSeq`, `newestSeq`, `hasMoreNewer`, and `omittedOlder` fields let callers continue paging without raw RPC calls.
232
253
  - `getRunDetail(runId)` returns phases, prompt-safe agent summaries, and the latest progress page.
233
254
  - `getRunProgress(runId, options?)` pages progress forward, backward, by phase, or from the latest tail.
234
255
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/github/copilot-sdk.git"
6
6
  },
7
- "version": "1.0.13-preview.2",
7
+ "version": "1.0.13-preview.4",
8
8
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
9
9
  "main": "./dist/cjs/index.js",
10
10
  "types": "./dist/index.d.ts",
@@ -56,7 +56,7 @@
56
56
  "author": "GitHub",
57
57
  "license": "MIT",
58
58
  "dependencies": {
59
- "@github/copilot": "^1.0.82-0",
59
+ "@github/copilot": "^1.0.83-0",
60
60
  "koffi": "^3.1.0",
61
61
  "vscode-jsonrpc": "^8.2.1",
62
62
  "zod": "^4.3.6"