@github/copilot-sdk 1.0.13-preview.1 → 1.0.13-preview.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -2
- package/dist/cjs/client.js +97 -4
- package/dist/cjs/generated/rpc.js +29 -1
- package/dist/cjs/session.js +29 -5
- package/dist/client.d.ts +5 -0
- package/dist/client.js +97 -4
- package/dist/extension.d.ts +1 -1
- package/dist/factory.d.ts +35 -1
- package/dist/generated/rpc.d.ts +83 -11
- package/dist/generated/rpc.js +29 -1
- package/dist/generated/session-events.d.ts +1081 -235
- package/dist/index.d.ts +2 -2
- package/dist/session.d.ts +1 -0
- package/dist/session.js +29 -5
- package/dist/types.d.ts +43 -5
- package/docs/factories.md +25 -4
- package/package.json +2 -2
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, 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, 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";
|
package/dist/session.d.ts
CHANGED
package/dist/session.js
CHANGED
|
@@ -223,6 +223,7 @@ class CopilotSession {
|
|
|
223
223
|
this.traceContextProvider = traceContextProvider;
|
|
224
224
|
this.mcpAuthHandler = options?.mcpAuthHandler;
|
|
225
225
|
this.managedSettingsEnabled = options?.managedSettingsEnabled === true;
|
|
226
|
+
this.onDisconnected = options?.onDisconnected;
|
|
226
227
|
}
|
|
227
228
|
sessionId;
|
|
228
229
|
connection;
|
|
@@ -249,6 +250,7 @@ class CopilotSession {
|
|
|
249
250
|
_capabilities = {};
|
|
250
251
|
openCanvasInstances = [];
|
|
251
252
|
disconnected = false;
|
|
253
|
+
onDisconnected;
|
|
252
254
|
/** @internal Client session API handlers, populated by CopilotClient during create/resume. */
|
|
253
255
|
clientSessionApis = {};
|
|
254
256
|
/**
|
|
@@ -263,14 +265,18 @@ class CopilotSession {
|
|
|
263
265
|
const name = typeof nameOrHandle === "string" ? nameOrHandle : getFactoryDefinition(nameOrHandle).meta.name;
|
|
264
266
|
if (options?.resumeFromRunId !== void 0) {
|
|
265
267
|
return this.factory.resume(options.resumeFromRunId, {
|
|
266
|
-
limits: options.limits
|
|
268
|
+
limits: options.limits,
|
|
269
|
+
notifyOnComplete: options.notifyOnComplete,
|
|
270
|
+
logPhaseNames: options.logPhaseNames
|
|
267
271
|
});
|
|
268
272
|
}
|
|
269
273
|
const envelope = await this.rpc.factory.run({
|
|
270
274
|
name,
|
|
271
275
|
args: options?.args === void 0 ? {} : options.args,
|
|
272
276
|
options: {
|
|
273
|
-
limits: options?.limits
|
|
277
|
+
limits: options?.limits,
|
|
278
|
+
notifyOnComplete: options?.notifyOnComplete,
|
|
279
|
+
logPhaseNames: options?.logPhaseNames
|
|
274
280
|
}
|
|
275
281
|
});
|
|
276
282
|
return this.settleFactoryRun(envelope);
|
|
@@ -281,7 +287,9 @@ class CopilotSession {
|
|
|
281
287
|
try {
|
|
282
288
|
response = await this.rpc.factory.resume({
|
|
283
289
|
runId,
|
|
284
|
-
limits: options?.limits
|
|
290
|
+
limits: options?.limits,
|
|
291
|
+
notifyOnComplete: options?.notifyOnComplete,
|
|
292
|
+
logPhaseNames: options?.logPhaseNames
|
|
285
293
|
});
|
|
286
294
|
} catch (error) {
|
|
287
295
|
if (error instanceof ResponseError && typeof error.data === "object" && error.data !== null) {
|
|
@@ -296,7 +304,10 @@ class CopilotSession {
|
|
|
296
304
|
}),
|
|
297
305
|
getRun: async (runId) => this.rpc.factory.getRun({ runId }),
|
|
298
306
|
waitForRun: (runId, options) => this.waitForFactoryRun(runId, options?.signal),
|
|
299
|
-
listRuns: async () =>
|
|
307
|
+
listRuns: (async (options) => {
|
|
308
|
+
const page = await this.rpc.factory.listRuns(options ?? {});
|
|
309
|
+
return options === void 0 ? page.runs : page;
|
|
310
|
+
}),
|
|
300
311
|
getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
|
|
301
312
|
getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
|
|
302
313
|
cancel: async (runId) => this.rpc.factory.cancel({ runId })
|
|
@@ -457,7 +468,7 @@ class CopilotSession {
|
|
|
457
468
|
const unsubscribe = this.on((event) => {
|
|
458
469
|
if (event.type === "assistant.message") {
|
|
459
470
|
lastAssistantMessage = event;
|
|
460
|
-
} else if (event.type === "session.idle") {
|
|
471
|
+
} else if (event.type === "session.idle" && event.data.mode !== "autopilot") {
|
|
461
472
|
resolveOutcome({ kind: "idle" });
|
|
462
473
|
} else if (event.type === "session.error") {
|
|
463
474
|
const error = new Error(event.data.message);
|
|
@@ -492,7 +503,11 @@ class CopilotSession {
|
|
|
492
503
|
}
|
|
493
504
|
/** @internal */
|
|
494
505
|
_markDisconnected() {
|
|
506
|
+
if (this.disconnected) {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
495
509
|
this.disconnected = true;
|
|
510
|
+
this._runOnDisconnected();
|
|
496
511
|
this.eventHandlers.clear();
|
|
497
512
|
this.typedEventHandlers.clear();
|
|
498
513
|
this.toolHandlers.clear();
|
|
@@ -512,6 +527,15 @@ class CopilotSession {
|
|
|
512
527
|
this.factoryAbortControllers.clear();
|
|
513
528
|
this.transformCallbacks?.clear();
|
|
514
529
|
}
|
|
530
|
+
/** @internal */
|
|
531
|
+
_runOnDisconnected() {
|
|
532
|
+
this.onDisconnected?.();
|
|
533
|
+
this.onDisconnected = void 0;
|
|
534
|
+
}
|
|
535
|
+
/** @internal */
|
|
536
|
+
_setOnDisconnected(callback) {
|
|
537
|
+
this.onDisconnected = callback;
|
|
538
|
+
}
|
|
515
539
|
on(eventTypeOrHandler, handler) {
|
|
516
540
|
if (typeof eventTypeOrHandler === "string" && handler) {
|
|
517
541
|
const eventType = eventTypeOrHandler;
|
package/dist/types.d.ts
CHANGED
|
@@ -7,11 +7,29 @@ import type { CopilotRequestHandler } from "./copilotRequestHandler.js";
|
|
|
7
7
|
import type { PermissionRequest as GeneratedPermissionRequest, PermissionRequestedData as GeneratedPermissionRequestedData, PermissionRequestedEvent as GeneratedPermissionRequestedEvent, ReasoningSummary, SessionLimitsConfig, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
|
|
8
8
|
import type { CopilotSession } from "./session.js";
|
|
9
9
|
import type { FactoryJsonSchema, JsonValue } from "./factory.js";
|
|
10
|
-
import type { GitHubTelemetryNotification, ModelBillingTokenPrices, OpenCanvasInstance, RemoteSessionMode, CurrentToolMetadata } from "./generated/rpc.js";
|
|
10
|
+
import type { GitHubTokenAcquireRequest, GitHubTokenAcquireResult, GitHubTelemetryNotification, ModelBillingTokenPrices, OpenCanvasInstance, RemoteSessionMode, CurrentToolMetadata } from "./generated/rpc.js";
|
|
11
11
|
import type { ToolSet } from "./toolSet.js";
|
|
12
12
|
export type { RemoteSessionMode } from "./generated/rpc.js";
|
|
13
13
|
export type { CurrentToolMetadata } from "./generated/rpc.js";
|
|
14
|
-
export type { GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, } from "./generated/rpc.js";
|
|
14
|
+
export type { GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, } from "./generated/rpc.js";
|
|
15
|
+
/**
|
|
16
|
+
* Arguments passed to a session's {@link GitHubTokenProvider}.
|
|
17
|
+
*
|
|
18
|
+
* The callback registration identifier is intentionally kept inside the SDK.
|
|
19
|
+
*/
|
|
20
|
+
export type GitHubTokenProviderArgs = Pick<GitHubTokenAcquireRequest, "host" | "sessionId" | "reason">;
|
|
21
|
+
/** Tagged token or cancellation returned by a {@link GitHubTokenProvider}. */
|
|
22
|
+
export type GitHubTokenProviderResult = GitHubTokenAcquireResult;
|
|
23
|
+
/**
|
|
24
|
+
* Acquires a GitHub token for one session.
|
|
25
|
+
*
|
|
26
|
+
* A token result must include `expiresIn`: the positive number of seconds of
|
|
27
|
+
* remaining lifetime when the callback completes. Production GitHub tokens
|
|
28
|
+
* typically last eight hours. Initial cancellation, callback errors, and
|
|
29
|
+
* invalid token responses reject session creation or resume instead of falling
|
|
30
|
+
* back to ambient authentication.
|
|
31
|
+
*/
|
|
32
|
+
export type GitHubTokenProvider = (args: GitHubTokenProviderArgs) => GitHubTokenProviderResult | Promise<GitHubTokenProviderResult>;
|
|
15
33
|
export type { ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, } from "./generated/rpc.js";
|
|
16
34
|
export type SessionEvent = Exclude<GeneratedSessionEvent, {
|
|
17
35
|
type: "permission.requested";
|
|
@@ -27,7 +45,7 @@ export type { SessionFsSqliteStatement } from "./sessionFsProvider.js";
|
|
|
27
45
|
export type { SessionFsSqliteTransactionErrorClass } from "./sessionFsProvider.js";
|
|
28
46
|
export { SessionFsSqliteTransactionFailure } from "./sessionFsProvider.js";
|
|
29
47
|
export type { LlmInferenceHeaders } from "./generated/rpc.js";
|
|
30
|
-
export type { PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, } from "./generated/rpc.js";
|
|
48
|
+
export type { PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, } from "./generated/rpc.js";
|
|
31
49
|
export type { CopilotRequestContext } from "./copilotRequestHandler.js";
|
|
32
50
|
export { CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, } from "./copilotRequestHandler.js";
|
|
33
51
|
/**
|
|
@@ -925,7 +943,7 @@ export type PermissionHandler = (request: PermissionRequest, invocation: {
|
|
|
925
943
|
export declare const approveAll: PermissionHandler;
|
|
926
944
|
export declare const defaultJoinSessionPermissionHandler: PermissionHandler;
|
|
927
945
|
/**
|
|
928
|
-
*
|
|
946
|
+
* Legacy question-and-answer request from the `ask_user` tool.
|
|
929
947
|
*/
|
|
930
948
|
export interface UserInputRequest {
|
|
931
949
|
/**
|
|
@@ -1795,6 +1813,8 @@ export interface ManagedSettings {
|
|
|
1795
1813
|
/** Managed permission policy for the session. */
|
|
1796
1814
|
permissions?: ManagedSettingsPermissions;
|
|
1797
1815
|
}
|
|
1816
|
+
/** Selects the model-facing shape of the built-in `ask_user` tool. */
|
|
1817
|
+
export type AskUserVariant = "legacy" | "elicitation";
|
|
1798
1818
|
/**
|
|
1799
1819
|
* Shared configuration fields used by both {@link SessionConfig} (for
|
|
1800
1820
|
* creating a new session) and {@link ResumeSessionConfig} (for resuming
|
|
@@ -2067,9 +2087,18 @@ export interface SessionConfigBase {
|
|
|
2067
2087
|
onMcpAuthRequest?: McpAuthHandler;
|
|
2068
2088
|
/**
|
|
2069
2089
|
* Handler for user input requests from the agent.
|
|
2070
|
-
* When provided
|
|
2090
|
+
* When provided with the default `legacy` {@link AskUserVariant}, enables the
|
|
2091
|
+
* question-and-answer form of the `ask_user` tool.
|
|
2071
2092
|
*/
|
|
2072
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;
|
|
2073
2102
|
/**
|
|
2074
2103
|
* Handler for elicitation requests from the agent.
|
|
2075
2104
|
* When provided, the server calls back to this client for form-based UI dialogs.
|
|
@@ -2237,6 +2266,15 @@ export interface SessionConfigBase {
|
|
|
2237
2266
|
* the identity used for content exclusion, model routing, and quota checks.
|
|
2238
2267
|
*/
|
|
2239
2268
|
gitHubToken?: string;
|
|
2269
|
+
/**
|
|
2270
|
+
* Acquires short-lived GitHub credentials for this session on demand.
|
|
2271
|
+
*
|
|
2272
|
+
* Mutually exclusive with {@link SessionConfigBase.gitHubToken}. The
|
|
2273
|
+
* callback receives the effective GitHub host, the session ID when known,
|
|
2274
|
+
* and whether this is the initial acquisition or a refresh. Its opaque
|
|
2275
|
+
* registration ID remains internal to the SDK.
|
|
2276
|
+
*/
|
|
2277
|
+
gitHubTokenProvider?: GitHubTokenProvider;
|
|
2240
2278
|
/**
|
|
2241
2279
|
* Opt-in: when true, the runtime self-fetches enterprise managed settings
|
|
2242
2280
|
* (bypass-permissions policy) at session bootstrap using the session's
|
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?: {
|
|
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?: {
|
|
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
|
|
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.
|
|
7
|
+
"version": "1.0.13-preview.3",
|
|
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.
|
|
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"
|