@github/copilot-sdk 1.0.22 → 1.0.23-preview.1
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 +22 -6
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +2 -1
- package/dist/cjs/copilotRequestHandler.js +17 -9
- package/dist/cjs/generated/rpc.js +96 -29
- package/dist/cjs/host.js +11 -1
- package/dist/cjs/session.js +8 -6
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.js +2 -1
- package/dist/copilotRequestHandler.d.ts +8 -2
- package/dist/copilotRequestHandler.js +17 -9
- package/dist/generated/rpc.d.ts +1163 -342
- package/dist/generated/rpc.js +96 -29
- package/dist/generated/session-events.d.ts +104 -0
- package/dist/host.d.ts +8 -1
- package/dist/host.js +11 -1
- package/dist/session.js +8 -6
- package/dist/types.d.ts +28 -6
- package/docs/agent-author.md +2 -0
- package/package.json +17 -12
package/dist/generated/rpc.js
CHANGED
|
@@ -173,6 +173,14 @@ function createServerRpc(connection) {
|
|
|
173
173
|
* @returns The existing runtime identity and its resource on the listener.
|
|
174
174
|
*/
|
|
175
175
|
publishSession: async (params) => connection.sendRequest("host.publishSession", params),
|
|
176
|
+
/**
|
|
177
|
+
* Withdraws a live or dormant application publication from an owned live host and revokes AHP attachments without deleting local session history, worktrees, or ongoing work. Returns false when already absent; rejects nonapplication publications.
|
|
178
|
+
*
|
|
179
|
+
* @param params Withdraws an application publication without deleting its underlying local session.
|
|
180
|
+
*
|
|
181
|
+
* @returns Publication withdrawal outcome; local history, worktrees and ongoing work are preserved.
|
|
182
|
+
*/
|
|
183
|
+
unpublishSession: async (params) => connection.sendRequest("host.unpublishSession", params),
|
|
176
184
|
/**
|
|
177
185
|
* Reads the complete advertised live and dormant session catalog of an existing host owned by this connection. Does not start hosting, subscribe to sessions, or guarantee resumability.
|
|
178
186
|
*
|
|
@@ -234,7 +242,15 @@ function createServerRpc(connection) {
|
|
|
234
242
|
*
|
|
235
243
|
* @returns The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
|
|
236
244
|
*/
|
|
237
|
-
getBuiltInCatalog: async () => connection.sendRequest("models.getBuiltInCatalog", {})
|
|
245
|
+
getBuiltInCatalog: async () => connection.sendRequest("models.getBuiltInCatalog", {}),
|
|
246
|
+
/**
|
|
247
|
+
* Reports the unit of each model's published token prices: AI Credits or nano-AIU. Pair these units with models.list prices by model ID and use identical account-selection options for both calls. When options are omitted, the current account and its model providers are used.
|
|
248
|
+
*
|
|
249
|
+
* @param params Optional opaque account selection or compatibility GitHub token used to list models.
|
|
250
|
+
*
|
|
251
|
+
* @returns Price units for every catalog model that publishes token prices.
|
|
252
|
+
*/
|
|
253
|
+
listTokenPriceUnits: async (params) => connection.sendRequest("models.listTokenPriceUnits", params)
|
|
238
254
|
},
|
|
239
255
|
/** @experimental */
|
|
240
256
|
contentExclusion: {
|
|
@@ -487,14 +503,6 @@ function createServerRpc(connection) {
|
|
|
487
503
|
* @returns Skill installation management result with the honoured contract, or a typed refusal.
|
|
488
504
|
*/
|
|
489
505
|
planInstall: async (params) => connection.sendRequest("skills.planInstall", params),
|
|
490
|
-
/**
|
|
491
|
-
* Plans installation of the Skill pinned by an Agent Finder materialisation reference without writing files. The runtime retrieves the descriptor only from its fixed Agent Finder authority and applies the same verification as skills.planInstall; the review shows only verified data. Apply the returned plan with skills.applyInstall.
|
|
492
|
-
*
|
|
493
|
-
* @param params Side-effect-free planning of one Skill from a materialisation reference rather than a search candidate.
|
|
494
|
-
*
|
|
495
|
-
* @returns Skill installation management result with the honoured contract, or a typed refusal.
|
|
496
|
-
*/
|
|
497
|
-
planInstallFromReference: async (params) => connection.sendRequest("skills.planInstallFromReference", params),
|
|
498
506
|
/**
|
|
499
507
|
* Consumes one verified Skill installation plan, requests explicit human consent through installations.confirm on the original connection, then revalidates and installs the Skill disabled.
|
|
500
508
|
*
|
|
@@ -594,33 +602,24 @@ function createServerRpc(connection) {
|
|
|
594
602
|
*/
|
|
595
603
|
getDiscoveryPaths: async (params) => connection.sendRequest("skills.getDiscoveryPaths", params)
|
|
596
604
|
},
|
|
597
|
-
/**
|
|
598
|
-
* Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime uses its built-in extension launcher.
|
|
599
|
-
*
|
|
600
|
-
* @experimental
|
|
601
|
-
*/
|
|
602
|
-
registerExtensionLaunchProvider: async () => connection.sendRequest("registerExtensionLaunchProvider", {}),
|
|
603
605
|
/** @experimental */
|
|
604
|
-
|
|
606
|
+
plugins: {
|
|
605
607
|
/**
|
|
606
|
-
*
|
|
608
|
+
* Plans installation of an Agent Plugin search candidate from its verified Agent Finder materialisation without writing files. Only candidates that carry a handle can be planned. The review shows only verified data, and installing leaves the plugin disabled until it is enabled through plugins.enable.
|
|
607
609
|
*
|
|
608
|
-
* @param params
|
|
610
|
+
* @param params Side-effect-free planning of one Agent Plugin search candidate through its Agent Finder materialisation.
|
|
609
611
|
*
|
|
610
|
-
* @returns
|
|
612
|
+
* @returns Agent Plugin installation planning result with the honoured contract, or a typed refusal.
|
|
611
613
|
*/
|
|
612
|
-
|
|
614
|
+
planInstall: async (params) => connection.sendRequest("plugins.planInstall", params),
|
|
613
615
|
/**
|
|
614
|
-
*
|
|
616
|
+
* Consumes one verified Agent Plugin installation plan, requests explicit human consent through installations.confirm on the original connection, then reacquires and verifies every file and registers the plugin, disabled, exactly as a direct plugin install. The installed plugin is listed, enabled and uninstalled through the existing plugins methods.
|
|
615
617
|
*
|
|
616
|
-
* @param params
|
|
618
|
+
* @param params Applies exactly one retained verified Agent Plugin installation plan.
|
|
617
619
|
*
|
|
618
|
-
* @returns
|
|
620
|
+
* @returns Agent Plugin installation result with the honoured contract, or a typed request/negotiation refusal.
|
|
619
621
|
*/
|
|
620
|
-
|
|
621
|
-
},
|
|
622
|
-
/** @experimental */
|
|
623
|
-
plugins: {
|
|
622
|
+
applyInstall: async (params) => connection.sendRequest("plugins.applyInstall", params),
|
|
624
623
|
/**
|
|
625
624
|
* Lists plugins installed in user/global state.
|
|
626
625
|
*
|
|
@@ -718,6 +717,39 @@ function createServerRpc(connection) {
|
|
|
718
717
|
refresh: async (params) => connection.sendRequest("plugins.marketplaces.refresh", params)
|
|
719
718
|
}
|
|
720
719
|
},
|
|
720
|
+
/**
|
|
721
|
+
* Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime uses its built-in extension launcher.
|
|
722
|
+
*
|
|
723
|
+
* @experimental
|
|
724
|
+
*/
|
|
725
|
+
registerExtensionLaunchProvider: async () => connection.sendRequest("registerExtensionLaunchProvider", {}),
|
|
726
|
+
/** @experimental */
|
|
727
|
+
catalog: {
|
|
728
|
+
/**
|
|
729
|
+
* Requests a bounded catalog search. This host-implemented server method is available through SDK/TUI hosts; standalone and C-ABI runtimes whose host does not implement server-method dispatch return JSON-RPC MethodNotFound. A runtime with search available returns inert candidate summaries, each with an opaque single-use handle scoped to this runtime instance; a runtime without it returns the typed search-unavailable result. Public authorities may be searched anonymously, while an authority that requires credentials yields the typed authentication-required result. All returned text, URLs, and package metadata are untrusted external data and can never trigger instructions, tools, or installation. Read-only: nothing is installed, configured, or persisted.
|
|
730
|
+
*
|
|
731
|
+
* @param params A bounded catalog search. Both the query length and the result count are capped by the schema so a caller cannot request an unbounded scan.
|
|
732
|
+
*
|
|
733
|
+
* @returns Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
|
|
734
|
+
*/
|
|
735
|
+
search: async (params) => connection.sendRequest("catalog.search", params),
|
|
736
|
+
/**
|
|
737
|
+
* 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
|
+
*
|
|
739
|
+
* @param params Terminates one retained catalog selection group through an opaque reference previously returned by the model-safe search projection.
|
|
740
|
+
*
|
|
741
|
+
* @returns Typed outcome of catalog.select. Only the selected host result carries a fresh candidate handle; the model-facing projection removes both that handle and searchId.
|
|
742
|
+
*/
|
|
743
|
+
select: async (params) => connection.sendRequest("catalog.select", params),
|
|
744
|
+
/**
|
|
745
|
+
* Plans installing the resource an Agent Finder materialisation reference pins, without writing files and whatever its kind. The runtime retrieves the descriptor once, only from its fixed Agent Finder authority, verifies it, and plans by its resolution policy: a Skill (`agent-skill@1.0.0`) when the caller requires skill-confirmed-installation, an Agent Plugin (`plugin@1.0.0`) when it requires agent-plugin-confirmed-installation. Any other kind is refused as unsupported-resource. The outcome names the kind; apply a Skill plan with skills.applyInstall and an Agent Plugin plan with plugins.applyInstall. The review shows only verified data.
|
|
746
|
+
*
|
|
747
|
+
* @param params Side-effect-free planning of whatever resource a materialisation reference pins, rather than a search candidate.
|
|
748
|
+
*
|
|
749
|
+
* @returns Planning result for a materialisation reference with the honoured contract, or a typed refusal.
|
|
750
|
+
*/
|
|
751
|
+
planInstallFromReference: async (params) => connection.sendRequest("catalog.planInstallFromReference", params)
|
|
752
|
+
},
|
|
721
753
|
/** @experimental */
|
|
722
754
|
agents: {
|
|
723
755
|
/**
|
|
@@ -1643,7 +1675,42 @@ function createInternalServerRpc(connection) {
|
|
|
1643
1675
|
*
|
|
1644
1676
|
* @returns Whether the gh-replaceable GitHub MCP tools may be clipped for the session described by the request.
|
|
1645
1677
|
*/
|
|
1646
|
-
shouldExcludeGitHubTools: async (params) => connection.sendRequest("mcp.shouldExcludeGitHubTools", params)
|
|
1678
|
+
shouldExcludeGitHubTools: async (params) => connection.sendRequest("mcp.shouldExcludeGitHubTools", params),
|
|
1679
|
+
/** @experimental */
|
|
1680
|
+
oauth: {
|
|
1681
|
+
/**
|
|
1682
|
+
* Reads the static OAuth client a remote MCP server configuration pins, so a host can decide whether to register a client dynamically or reuse the configured one. Omits `clientConfig` when no non-empty `oauthClientId` is configured. The client secret is deliberately never carried here: the runtime loads it from the OAuth secret store at flow time.
|
|
1683
|
+
*
|
|
1684
|
+
* @param params A remote MCP server configuration whose pinned OAuth client should be read.
|
|
1685
|
+
*
|
|
1686
|
+
* @returns The OAuth client the configuration pins, when it pins one.
|
|
1687
|
+
*/
|
|
1688
|
+
staticClientConfig: async (params) => connection.sendRequest("mcp.oauth.staticClientConfig", params),
|
|
1689
|
+
/**
|
|
1690
|
+
* Reads raw protected-resource metadata after a 401 establishes that OAuth is required. Uses the metadata URL from the server's `WWW-Authenticate` challenge when provided; otherwise, tries conventional metadata endpoints derived from the request URL. A host configuring a remote server interactively needs the unparsed document to classify the challenge before it starts OAuth. The request URL and each metadata URL pass through the named session's egress policy and sandbox proxy. The runtime refuses URLs that the session may not reach.
|
|
1691
|
+
*
|
|
1692
|
+
* @param params An OAuth challenge from a remote MCP server whose protected-resource metadata should be read.
|
|
1693
|
+
*
|
|
1694
|
+
* @returns Raw protected-resource metadata from the explicit metadata URL or conventional discovery.
|
|
1695
|
+
*/
|
|
1696
|
+
fetchProtectedResourceMetadata: async (params) => connection.sendRequest("mcp.oauth.fetchProtectedResourceMetadata", params),
|
|
1697
|
+
/**
|
|
1698
|
+
* Asks a remote MCP server's authorization server whether it supports Dynamic Client Registration, after a 401 has already established that OAuth is required. A host configuring a remote server interactively needs this to choose between registering a client automatically and asking the user for client credentials. The request travels through the named session's egress policy and sandbox proxy, so a server that session may not reach is refused rather than contacted.
|
|
1699
|
+
*
|
|
1700
|
+
* @param params A remote MCP server whose authorization server should be asked about Dynamic Client Registration.
|
|
1701
|
+
*
|
|
1702
|
+
* @returns Whether the server's authorization server registers clients dynamically.
|
|
1703
|
+
*/
|
|
1704
|
+
checkDcrSupport: async (params) => connection.sendRequest("mcp.oauth.checkDcrSupport", params),
|
|
1705
|
+
/**
|
|
1706
|
+
* Reports whether an authorization server URL belongs to Microsoft Entra ID. Entra does not support Dynamic Client Registration, so a host that finds no DCR support can still authorize against it with a pre-registered client instead of asking the user for client credentials.
|
|
1707
|
+
*
|
|
1708
|
+
* @param params An authorization server URL to classify.
|
|
1709
|
+
*
|
|
1710
|
+
* @returns Whether the URL is a Microsoft Entra ID authorization server.
|
|
1711
|
+
*/
|
|
1712
|
+
isMicrosoftAuthorizationServer: async (params) => connection.sendRequest("mcp.oauth.isMicrosoftAuthorizationServer", params)
|
|
1713
|
+
}
|
|
1647
1714
|
},
|
|
1648
1715
|
/** @experimental */
|
|
1649
1716
|
instructions: {
|
|
@@ -2061,7 +2128,7 @@ function createSessionRpc(connection, sessionId) {
|
|
|
2061
2128
|
/**
|
|
2062
2129
|
* Begin an interactive login flow for a provider kind (dispatch is kind-only) and return its opaque flow id and first step.
|
|
2063
2130
|
*
|
|
2064
|
-
* @param params Begin an interactive login flow for a provider kind
|
|
2131
|
+
* @param params Begin an interactive login flow for a provider kind, optionally reusing a cached base identity or explicitly requesting provider account selection.
|
|
2065
2132
|
*
|
|
2066
2133
|
* @returns A started login flow: its opaque id and first step.
|
|
2067
2134
|
*/
|
|
@@ -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
|
*/
|
|
@@ -4582,6 +4630,12 @@ export interface FusionResolvedData {
|
|
|
4582
4630
|
* Concrete model selected for Critique review, or the legacy Cascade judge/repair model when role-specific fields are absent.
|
|
4583
4631
|
*/
|
|
4584
4632
|
secondaryModel: string | null;
|
|
4633
|
+
/**
|
|
4634
|
+
* Identifier of the server policy rule whose workflow the plan's steps describe, when CAPI's sticky root routing replaced the workflow of `ruleId`'s rule to keep the previous turn's root model. Absent when no substitution occurred.
|
|
4635
|
+
*
|
|
4636
|
+
* @experimental
|
|
4637
|
+
*/
|
|
4638
|
+
selectedRuleId?: string;
|
|
4585
4639
|
/**
|
|
4586
4640
|
* Synthetic HydraFusion model selected for the session.
|
|
4587
4641
|
*/
|
|
@@ -7553,6 +7607,12 @@ export interface ToolExecutionCompleteData {
|
|
|
7553
7607
|
toolTelemetry?: {
|
|
7554
7608
|
[k: string]: JsonValue | undefined;
|
|
7555
7609
|
};
|
|
7610
|
+
/**
|
|
7611
|
+
* 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.
|
|
7612
|
+
*
|
|
7613
|
+
* @experimental
|
|
7614
|
+
*/
|
|
7615
|
+
toolUsage?: ToolExecutionUsage;
|
|
7556
7616
|
/**
|
|
7557
7617
|
* Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
|
|
7558
7618
|
*/
|
|
@@ -8065,6 +8125,50 @@ export interface ToolExecutionCompleteToolDescriptionMetaUI {
|
|
|
8065
8125
|
*/
|
|
8066
8126
|
visibility?: ToolExecutionCompleteToolDescriptionMetaUIVisibility[];
|
|
8067
8127
|
}
|
|
8128
|
+
/**
|
|
8129
|
+
* 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.
|
|
8130
|
+
*/
|
|
8131
|
+
/** @experimental */
|
|
8132
|
+
export interface ToolExecutionUsage {
|
|
8133
|
+
accounting?: UsageAccountingIdentity;
|
|
8134
|
+
copilotUsage?: AssistantUsageCopilotUsage;
|
|
8135
|
+
/**
|
|
8136
|
+
* Total provider-reported input tokens across all modalities.
|
|
8137
|
+
*/
|
|
8138
|
+
inputTokens?: number;
|
|
8139
|
+
inputTokensDetails?: ToolExecutionUsageTokenDetails;
|
|
8140
|
+
/**
|
|
8141
|
+
* Requested model for the tool operation, independent of the conversation model. Not a provider-confirmed serving model.
|
|
8142
|
+
*/
|
|
8143
|
+
model: string;
|
|
8144
|
+
/**
|
|
8145
|
+
* Total provider-reported output tokens across all modalities.
|
|
8146
|
+
*/
|
|
8147
|
+
outputTokens?: number;
|
|
8148
|
+
outputTokensDetails?: ToolExecutionUsageTokenDetails;
|
|
8149
|
+
provider?: ModelProviderRef;
|
|
8150
|
+
/**
|
|
8151
|
+
* Runtime-generated identifier for this metered operation. Deduplicates repeated delivery or replay; not an upstream billing identifier.
|
|
8152
|
+
*/
|
|
8153
|
+
requestId: string;
|
|
8154
|
+
/**
|
|
8155
|
+
* Provider-reported sum of input and output tokens.
|
|
8156
|
+
*/
|
|
8157
|
+
totalTokens?: number;
|
|
8158
|
+
}
|
|
8159
|
+
/**
|
|
8160
|
+
* Provider-reported image and text token counts, which are subsets of the corresponding total rather than additional tokens.
|
|
8161
|
+
*/
|
|
8162
|
+
export interface ToolExecutionUsageTokenDetails {
|
|
8163
|
+
/**
|
|
8164
|
+
* Image tokens included in the corresponding input or output total.
|
|
8165
|
+
*/
|
|
8166
|
+
imageTokens: number;
|
|
8167
|
+
/**
|
|
8168
|
+
* Text tokens included in the corresponding input or output total.
|
|
8169
|
+
*/
|
|
8170
|
+
textTokens: number;
|
|
8171
|
+
}
|
|
8068
8172
|
/**
|
|
8069
8173
|
* Session event "tool_search.activated". Persisted generic client-side tool activations restored when a session resumes.
|
|
8070
8174
|
*/
|
package/dist/host.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HostExitedNotification, HostPublishSessionResult, HostListSessionsResult, HostLocalServerOptions, HostGitHubEnvironmentOptions } from "./generated/rpc.js";
|
|
1
|
+
import type { HostExitedNotification, HostPublishSessionResult, HostUnpublishSessionResult, HostListSessionsResult, HostLocalServerOptions, HostGitHubEnvironmentOptions } from "./generated/rpc.js";
|
|
2
2
|
import type { CopilotSession } from "./session.js";
|
|
3
3
|
import type { SessionConfig, ResumeSessionConfig } from "./types.js";
|
|
4
4
|
/** Host-selected defaults for a fresh application-owned session. @experimental */
|
|
@@ -72,6 +72,7 @@ export declare class AhpHost {
|
|
|
72
72
|
private readonly disposeHost;
|
|
73
73
|
private readonly publishHostSession;
|
|
74
74
|
private readonly listHostSessions;
|
|
75
|
+
private readonly unpublishHostSession;
|
|
75
76
|
readonly hostId: string;
|
|
76
77
|
/** Local WebSocket URL. Absent when only the GitHub environment is enabled. */
|
|
77
78
|
readonly url: string | undefined;
|
|
@@ -85,6 +86,12 @@ export declare class AhpHost {
|
|
|
85
86
|
dispose(): Promise<void>;
|
|
86
87
|
/** Publish an attached application session into the durable compute-scoped host catalog. */
|
|
87
88
|
publishSession(sessionId: string): Promise<HostPublishSessionResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Withdraw a live or dormant application publication and revoke AHP attachments.
|
|
91
|
+
* Preserves local history, worktrees and ongoing work; returns false when already absent.
|
|
92
|
+
* Rejects nonapplication publications. Does not stop the host.
|
|
93
|
+
*/
|
|
94
|
+
unpublishSession(sessionId: string): Promise<HostUnpublishSessionResult>;
|
|
88
95
|
/** List all live and dormant catalog sessions advertised by this host. */
|
|
89
96
|
listSessions(): Promise<HostListSessionsResult>;
|
|
90
97
|
[Symbol.asyncDispose](): Promise<void>;
|
package/dist/host.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
class AhpHost {
|
|
2
2
|
/** @internal */
|
|
3
|
-
constructor(info, disposeHost, publishHostSession, listHostSessions) {
|
|
3
|
+
constructor(info, disposeHost, publishHostSession, listHostSessions, unpublishHostSession) {
|
|
4
4
|
this.disposeHost = disposeHost;
|
|
5
5
|
this.publishHostSession = publishHostSession;
|
|
6
6
|
this.listHostSessions = listHostSessions;
|
|
7
|
+
this.unpublishHostSession = unpublishHostSession;
|
|
7
8
|
this.hostId = info.hostId;
|
|
8
9
|
this.url = info.url;
|
|
9
10
|
this.environmentId = info.environmentId;
|
|
@@ -13,6 +14,7 @@ class AhpHost {
|
|
|
13
14
|
disposeHost;
|
|
14
15
|
publishHostSession;
|
|
15
16
|
listHostSessions;
|
|
17
|
+
unpublishHostSession;
|
|
16
18
|
hostId;
|
|
17
19
|
/** Local WebSocket URL. Absent when only the GitHub environment is enabled. */
|
|
18
20
|
url;
|
|
@@ -30,6 +32,14 @@ class AhpHost {
|
|
|
30
32
|
publishSession(sessionId) {
|
|
31
33
|
return this.publishHostSession(sessionId);
|
|
32
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Withdraw a live or dormant application publication and revoke AHP attachments.
|
|
37
|
+
* Preserves local history, worktrees and ongoing work; returns false when already absent.
|
|
38
|
+
* Rejects nonapplication publications. Does not stop the host.
|
|
39
|
+
*/
|
|
40
|
+
unpublishSession(sessionId) {
|
|
41
|
+
return this.unpublishHostSession(sessionId);
|
|
42
|
+
}
|
|
33
43
|
/** List all live and dormant catalog sessions advertised by this host. */
|
|
34
44
|
listSessions() {
|
|
35
45
|
return this.listHostSessions();
|
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
|
|
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`
|
|
992
|
-
*
|
|
993
|
-
*
|
|
994
|
-
*
|
|
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
|
-
|
|
1040
|
+
/**
|
|
1041
|
+
* Context supplied with a permission request callback.
|
|
1042
|
+
*/
|
|
1043
|
+
export interface PermissionHandlerInvocation {
|
|
1040
1044
|
sessionId: string;
|
|
1041
1045
|
managedSettingsEnabled?: boolean;
|
|
1042
|
-
|
|
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
|
*/
|
|
@@ -1276,6 +1290,14 @@ export interface UserPromptSubmittedHookOutput {
|
|
|
1276
1290
|
modifiedPrompt?: string;
|
|
1277
1291
|
additionalContext?: string;
|
|
1278
1292
|
suppressOutput?: boolean;
|
|
1293
|
+
/**
|
|
1294
|
+
* `"block"` refuses the prompt: no model turn runs, no user message is
|
|
1295
|
+
* recorded, and the session emits an ephemeral `session.warning`
|
|
1296
|
+
* (`warningType: "policy_blocked"`) carrying {@link reason}.
|
|
1297
|
+
*/
|
|
1298
|
+
decision?: "block";
|
|
1299
|
+
/** Why the prompt was blocked, carried by the `session.warning`. */
|
|
1300
|
+
reason?: string;
|
|
1279
1301
|
}
|
|
1280
1302
|
/**
|
|
1281
1303
|
* Handler for user-prompt-submitted hook
|
package/docs/agent-author.md
CHANGED
|
@@ -140,6 +140,8 @@ All handlers may return `void`/`undefined` (no-op) or an output object.
|
|
|
140
140
|
|-------|------|--------|
|
|
141
141
|
| `modifiedPrompt` | `string` | Replaces the user's prompt |
|
|
142
142
|
| `additionalContext` | `string` | Appended as hidden context the agent sees |
|
|
143
|
+
| `decision` | `"block"` | Refuses the prompt: no model turn runs and no user message is recorded |
|
|
144
|
+
| `reason` | `string` | Why the prompt was blocked, carried by the ephemeral `session.warning` (`warningType: "policy_blocked"`) |
|
|
143
145
|
|
|
144
146
|
### onPreToolUse
|
|
145
147
|
|
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.
|
|
9
|
-
"copilotCliVersion": "1.0.
|
|
8
|
+
"version": "1.0.23-preview.1",
|
|
9
|
+
"copilotCliVersion": "1.0.99-1",
|
|
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",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"prepare:runtime": "tsx scripts/prepare-runtime.ts",
|
|
45
45
|
"test": "vitest run",
|
|
46
46
|
"test:unit": "vitest run --exclude=\"test/e2e/**\"",
|
|
47
|
+
"test:codegen": "vitest run --exclude=\"test/e2e/**\" codegen.test.ts legacy-parameters.test.ts",
|
|
47
48
|
"test:watch": "vitest",
|
|
48
49
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" --ignore-path .prettierignore",
|
|
49
50
|
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\" --ignore-path .prettierignore",
|
|
@@ -80,6 +81,7 @@
|
|
|
80
81
|
"@typescript-eslint/parser": "^8.54.0",
|
|
81
82
|
"esbuild": "^0.28.1",
|
|
82
83
|
"eslint": "^9.0.0",
|
|
84
|
+
"file-entry-cache": "file:./scripts/eslint-file-cache",
|
|
83
85
|
"glob": "^13.0.1",
|
|
84
86
|
"hpke-js": "^1.8.0",
|
|
85
87
|
"json-schema": "^0.4.0",
|
|
@@ -96,6 +98,9 @@
|
|
|
96
98
|
"engines": {
|
|
97
99
|
"node": "^20.19.0 || >=22.12.0"
|
|
98
100
|
},
|
|
101
|
+
"overrides": {
|
|
102
|
+
"file-entry-cache": "$file-entry-cache"
|
|
103
|
+
},
|
|
99
104
|
"files": [
|
|
100
105
|
"dist/**/*",
|
|
101
106
|
"!dist/tsconfig.tsbuildinfo",
|
|
@@ -103,18 +108,18 @@
|
|
|
103
108
|
"README.md"
|
|
104
109
|
],
|
|
105
110
|
"copilotRuntime": {
|
|
106
|
-
"sourceSha": "
|
|
107
|
-
"version": "1.0.
|
|
111
|
+
"sourceSha": "7ea4e663f9dbacf776b91d6f8f2ff30b3a5b46eb",
|
|
112
|
+
"version": "1.0.99-1",
|
|
108
113
|
"visibility": "public"
|
|
109
114
|
},
|
|
110
115
|
"optionalDependencies": {
|
|
111
|
-
"@github/copilot-sdk-darwin-arm64": "1.0.
|
|
112
|
-
"@github/copilot-sdk-darwin-x64": "1.0.
|
|
113
|
-
"@github/copilot-sdk-linux-arm64": "1.0.
|
|
114
|
-
"@github/copilot-sdk-linux-x64": "1.0.
|
|
115
|
-
"@github/copilot-sdk-linuxmusl-arm64": "1.0.
|
|
116
|
-
"@github/copilot-sdk-linuxmusl-x64": "1.0.
|
|
117
|
-
"@github/copilot-sdk-win32-arm64": "1.0.
|
|
118
|
-
"@github/copilot-sdk-win32-x64": "1.0.
|
|
116
|
+
"@github/copilot-sdk-darwin-arm64": "1.0.23-preview.1",
|
|
117
|
+
"@github/copilot-sdk-darwin-x64": "1.0.23-preview.1",
|
|
118
|
+
"@github/copilot-sdk-linux-arm64": "1.0.23-preview.1",
|
|
119
|
+
"@github/copilot-sdk-linux-x64": "1.0.23-preview.1",
|
|
120
|
+
"@github/copilot-sdk-linuxmusl-arm64": "1.0.23-preview.1",
|
|
121
|
+
"@github/copilot-sdk-linuxmusl-x64": "1.0.23-preview.1",
|
|
122
|
+
"@github/copilot-sdk-win32-arm64": "1.0.23-preview.1",
|
|
123
|
+
"@github/copilot-sdk-win32-x64": "1.0.23-preview.1"
|
|
119
124
|
}
|
|
120
125
|
}
|