@alvin0/ai-agent-sdk-provider-copilot 0.1.3 → 0.1.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.
- package/dist/index.d.ts +27 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AgentSdkError, ModelInvocationContext, RetryPolicyConfig, SafeErrorRecord } from "@alvin0/ai-agent-sdk-core";
|
|
2
2
|
import { ComposableModelProviderPlugin, CredentialOperationOptions, CredentialStore, ModelTarget } from "@alvin0/ai-agent-sdk-core/provider";
|
|
3
|
-
import { HttpModelAdapter, ProtocolRequest, ProtocolSseEvent, ProtocolStreamChunk, ProviderCatalogModel, ProviderRequestLogger, RuntimeModelDiscoveryContext, RuntimeWireProtocol } from "@alvin0/ai-agent-sdk-provider-http";
|
|
3
|
+
import { HttpModelAdapter, ProtocolRequest, ProtocolSseEvent, ProtocolStreamChunk, ProviderCatalogModel, ProviderRequestLogger, ProviderResponseLogger, RuntimeModelDiscoveryContext, RuntimeWireProtocol } from "@alvin0/ai-agent-sdk-provider-http";
|
|
4
4
|
import { ChatCompletionsDialect } from "@alvin0/ai-agent-sdk-protocol-openai-chat-completions";
|
|
5
5
|
import { ResponsesDialect } from "@alvin0/ai-agent-sdk-protocol-responses";
|
|
6
6
|
//#region src/catalog.d.ts
|
|
@@ -419,6 +419,22 @@ interface CopilotDialect {
|
|
|
419
419
|
readonly parallelToolCalls: boolean;
|
|
420
420
|
/** Prompt/session cache key, used by BOTH branches. */
|
|
421
421
|
readonly promptCacheKey?: string;
|
|
422
|
+
/**
|
|
423
|
+
* Chat Completions only: how to tell this endpoint how hard to think.
|
|
424
|
+
*
|
|
425
|
+
* Defaults to `false` (send nothing) — the original design reasoned that an
|
|
426
|
+
* unrecognized field would 400 a request, but a live probe against a real
|
|
427
|
+
* Copilot Individual account (docs/plans/reasoning-effort-provider-redesign.md,
|
|
428
|
+
* phase 4b) found the opposite: `gpt-4o-mini` on `/chat/completions` accepted
|
|
429
|
+
* `reasoning_effort` in the body without error, both set and unset. The
|
|
430
|
+
* account's only chat-completions-entitled model is not a reasoning model, so
|
|
431
|
+
* this proves the field is tolerated, not that it changes behavior — still not
|
|
432
|
+
* enough to flip the default without guessing (decision 7), but enough to stop
|
|
433
|
+
* blocking the caller who wants to opt in. Set `'openai'` to send
|
|
434
|
+
* `reasoning_effort` verbatim, the same wire field Chat Completions uses
|
|
435
|
+
* elsewhere in this SDK.
|
|
436
|
+
*/
|
|
437
|
+
readonly reasoningFormat: ChatCompletionsDialect['reasoningFormat'];
|
|
422
438
|
}
|
|
423
439
|
/**
|
|
424
440
|
* Conservative defaults, matching each sub-protocol's own defaults where the two
|
|
@@ -452,9 +468,9 @@ declare function toResponsesDialect(dialect: CopilotDialect): Partial<ResponsesD
|
|
|
452
468
|
* Project the Copilot dialect onto the Chat Completions dialect.
|
|
453
469
|
*
|
|
454
470
|
* PURE and TOTAL, same rule as {@link toResponsesDialect}: `store`, `include` and
|
|
455
|
-
* `reasoningSummary` have no Chat Completions destination and are dropped
|
|
456
|
-
* `
|
|
457
|
-
*
|
|
471
|
+
* `reasoningSummary` have no Chat Completions destination and are dropped.
|
|
472
|
+
* `reasoningFormat` DOES have one — see its doc comment on {@link CopilotDialect}
|
|
473
|
+
* for why it defaults off rather than on.
|
|
458
474
|
*
|
|
459
475
|
* Two flags change type on the way across, and each mapping is total:
|
|
460
476
|
*
|
|
@@ -941,6 +957,13 @@ interface CopilotProviderOptions {
|
|
|
941
957
|
* stop the request (Requirement 14.5).
|
|
942
958
|
*/
|
|
943
959
|
readonly requestLogger?: ProviderRequestLogger;
|
|
960
|
+
/**
|
|
961
|
+
* Exact wire-response observer, fired once a stream ends.
|
|
962
|
+
*
|
|
963
|
+
* BEST-EFFORT, same contract as {@link requestLogger}: a logger that
|
|
964
|
+
* overruns or throws does not affect the request it describes.
|
|
965
|
+
*/
|
|
966
|
+
readonly responseLogger?: ProviderResponseLogger;
|
|
944
967
|
/** HTTP implementation, for tests and non-browser runtimes. */
|
|
945
968
|
readonly fetch?: typeof globalThis.fetch;
|
|
946
969
|
/** Registry id; defaults to {@link COPILOT_ROUTE_ID}. */
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/catalog.ts","../src/common/identity.ts","../src/common/store-types.ts","../src/router.ts","../src/dual-protocol.ts","../src/auth.ts","../src/common/http.ts","../src/exchange.ts","../src/adapter.ts","../src/token.ts","../src/common/error-codes.ts","../src/errors.ts","../src/oauth.ts"],"mappings":";;;;;;;cA6Ea;;cAGA;;cAGA;;cAGA;;cAGA;;;;;;;;;;;;KAaD;;KA2BA;;;;;;UAOK;;WAEN;;WAEA,QAAQ;;;UAIF;;WAEN,OAAO;;;;;;;WAOP,kBAAkB;;;;;;;;;;;UAYZ;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN,qBAAqB;;WAErB,oBAAoB;;WAEpB,kBAAkB;;;UAIZ;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;;;;;UAcM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;;;;iBAaK,4BACd,UAAS,wBACR;;;;;;;;;;iBAiCa,2BAA2B,UAAS;WACzC;WACA;WACA;;;;;;;;;;;;;;;;;;;iBA8BW,sBACpB,SAAS,8BACT,QAAQ,sBACR,kBAAkB,WAAW,QAC5B,QAAQ;;;;;;;;;;;;iBAwCK,wBACd,MAAM,yBACN,oBACC;;;;;;;;;;;;;;;;;;;;;;;;cCjVU;;cAGA;;cAGA;;;;;;;;UASI;;WAEN;;WAEA;;;;;;;;;;;UCfM;;WAEN;;WAEA;;WAEA;;;UAIM;WACN;WACA;WACA;;;;;;;;;;;;;;;;;;;;;UAsBM;;;;;WAKN;WACA,QAAQ;WACR,UAAU;;WAEV;;WAEA;;;;;;UAOM;WACN;EACT,QAAQ,QAAQ;EAChB,MAAM,MAAM,kBAAkB;;;KAIpB,yBAAyB,gBAAgB;;;;;;;;;;;;;;;;cCFxC;;UAMI;;WAEN;;WAEA,UAAU;;WAEV;;;;;;;;WAQA;;;UAIM;;;;;;;;;;EAUf,OAAO,kBAAkB;;;;;;;;EAQzB,MAAM,iBAAiB;;;;;EAKvB,qBAAqB;;;UAIN;;;;;WAKN,YAAY,SAAS,eAAe;;;;;;;;;WASpC;;;;;;;;;;;;;;iBA2BK,4BACd,UAAS,+BACR;;;;cCrHU;;;;;;;;;;;;;;;;;UAkBI;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/catalog.ts","../src/common/identity.ts","../src/common/store-types.ts","../src/router.ts","../src/dual-protocol.ts","../src/auth.ts","../src/common/http.ts","../src/exchange.ts","../src/adapter.ts","../src/token.ts","../src/common/error-codes.ts","../src/errors.ts","../src/oauth.ts"],"mappings":";;;;;;;cA6Ea;;cAGA;;cAGA;;cAGA;;cAGA;;;;;;;;;;;;KAaD;;KA2BA;;;;;;UAOK;;WAEN;;WAEA,QAAQ;;;UAIF;;WAEN,OAAO;;;;;;;WAOP,kBAAkB;;;;;;;;;;;UAYZ;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN,qBAAqB;;WAErB,oBAAoB;;WAEpB,kBAAkB;;;UAIZ;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;;;;;UAcM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;;;;iBAaK,4BACd,UAAS,wBACR;;;;;;;;;;iBAiCa,2BAA2B,UAAS;WACzC;WACA;WAC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A;;WAEA,QAAQ;;;UAIF;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN,YAAY,MAAM;;WAElB,UAAU,mBAAmB;;;UAIvB;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;;;;;;;;;;iBA+BW,yBACpB,UAAS,sBACR,QAAQ;;;;;;;;;;;;;;;;iBAqDK,sBACd,OAAO,wBACP,UAAU,qBACV,WAAW,uBACV,QAAQ;iBACK,sBACd,OAAO,kBACP,UAAU,qBACV,WAAW,uBACV,QAAQ"}
|
package/dist/index.js
CHANGED
|
@@ -1063,7 +1063,8 @@ const COPILOT_DEFAULT_DIALECT = Object.freeze({
|
|
|
1063
1063
|
reasoningSummary: "auto",
|
|
1064
1064
|
streamUsage: true,
|
|
1065
1065
|
systemRole: "system",
|
|
1066
|
-
parallelToolCalls: false
|
|
1066
|
+
parallelToolCalls: false,
|
|
1067
|
+
reasoningFormat: false
|
|
1067
1068
|
});
|
|
1068
1069
|
/**
|
|
1069
1070
|
* Project the Copilot dialect onto the Responses dialect.
|
|
@@ -1097,9 +1098,9 @@ function toResponsesDialect(dialect) {
|
|
|
1097
1098
|
* Project the Copilot dialect onto the Chat Completions dialect.
|
|
1098
1099
|
*
|
|
1099
1100
|
* PURE and TOTAL, same rule as {@link toResponsesDialect}: `store`, `include` and
|
|
1100
|
-
* `reasoningSummary` have no Chat Completions destination and are dropped
|
|
1101
|
-
* `
|
|
1102
|
-
*
|
|
1101
|
+
* `reasoningSummary` have no Chat Completions destination and are dropped.
|
|
1102
|
+
* `reasoningFormat` DOES have one — see its doc comment on {@link CopilotDialect}
|
|
1103
|
+
* for why it defaults off rather than on.
|
|
1103
1104
|
*
|
|
1104
1105
|
* Two flags change type on the way across, and each mapping is total:
|
|
1105
1106
|
*
|
|
@@ -1128,6 +1129,7 @@ function toChatCompletionsDialect(dialect) {
|
|
|
1128
1129
|
streamUsage: dialect.streamUsage,
|
|
1129
1130
|
systemRole: dialect.systemRole,
|
|
1130
1131
|
parallelToolCalls: dialect.parallelToolCalls,
|
|
1132
|
+
reasoningFormat: dialect.reasoningFormat,
|
|
1131
1133
|
...dialect.promptCacheKey === void 0 ? {} : { promptCacheKey: dialect.promptCacheKey }
|
|
1132
1134
|
};
|
|
1133
1135
|
}
|
|
@@ -1159,8 +1161,8 @@ function copilotDualProtocol(options) {
|
|
|
1159
1161
|
/**
|
|
1160
1162
|
* The Chat Completions dialect for one request.
|
|
1161
1163
|
*
|
|
1162
|
-
* Same rule; the sub-protocol supplies `path`, `stop
|
|
1163
|
-
*
|
|
1164
|
+
* Same rule; the sub-protocol supplies `path`, `stop` and `seed`, which
|
|
1165
|
+
* {@link CopilotDialect} does not expose.
|
|
1164
1166
|
*/
|
|
1165
1167
|
const resolvedChatDialect = (dialect) => Object.freeze({
|
|
1166
1168
|
...chat.defaultDialect,
|
|
@@ -2002,6 +2004,7 @@ function buildCopilotAdapter(options, captured) {
|
|
|
2002
2004
|
baseHeaders: COPILOT_TRANSPORT_HEADERS,
|
|
2003
2005
|
...options.retryPolicy === void 0 ? {} : { retryPolicy: options.retryPolicy },
|
|
2004
2006
|
...options.requestLogger === void 0 ? {} : { requestLogger: options.requestLogger },
|
|
2007
|
+
...options.responseLogger === void 0 ? {} : { responseLogger: options.responseLogger },
|
|
2005
2008
|
errorCode: (status, detail) => isMissingEditorHeaderFailure(status, detail) ? COPILOT_ERROR_CODES.EDITOR_HEADERS_MISSING : void 0,
|
|
2006
2009
|
fetch: copilotProviderFetch(options, secrets)
|
|
2007
2010
|
});
|