@github/copilot-sdk 1.0.23-preview.0 → 1.0.23-preview.2

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.
@@ -733,6 +733,22 @@ function createServerRpc(connection) {
733
733
  * @returns Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
734
734
  */
735
735
  search: async (params) => connection.sendRequest("catalog.search", params),
736
+ /**
737
+ * Retrieves one saved feed by its opaque ID, optionally filtered by trust tier. Requires catalog-feeds and catalog-search-credential-required, and uses the same authority, credential policy, optional session binding and candidate projection as catalog.search, so available entries are the same inert candidates, with the same installability, handles and display metadata, and install through the same confirmed flows. Entries keep the feed's order; an entry the runtime cannot present is returned as unavailable with a reason rather than failing the feed. No anonymous retry. Read-only: nothing is installed, configured, or persisted.
738
+ *
739
+ * @param params Retrieves one saved feed by its opaque ID. Requires catalog-feeds and catalog-search-credential-required; add catalog-search-session-bound with policySessionId to retain the selected session's authority for installation, exactly as for catalog.search.
740
+ *
741
+ * @returns Outcome of catalog.getSavedFeed: the feed with its entries, or one typed refusal. An entry that cannot be presented never fails the feed.
742
+ */
743
+ getSavedFeed: async (params) => connection.sendRequest("catalog.getSavedFeed", params),
744
+ /**
745
+ * Retrieves one generated feed by strategy and key, such as telemetry/popular, optionally filtered by trust tier. Requires catalog-feeds and catalog-search-credential-required, and uses the same authority, credential policy, optional session binding and candidate projection as catalog.search, so available entries are the same inert candidates, with the same installability, handles and display metadata, and install through the same confirmed flows. Entries keep the feed's order; an entry the runtime cannot present is returned as unavailable with a reason rather than failing the feed. No anonymous retry. Read-only: nothing is installed, configured, or persisted.
746
+ *
747
+ * @param params Retrieves one generated feed, computed on every request, by strategy and key, such as `telemetry` and `popular`. Requires catalog-feeds and catalog-search-credential-required; add catalog-search-session-bound with policySessionId to retain the selected session's authority for installation, exactly as for catalog.search.
748
+ *
749
+ * @returns Outcome of catalog.getGeneratedFeed: the feed with its entries, or one typed refusal. An entry that cannot be presented never fails the feed.
750
+ */
751
+ getGeneratedFeed: async (params) => connection.sendRequest("catalog.getGeneratedFeed", params),
736
752
  /**
737
753
  * Terminates one retained catalog selection group. A selected outcome returns the native host a fresh single-use candidate handle plus the original searchId for a later explicit mcp.planInstall call; non-selected outcomes release the group without producing a planning input. Candidate state, cards, URLs, credentials and private identifiers remain inside the runtime. The model-facing catalog_select tool projects the result separately and never exposes the candidate handle or searchId.
738
754
  *
@@ -2128,7 +2144,7 @@ function createSessionRpc(connection, sessionId) {
2128
2144
  /**
2129
2145
  * Begin an interactive login flow for a provider kind (dispatch is kind-only) and return its opaque flow id and first step.
2130
2146
  *
2131
- * @param params Begin an interactive login flow for a provider kind. Dispatch is kind-only.
2147
+ * @param params Begin an interactive login flow for a provider kind, optionally reusing a cached base identity or explicitly requesting provider account selection.
2132
2148
  *
2133
2149
  * @returns A started login flow: its opaque id and first step.
2134
2150
  */
@@ -2727,6 +2743,14 @@ function createSessionRpc(connection, sessionId) {
2727
2743
  * @returns Progress information for the task, or null when no task with that ID is tracked.
2728
2744
  */
2729
2745
  getProgress: async (params) => connection.sendRequest("session.tasks.getProgress", { ...params, sessionId }),
2746
+ /**
2747
+ * Reads a detached shell task's output after a cursor, optionally waiting for new output or for the shell to finish.
2748
+ *
2749
+ * @param params Detached shell task to read output from, with an optional cursor and long-poll wait. waitMs defaults to zero (maximum 30000).
2750
+ *
2751
+ * @returns Output a detached shell task wrote after the request cursor, with the cursor for the next read.
2752
+ */
2753
+ readOutput: async (params) => connection.sendRequest("session.tasks.readOutput", { ...params, sessionId }),
2730
2754
  /**
2731
2755
  * Returns the first sync-waiting task that can currently be promoted to background mode.
2732
2756
  *
@@ -3907,6 +3907,10 @@ export interface CompactionStartEvent {
3907
3907
  * Context window breakdown at the start of LLM-powered conversation compaction
3908
3908
  */
3909
3909
  export interface CompactionStartData {
3910
+ /**
3911
+ * Identifier shared with the matching compaction completion event
3912
+ */
3913
+ compactionAttemptId?: string;
3910
3914
  /**
3911
3915
  * Token count from non-system messages (user, assistant, tool) at compaction start
3912
3916
  */
@@ -3919,10 +3923,18 @@ export interface CompactionStartData {
3919
3923
  * Model identifier used for compaction, when known
3920
3924
  */
3921
3925
  model?: string;
3926
+ /**
3927
+ * Destination model for a model-switch compaction when it differs from the compacting model
3928
+ */
3929
+ switchTargetModel?: string;
3922
3930
  /**
3923
3931
  * Token count from system message(s) at compaction start
3924
3932
  */
3925
3933
  systemTokens?: number;
3934
+ /**
3935
+ * Destination prompt-token budget when it differs from the effective compaction token limit
3936
+ */
3937
+ targetPromptTokenLimit?: number;
3926
3938
  /**
3927
3939
  * Model context window token limit the compaction is targeting, when known
3928
3940
  */
@@ -3979,6 +3991,10 @@ export interface CompactionCompleteData {
3979
3991
  * File path where the checkpoint was stored
3980
3992
  */
3981
3993
  checkpointPath?: string;
3994
+ /**
3995
+ * Identifier shared with the matching compaction start event
3996
+ */
3997
+ compactionAttemptId?: string;
3982
3998
  compactionTokensUsed?: CompactionCompleteCompactionTokensUsed;
3983
3999
  /**
3984
4000
  * Token count from non-system messages (user, assistant, tool) after compaction
@@ -3992,10 +4008,30 @@ export interface CompactionCompleteData {
3992
4008
  * Error message if compaction failed
3993
4009
  */
3994
4010
  error?: string;
4011
+ /**
4012
+ * Bounded reason for a typed failed outcome. Unknown future values are preserved.
4013
+ */
4014
+ failureReason?: string;
4015
+ /**
4016
+ * Model identifier at admission when routing later changed to the reported compaction model
4017
+ */
4018
+ initialModel?: string;
3995
4019
  /**
3996
4020
  * Number of messages removed during compaction
3997
4021
  */
3998
4022
  messagesRemoved?: number;
4023
+ /**
4024
+ * Model identifier used for compaction when provider usage does not already supply it
4025
+ */
4026
+ model?: string;
4027
+ /**
4028
+ * Typed terminal outcome for this observed compaction completion. Unknown future values are preserved.
4029
+ */
4030
+ outcome?: string;
4031
+ /**
4032
+ * Bounded reason for an expected non-application outcome such as cancellation or no applicable history. Unknown future values are preserved.
4033
+ */
4034
+ outcomeReason?: string;
3999
4035
  /**
4000
4036
  * Total tokens in conversation after compaction
4001
4037
  */
@@ -4029,10 +4065,22 @@ export interface CompactionCompleteData {
4029
4065
  * LLM-generated summary of the compacted conversation history
4030
4066
  */
4031
4067
  summaryContent?: string;
4068
+ /**
4069
+ * Destination model for a model-switch compaction when it differs from the compacting model
4070
+ */
4071
+ switchTargetModel?: string;
4032
4072
  /**
4033
4073
  * Token count from system message(s) after compaction
4034
4074
  */
4035
4075
  systemTokens?: number;
4076
+ /**
4077
+ * Destination prompt-token budget when it differs from the effective compaction token limit
4078
+ */
4079
+ targetPromptTokenLimit?: number;
4080
+ /**
4081
+ * Open accounting-basis identifier for trustworthy paired pre/post token measurements. The current runtime emits local_full_context_estimate.
4082
+ */
4083
+ tokenAccountingBasis?: string;
4036
4084
  /**
4037
4085
  * Model context window token limit the compaction was targeting, when known
4038
4086
  */
@@ -7396,6 +7444,12 @@ export interface ToolShellOutputEvent {
7396
7444
  * Live, append-only shell output. Not persisted or replayed to late subscribers. Text is decoded and redacted per chunk; chunks need not contain complete lines.
7397
7445
  */
7398
7446
  export interface ToolShellOutputData {
7447
+ /**
7448
+ * Experimental HydraFusion attribution of the staged phase whose tool call produced this output. Absent outside a staged phase.
7449
+ *
7450
+ * @experimental
7451
+ */
7452
+ fusion?: FusionAttribution;
7399
7453
  /**
7400
7454
  * Zero-based publication sequence across all output streams for this tool call. Not a byte offset or an OS write-order guarantee.
7401
7455
  */
@@ -7559,6 +7613,12 @@ export interface ToolExecutionCompleteData {
7559
7613
  toolTelemetry?: {
7560
7614
  [k: string]: JsonValue | undefined;
7561
7615
  };
7616
+ /**
7617
+ * Provider-reported usage of a separately metered runtime-owned tool operation, independent of the conversation model. Present on success or failure when usage is known. Experimental.
7618
+ *
7619
+ * @experimental
7620
+ */
7621
+ toolUsage?: ToolExecutionUsage;
7562
7622
  /**
7563
7623
  * Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
7564
7624
  */
@@ -8071,6 +8131,50 @@ export interface ToolExecutionCompleteToolDescriptionMetaUI {
8071
8131
  */
8072
8132
  visibility?: ToolExecutionCompleteToolDescriptionMetaUIVisibility[];
8073
8133
  }
8134
+ /**
8135
+ * Authoritative usage reported by a separately metered runtime-owned tool operation. May be present on a failed tool when the service reported usage before local result processing failed. Missing token counts or billing mean unavailable, not zero.
8136
+ */
8137
+ /** @experimental */
8138
+ export interface ToolExecutionUsage {
8139
+ accounting?: UsageAccountingIdentity;
8140
+ copilotUsage?: AssistantUsageCopilotUsage;
8141
+ /**
8142
+ * Total provider-reported input tokens across all modalities.
8143
+ */
8144
+ inputTokens?: number;
8145
+ inputTokensDetails?: ToolExecutionUsageTokenDetails;
8146
+ /**
8147
+ * Requested model for the tool operation, independent of the conversation model. Not a provider-confirmed serving model.
8148
+ */
8149
+ model: string;
8150
+ /**
8151
+ * Total provider-reported output tokens across all modalities.
8152
+ */
8153
+ outputTokens?: number;
8154
+ outputTokensDetails?: ToolExecutionUsageTokenDetails;
8155
+ provider?: ModelProviderRef;
8156
+ /**
8157
+ * Runtime-generated identifier for this metered operation. Deduplicates repeated delivery or replay; not an upstream billing identifier.
8158
+ */
8159
+ requestId: string;
8160
+ /**
8161
+ * Provider-reported sum of input and output tokens.
8162
+ */
8163
+ totalTokens?: number;
8164
+ }
8165
+ /**
8166
+ * Provider-reported image and text token counts, which are subsets of the corresponding total rather than additional tokens.
8167
+ */
8168
+ export interface ToolExecutionUsageTokenDetails {
8169
+ /**
8170
+ * Image tokens included in the corresponding input or output total.
8171
+ */
8172
+ imageTokens: number;
8173
+ /**
8174
+ * Text tokens included in the corresponding input or output total.
8175
+ */
8176
+ textTokens: number;
8177
+ }
8074
8178
  /**
8075
8179
  * Session event "tool_search.activated". Persisted generic client-side tool activations restored when a session resumes.
8076
8180
  */
@@ -9182,6 +9286,12 @@ export interface PermissionRequestedEvent {
9182
9286
  */
9183
9287
  export interface PermissionRequestedData {
9184
9288
  agentMode?: SessionMode;
9289
+ /**
9290
+ * Experimental HydraFusion attribution of the staged phase whose tool call raised this request. Absent outside a staged phase.
9291
+ *
9292
+ * @experimental
9293
+ */
9294
+ fusion?: FusionAttribution;
9185
9295
  /**
9186
9296
  * Delegated agent that owns permission recovery when the owner session multiplexes remote agents. Absent otherwise.
9187
9297
  */
package/dist/session.js CHANGED
@@ -825,12 +825,12 @@ class CopilotSession {
825
825
  }
826
826
  }
827
827
  } else if (event.type === "permission.requested") {
828
- const { requestId, permissionRequest, resolvedByHook } = event.data;
828
+ const { requestId, permissionRequest, promptRequest, resolvedByHook } = event.data;
829
829
  if (resolvedByHook) {
830
830
  return;
831
831
  }
832
832
  if (this.permissionHandler) {
833
- void this._executePermissionAndRespond(requestId, permissionRequest);
833
+ void this._executePermissionAndRespond(requestId, permissionRequest, promptRequest);
834
834
  }
835
835
  } else if (event.type === "mcp.oauth_required") {
836
836
  const data = event.data;
@@ -989,12 +989,14 @@ class CopilotSession {
989
989
  * Executes a permission handler and sends the result back via RPC.
990
990
  * @internal
991
991
  */
992
- async _executePermissionAndRespond(requestId, permissionRequest) {
992
+ async _executePermissionAndRespond(requestId, permissionRequest, promptRequest) {
993
993
  try {
994
- const handlerResult = await this.permissionHandler(permissionRequest, {
994
+ const invocation = {
995
995
  sessionId: this.sessionId,
996
- managedSettingsEnabled: this.managedSettingsEnabled
997
- });
996
+ managedSettingsEnabled: this.managedSettingsEnabled,
997
+ ...promptRequest === void 0 ? {} : { promptRequest }
998
+ };
999
+ const handlerResult = await this.permissionHandler(permissionRequest, invocation);
998
1000
  const isAttributed = isAttributedPermissionResult(handlerResult);
999
1001
  const result = isAttributed ? handlerResult.result : handlerResult;
1000
1002
  const decisionContext = isAttributed ? handlerResult.decisionContext : void 0;
package/dist/types.d.ts CHANGED
@@ -988,10 +988,11 @@ import type { PermissionDecisionRequest, PermissionDecisionContext } from "./gen
988
988
  * access the variant-specific fields (e.g. shell `commands`, write
989
989
  * `fileName`/`diff`, mcp `toolName`/`args`).
990
990
  *
991
- * `managedApprovalRequired` indicates that managed policy requires an explicit
992
- * user decision. Hosts should bypass automatic approval and present their
993
- * normal confirmation UI. The runtime currently emits it for managed Shell,
994
- * Read, Edit, and Domain selector asks.
991
+ * On the raw `permissionRequest`, `managedApprovalRequired` preserves managed
992
+ * policy provenance and one-shot restrictions. To determine whether a human
993
+ * response is still required, hosts should prefer
994
+ * `event.data.promptRequest?.managedApprovalRequired` when `promptRequest` is
995
+ * present, and fall back to the raw marker for older runtimes.
995
996
  */
996
997
  export type PermissionRequest = GeneratedPermissionRequest & {
997
998
  readonly managedApprovalRequired?: boolean;
@@ -1036,10 +1037,23 @@ export declare function isAttributedPermissionResult(result: PermissionRequestRe
1036
1037
  * permission behavior.
1037
1038
  */
1038
1039
  export declare function createAttributedPermissionResult(result: PermissionRequestResult | AttributedPermissionResult, decisionContext: PermissionDecisionContext): AttributedPermissionResult;
1039
- export type PermissionHandler = (request: PermissionRequest, invocation: {
1040
+ /**
1041
+ * Context supplied with a permission request callback.
1042
+ */
1043
+ export interface PermissionHandlerInvocation {
1040
1044
  sessionId: string;
1041
1045
  managedSettingsEnabled?: boolean;
1042
- }) => Promise<PermissionRequestResult | AttributedPermissionResult> | PermissionRequestResult | AttributedPermissionResult;
1046
+ /**
1047
+ * Derived user-facing prompt context when supplied by the runtime.
1048
+ *
1049
+ * Managed requests retain their raw `managedApprovalRequired` marker. Only
1050
+ * standard prompt kinds (`commands`, `read`, `write`, `url`, and
1051
+ * `workflow`) can clear that human requirement after Assisted approval.
1052
+ * For missing or other prompt kinds, keep the raw marker authoritative.
1053
+ */
1054
+ promptRequest?: PermissionRequestedData["promptRequest"];
1055
+ }
1056
+ export type PermissionHandler = (request: PermissionRequest, invocation: PermissionHandlerInvocation) => Promise<PermissionRequestResult | AttributedPermissionResult> | PermissionRequestResult | AttributedPermissionResult;
1043
1057
  /**
1044
1058
  * Approves permission requests when managed settings are disabled.
1045
1059
  */
package/package.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "url": "https://github.com/github/copilot-agent-runtime.git",
6
6
  "directory": "src/sdk/nodejs"
7
7
  },
8
- "version": "1.0.23-preview.0",
9
- "copilotCliVersion": "1.0.99-0",
8
+ "version": "1.0.23-preview.2",
9
+ "copilotCliVersion": "1.0.99-2",
10
10
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
11
11
  "main": "./dist/cjs/index.js",
12
12
  "types": "./dist/index.d.ts",
@@ -54,6 +54,7 @@
54
54
  "generate": "cd ../scripts/codegen && npm run generate",
55
55
  "set:cli-version": "node scripts/set-cli-version.js",
56
56
  "update:protocol-version": "tsx scripts/update-protocol-version.ts",
57
+ "vendor:tools": "tsx scripts/vendor-build-tools.ts",
57
58
  "prepublishOnly": "npm run build",
58
59
  "package": "npm run clean && npm run build && node scripts/set-version.js && npm run pack:release && npm version 0.0.0-dev --no-git-tag-version --allow-same-version"
59
60
  },
@@ -81,19 +82,26 @@
81
82
  "@typescript-eslint/parser": "^8.54.0",
82
83
  "esbuild": "^0.28.1",
83
84
  "eslint": "^9.0.0",
85
+ "file-entry-cache": "file:./scripts/eslint-file-cache",
84
86
  "glob": "^13.0.1",
85
87
  "hpke-js": "^1.8.0",
86
88
  "json-schema": "^0.4.0",
87
89
  "json-schema-to-typescript": "^15.0.4",
88
- "prettier": "^3.8.1",
90
+ "prettier": "file:../../../third_party/build-tools/prettier-3.8.1",
89
91
  "rimraf": "^6.1.2",
90
92
  "semver": "^7.7.3",
91
93
  "tar": "^7.5.22",
92
- "tsx": "^4.20.6",
94
+ "tsx": "file:../../../third_party/build-tools/tsx-4.22.4",
93
95
  "typescript": "^5.0.0",
96
+ "vite": "file:../../../third_party/build-tools/vite-8.3.4",
94
97
  "vitest": "^4.1.11",
95
98
  "ws": "^8.21.0"
96
99
  },
100
+ "overrides": {
101
+ "file-entry-cache": "$file-entry-cache",
102
+ "prettier": "$prettier",
103
+ "vite": "$vite"
104
+ },
97
105
  "engines": {
98
106
  "node": "^20.19.0 || >=22.12.0"
99
107
  },
@@ -104,18 +112,18 @@
104
112
  "README.md"
105
113
  ],
106
114
  "copilotRuntime": {
107
- "sourceSha": "1911cf98510f24398cbeeb739a76d9b12b0c74dc",
108
- "version": "1.0.99-0",
115
+ "sourceSha": "c9e96f9dbdbbce59d7e045d5abc3590136576cf7",
116
+ "version": "1.0.99-2",
109
117
  "visibility": "public"
110
118
  },
111
119
  "optionalDependencies": {
112
- "@github/copilot-sdk-darwin-arm64": "1.0.23-preview.0",
113
- "@github/copilot-sdk-darwin-x64": "1.0.23-preview.0",
114
- "@github/copilot-sdk-linux-arm64": "1.0.23-preview.0",
115
- "@github/copilot-sdk-linux-x64": "1.0.23-preview.0",
116
- "@github/copilot-sdk-linuxmusl-arm64": "1.0.23-preview.0",
117
- "@github/copilot-sdk-linuxmusl-x64": "1.0.23-preview.0",
118
- "@github/copilot-sdk-win32-arm64": "1.0.23-preview.0",
119
- "@github/copilot-sdk-win32-x64": "1.0.23-preview.0"
120
+ "@github/copilot-sdk-darwin-arm64": "1.0.23-preview.2",
121
+ "@github/copilot-sdk-darwin-x64": "1.0.23-preview.2",
122
+ "@github/copilot-sdk-linux-arm64": "1.0.23-preview.2",
123
+ "@github/copilot-sdk-linux-x64": "1.0.23-preview.2",
124
+ "@github/copilot-sdk-linuxmusl-arm64": "1.0.23-preview.2",
125
+ "@github/copilot-sdk-linuxmusl-x64": "1.0.23-preview.2",
126
+ "@github/copilot-sdk-win32-arm64": "1.0.23-preview.2",
127
+ "@github/copilot-sdk-win32-x64": "1.0.23-preview.2"
120
128
  }
121
129
  }