@lerianstudio/matcher-mcp 5.0.0-beta.14 → 5.0.0-beta.140
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 +29 -14
- package/dist/auth/request-token.js +11 -69
- package/dist/auth/request-token.js.map +1 -1
- package/dist/config.js +19 -85
- package/dist/config.js.map +1 -1
- package/dist/copilot/agent.js +5 -9
- package/dist/copilot/agent.js.map +1 -1
- package/dist/copilot/provider-anthropic.js +75 -23
- package/dist/copilot/provider-anthropic.js.map +1 -1
- package/dist/copilot/provider-openrouter.js +5 -18
- package/dist/copilot/provider-openrouter.js.map +1 -1
- package/dist/copilot/provider-shared.js +11 -0
- package/dist/copilot/provider-shared.js.map +1 -1
- package/dist/copilot/speech-provider.js +84 -0
- package/dist/copilot/speech-provider.js.map +1 -0
- package/dist/copilot/sse.js +5 -0
- package/dist/copilot/sse.js.map +1 -1
- package/dist/copilot/system-prompt.js +17 -2
- package/dist/copilot/system-prompt.js.map +1 -1
- package/dist/copilot/tools.js +14 -65
- package/dist/copilot/tools.js.map +1 -1
- package/dist/copilot/transcribe-handler.js +8 -93
- package/dist/copilot/transcribe-handler.js.map +1 -1
- package/dist/copilot/turn-request.js +76 -0
- package/dist/copilot/turn-request.js.map +1 -0
- package/dist/copilot/turns-handler.js +11 -102
- package/dist/copilot/turns-handler.js.map +1 -1
- package/dist/matcher/client.js +1 -1
- package/dist/matcher/client.js.map +1 -1
- package/dist/matcher/idempotency.js +1 -1
- package/dist/matcher/idempotency.js.map +1 -1
- package/dist/observability/otel.js +86 -125
- package/dist/observability/otel.js.map +1 -1
- package/dist/server.js +12 -81
- package/dist/server.js.map +1 -1
- package/dist/spec/curated-operations.js +114 -98
- package/dist/spec/curated-operations.js.map +1 -1
- package/dist/spec/enum-policy.js +21 -26
- package/dist/spec/enum-policy.js.map +1 -1
- package/dist/spec/index.js +1 -1
- package/dist/spec/index.js.map +1 -1
- package/dist/spec/openapi.yaml +901 -74
- package/dist/spec/schema-parity.js +25 -30
- package/dist/spec/schema-parity.js.map +1 -1
- package/dist/tools/context/create.js +16 -5
- package/dist/tools/context/create.js.map +1 -1
- package/dist/tools/context/index.js +137 -17
- package/dist/tools/context/index.js.map +1 -1
- package/dist/tools/context/list.js +10 -36
- package/dist/tools/context/list.js.map +1 -1
- package/dist/tools/context/setup-progress.js +4 -3
- package/dist/tools/context/setup-progress.js.map +1 -1
- package/dist/tools/context/shared.js +5 -53
- package/dist/tools/context/shared.js.map +1 -1
- package/dist/tools/context/update.js +15 -7
- package/dist/tools/context/update.js.map +1 -1
- package/dist/tools/curated-tool.js +37 -0
- package/dist/tools/curated-tool.js.map +1 -0
- package/dist/tools/dashboard/index.js +124 -19
- package/dist/tools/dashboard/index.js.map +1 -1
- package/dist/tools/dashboard/shared.js +9 -76
- package/dist/tools/dashboard/shared.js.map +1 -1
- package/dist/tools/dispute/close.js +5 -5
- package/dist/tools/dispute/close.js.map +1 -1
- package/dist/tools/dispute/index.js +34 -6
- package/dist/tools/dispute/index.js.map +1 -1
- package/dist/tools/dispute/list.js +19 -48
- package/dist/tools/dispute/list.js.map +1 -1
- package/dist/tools/dispute/shared.js +4 -50
- package/dist/tools/dispute/shared.js.map +1 -1
- package/dist/tools/dispute/submit-evidence.js +5 -5
- package/dist/tools/dispute/submit-evidence.js.map +1 -1
- package/dist/tools/exception/add-comment.js +3 -2
- package/dist/tools/exception/add-comment.js.map +1 -1
- package/dist/tools/exception/adjust-entry.js +5 -5
- package/dist/tools/exception/adjust-entry.js.map +1 -1
- package/dist/tools/exception/bulk-assign.js +3 -2
- package/dist/tools/exception/bulk-assign.js.map +1 -1
- package/dist/tools/exception/bulk-dispatch.js +3 -2
- package/dist/tools/exception/bulk-dispatch.js.map +1 -1
- package/dist/tools/exception/bulk-resolve.js +3 -2
- package/dist/tools/exception/bulk-resolve.js.map +1 -1
- package/dist/tools/exception/dispatch.js +3 -2
- package/dist/tools/exception/dispatch.js.map +1 -1
- package/dist/tools/exception/force-match.js +3 -2
- package/dist/tools/exception/force-match.js.map +1 -1
- package/dist/tools/exception/history.js +10 -26
- package/dist/tools/exception/history.js.map +1 -1
- package/dist/tools/exception/index.js +88 -18
- package/dist/tools/exception/index.js.map +1 -1
- package/dist/tools/exception/list.js +17 -60
- package/dist/tools/exception/list.js.map +1 -1
- package/dist/tools/exception/open-dispute.js +3 -2
- package/dist/tools/exception/open-dispute.js.map +1 -1
- package/dist/tools/exception/shared.js +3 -51
- package/dist/tools/exception/shared.js.map +1 -1
- package/dist/tools/fee-rule/create.js +5 -5
- package/dist/tools/fee-rule/create.js.map +1 -1
- package/dist/tools/fee-rule/index.js +50 -8
- package/dist/tools/fee-rule/index.js.map +1 -1
- package/dist/tools/fee-rule/list.js +10 -30
- package/dist/tools/fee-rule/list.js.map +1 -1
- package/dist/tools/fee-rule/shared.js +3 -53
- package/dist/tools/fee-rule/shared.js.map +1 -1
- package/dist/tools/fee-rule/update.js +5 -5
- package/dist/tools/fee-rule/update.js.map +1 -1
- package/dist/tools/fee-schedule/create.js +9 -4
- package/dist/tools/fee-schedule/create.js.map +1 -1
- package/dist/tools/fee-schedule/index.js +62 -11
- package/dist/tools/fee-schedule/index.js.map +1 -1
- package/dist/tools/fee-schedule/list.js +9 -25
- package/dist/tools/fee-schedule/list.js.map +1 -1
- package/dist/tools/fee-schedule/shared.js +4 -50
- package/dist/tools/fee-schedule/shared.js.map +1 -1
- package/dist/tools/fee-schedule/simulate.js +5 -5
- package/dist/tools/fee-schedule/simulate.js.map +1 -1
- package/dist/tools/fee-schedule/update.js +5 -5
- package/dist/tools/fee-schedule/update.js.map +1 -1
- package/dist/tools/field-map/create.js +4 -3
- package/dist/tools/field-map/create.js.map +1 -1
- package/dist/tools/field-map/index.js +65 -11
- package/dist/tools/field-map/index.js.map +1 -1
- package/dist/tools/field-map/list.js +10 -30
- package/dist/tools/field-map/list.js.map +1 -1
- package/dist/tools/field-map/shared.js +21 -73
- package/dist/tools/field-map/shared.js.map +1 -1
- package/dist/tools/field-map/update.js +6 -4
- package/dist/tools/field-map/update.js.map +1 -1
- package/dist/tools/generic/describe-operation.js +2 -8
- package/dist/tools/generic/describe-operation.js.map +1 -1
- package/dist/tools/generic/invoke.js +5 -40
- package/dist/tools/generic/invoke.js.map +1 -1
- package/dist/tools/generic/list-operations.js +1 -1
- package/dist/tools/generic/list-operations.js.map +1 -1
- package/dist/tools/ingestion/index.js +100 -12
- package/dist/tools/ingestion/index.js.map +1 -1
- package/dist/tools/ingestion/job-transactions-list.js +12 -42
- package/dist/tools/ingestion/job-transactions-list.js.map +1 -1
- package/dist/tools/ingestion/jobs-list.js +11 -37
- package/dist/tools/ingestion/jobs-list.js.map +1 -1
- package/dist/tools/ingestion/shared.js +3 -49
- package/dist/tools/ingestion/shared.js.map +1 -1
- package/dist/tools/ingestion/transactions-search.js +11 -46
- package/dist/tools/ingestion/transactions-search.js.map +1 -1
- package/dist/tools/ingestion/upload-begin.js +1 -1
- package/dist/tools/ingestion/upload-begin.js.map +1 -1
- package/dist/tools/ingestion/upload.js +3 -2
- package/dist/tools/ingestion/upload.js.map +1 -1
- package/dist/tools/input-fields.js +51 -0
- package/dist/tools/input-fields.js.map +1 -0
- package/dist/tools/match-rule/index.js +130 -13
- package/dist/tools/match-rule/index.js.map +1 -1
- package/dist/tools/match-rule/list.js +10 -34
- package/dist/tools/match-rule/list.js.map +1 -1
- package/dist/tools/match-rule/shared.js +14 -53
- package/dist/tools/match-rule/shared.js.map +1 -1
- package/dist/tools/match-rule/update.js +7 -11
- package/dist/tools/match-rule/update.js.map +1 -1
- package/dist/tools/matching/get.js +6 -6
- package/dist/tools/matching/get.js.map +1 -1
- package/dist/tools/matching/groups.js +7 -15
- package/dist/tools/matching/groups.js.map +1 -1
- package/dist/tools/matching/index.js +77 -5
- package/dist/tools/matching/index.js.map +1 -1
- package/dist/tools/matching/list.js +10 -33
- package/dist/tools/matching/list.js.map +1 -1
- package/dist/tools/matching/shared.js +3 -52
- package/dist/tools/matching/shared.js.map +1 -1
- package/dist/tools/query-handler.js +9 -0
- package/dist/tools/query-handler.js.map +1 -0
- package/dist/tools/report/index.js +264 -30
- package/dist/tools/report/index.js.map +1 -1
- package/dist/tools/report/shared.js +21 -106
- package/dist/tools/report/shared.js.map +1 -1
- package/dist/tools/request-fields.js +17 -0
- package/dist/tools/request-fields.js.map +1 -0
- package/dist/tools/shared-dispatch.js +42 -0
- package/dist/tools/shared-dispatch.js.map +1 -0
- package/dist/tools/source/create.js +146 -23
- package/dist/tools/source/create.js.map +1 -1
- package/dist/tools/source/index.js +101 -13
- package/dist/tools/source/index.js.map +1 -1
- package/dist/tools/source/list.js +10 -33
- package/dist/tools/source/list.js.map +1 -1
- package/dist/tools/source/shared.js +3 -48
- package/dist/tools/source/shared.js.map +1 -1
- package/dist/tools/source/update.js +16 -33
- package/dist/tools/source/update.js.map +1 -1
- package/dist/tools/workspace/usage.js +27 -41
- package/dist/tools/workspace/usage.js.map +1 -1
- package/dist/transport/body-limit.js +1 -6
- package/dist/transport/body-limit.js.map +1 -1
- package/package.json +4 -4
- package/dist/tools/context/archive.js +0 -37
- package/dist/tools/context/archive.js.map +0 -1
- package/dist/tools/context/get.js +0 -31
- package/dist/tools/context/get.js.map +0 -1
- package/dist/tools/context/next-step.js +0 -99
- package/dist/tools/context/next-step.js.map +0 -1
- package/dist/tools/context/restore.js +0 -34
- package/dist/tools/context/restore.js.map +0 -1
- package/dist/tools/dashboard/aggregates.js +0 -37
- package/dist/tools/dashboard/aggregates.js.map +0 -1
- package/dist/tools/dashboard/cash-impact.js +0 -37
- package/dist/tools/dashboard/cash-impact.js.map +0 -1
- package/dist/tools/dashboard/match-rate.js +0 -37
- package/dist/tools/dashboard/match-rate.js.map +0 -1
- package/dist/tools/dashboard/metrics.js +0 -37
- package/dist/tools/dashboard/metrics.js.map +0 -1
- package/dist/tools/dashboard/sla.js +0 -34
- package/dist/tools/dashboard/sla.js.map +0 -1
- package/dist/tools/dashboard/source-breakdown.js +0 -37
- package/dist/tools/dashboard/source-breakdown.js.map +0 -1
- package/dist/tools/dashboard/volume.js +0 -37
- package/dist/tools/dashboard/volume.js.map +0 -1
- package/dist/tools/dispute/get.js +0 -27
- package/dist/tools/dispute/get.js.map +0 -1
- package/dist/tools/exception/delete-comment.js +0 -40
- package/dist/tools/exception/delete-comment.js.map +0 -1
- package/dist/tools/exception/get.js +0 -34
- package/dist/tools/exception/get.js.map +0 -1
- package/dist/tools/exception/list-comments.js +0 -35
- package/dist/tools/exception/list-comments.js.map +0 -1
- package/dist/tools/fee-rule/delete.js +0 -27
- package/dist/tools/fee-rule/delete.js.map +0 -1
- package/dist/tools/fee-rule/get.js +0 -27
- package/dist/tools/fee-rule/get.js.map +0 -1
- package/dist/tools/fee-schedule/delete.js +0 -32
- package/dist/tools/fee-schedule/delete.js.map +0 -1
- package/dist/tools/fee-schedule/get.js +0 -30
- package/dist/tools/fee-schedule/get.js.map +0 -1
- package/dist/tools/field-map/delete.js +0 -37
- package/dist/tools/field-map/delete.js.map +0 -1
- package/dist/tools/field-map/get.js +0 -43
- package/dist/tools/field-map/get.js.map +0 -1
- package/dist/tools/ingestion/job-errors-list.js +0 -45
- package/dist/tools/ingestion/job-errors-list.js.map +0 -1
- package/dist/tools/ingestion/job-get.js +0 -42
- package/dist/tools/ingestion/job-get.js.map +0 -1
- package/dist/tools/ingestion/transaction-ignore.js +0 -51
- package/dist/tools/ingestion/transaction-ignore.js.map +0 -1
- package/dist/tools/match-rule/create.js +0 -67
- package/dist/tools/match-rule/create.js.map +0 -1
- package/dist/tools/match-rule/delete.js +0 -35
- package/dist/tools/match-rule/delete.js.map +0 -1
- package/dist/tools/match-rule/get.js +0 -32
- package/dist/tools/match-rule/get.js.map +0 -1
- package/dist/tools/match-rule/reorder.js +0 -45
- package/dist/tools/match-rule/reorder.js.map +0 -1
- package/dist/tools/matching/start.js +0 -81
- package/dist/tools/matching/start.js.map +0 -1
- package/dist/tools/report/count-exceptions.js +0 -46
- package/dist/tools/report/count-exceptions.js.map +0 -1
- package/dist/tools/report/count-matched.js +0 -47
- package/dist/tools/report/count-matched.js.map +0 -1
- package/dist/tools/report/count-transactions.js +0 -45
- package/dist/tools/report/count-transactions.js.map +0 -1
- package/dist/tools/report/count-unmatched.js +0 -45
- package/dist/tools/report/count-unmatched.js.map +0 -1
- package/dist/tools/report/export-exceptions.js +0 -48
- package/dist/tools/report/export-exceptions.js.map +0 -1
- package/dist/tools/report/export-matched.js +0 -49
- package/dist/tools/report/export-matched.js.map +0 -1
- package/dist/tools/report/export-summary.js +0 -49
- package/dist/tools/report/export-summary.js.map +0 -1
- package/dist/tools/report/export-unmatched.js +0 -49
- package/dist/tools/report/export-unmatched.js.map +0 -1
- package/dist/tools/report/export-variance.js +0 -48
- package/dist/tools/report/export-variance.js.map +0 -1
- package/dist/tools/report/matched.js +0 -48
- package/dist/tools/report/matched.js.map +0 -1
- package/dist/tools/report/summary.js +0 -43
- package/dist/tools/report/summary.js.map +0 -1
- package/dist/tools/report/unmatched.js +0 -48
- package/dist/tools/report/unmatched.js.map +0 -1
- package/dist/tools/report/variance.js +0 -48
- package/dist/tools/report/variance.js.map +0 -1
- package/dist/tools/source/archive.js +0 -46
- package/dist/tools/source/archive.js.map +0 -1
- package/dist/tools/source/get.js +0 -57
- package/dist/tools/source/get.js.map +0 -1
- package/dist/tools/source/restore.js +0 -39
- package/dist/tools/source/restore.js.map +0 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// call — nothing persists across turns.
|
|
6
6
|
import Anthropic from '@anthropic-ai/sdk';
|
|
7
7
|
import { CopilotUnconfiguredError } from './provider-factory.js';
|
|
8
|
-
import {
|
|
8
|
+
import { buildTurnResult } from './provider-shared.js';
|
|
9
9
|
// Max tokens the Messages API requires per request. A fixed ceiling is fine for
|
|
10
10
|
// grounded read-only answers.
|
|
11
11
|
// ponytail: fixed cap; make configurable if turns start truncating.
|
|
@@ -21,6 +21,16 @@ const ANTHROPIC_DEFAULT_MODEL = 'claude-opus-4-8';
|
|
|
21
21
|
// ponytail: placeholder name/input is a known ceiling — enrich LLMToolResult
|
|
22
22
|
// with the originating name/input if the model needs to see its prior args.
|
|
23
23
|
const SYNTHETIC_TOOL_USE_NAME = 'tool';
|
|
24
|
+
/**
|
|
25
|
+
* The prompt-cache breakpoint marker, at the default 5-minute TTL.
|
|
26
|
+
*
|
|
27
|
+
* 5m, not 1h: the 1-hour TTL costs 2x on the write instead of 1.25x and only
|
|
28
|
+
* pays off when requests sharing the prefix start more than five minutes
|
|
29
|
+
* apart. Every round inside an agentic turn starts seconds after the last, and
|
|
30
|
+
* a read refreshes the entry's timer for free, so a busy console keeps the
|
|
31
|
+
* 5-minute entry alive indefinitely at the cheaper write price.
|
|
32
|
+
*/
|
|
33
|
+
const CACHE_EPHEMERAL = { type: 'ephemeral' };
|
|
24
34
|
/**
|
|
25
35
|
* Build a provider backed by Anthropic. When `streamFn` is omitted the key is
|
|
26
36
|
* required (its absence throws CopilotUnconfiguredError here, at construction);
|
|
@@ -31,10 +41,31 @@ export function createAnthropicProvider(config, streamFn) {
|
|
|
31
41
|
return {
|
|
32
42
|
async streamTurn(input, handlers) {
|
|
33
43
|
const tools = input.tools.map(toAnthropicTool);
|
|
44
|
+
// Prompt caching, two of the API's four allowed breakpoints.
|
|
45
|
+
//
|
|
46
|
+
// The request renders as tools -> system -> messages, and everything up
|
|
47
|
+
// to the end of `system` is byte-identical on every round of every turn:
|
|
48
|
+
// `buildSystemPrompt` returns a frozen module constant with nothing
|
|
49
|
+
// interpolated into it (the operator's screen context is deliberately a
|
|
50
|
+
// user message, not part of the system tier), and the tool catalogue is
|
|
51
|
+
// memoized over the immutable spec index. That static floor is the whole
|
|
52
|
+
// prize (it dwarfs the conversation), so breakpoint 1 goes on the last
|
|
53
|
+
// (only) system block, which caches the tools ahead of it in the same
|
|
54
|
+
// entry. Nothing had to be moved out of it; it was already stable, just
|
|
55
|
+
// unmarked.
|
|
56
|
+
//
|
|
57
|
+
// Breakpoint 2 is the top-level marker: the API places it on the last
|
|
58
|
+
// cacheable block and walks it forward as the request grows, which is
|
|
59
|
+
// exactly the shape of the tail here: a turn accumulates tool results
|
|
60
|
+
// round over round, and the browser replays the whole conversation on
|
|
61
|
+
// the next POST. A write bills only the delta past the highest cache
|
|
62
|
+
// hit, so this second entry costs the messages delta, never the prefix
|
|
63
|
+
// breakpoint 1 already covers.
|
|
34
64
|
const params = {
|
|
35
65
|
model: config.copilotModel ?? ANTHROPIC_DEFAULT_MODEL,
|
|
36
66
|
max_tokens: ANTHROPIC_MAX_TOKENS,
|
|
37
|
-
system: input.system,
|
|
67
|
+
system: [{ type: 'text', text: input.system, cache_control: CACHE_EPHEMERAL }],
|
|
68
|
+
cache_control: CACHE_EPHEMERAL,
|
|
38
69
|
messages: buildAnthropicMessages(input),
|
|
39
70
|
...(tools.length > 0 ? { tools } : {}),
|
|
40
71
|
};
|
|
@@ -46,13 +77,25 @@ export function createAnthropicProvider(config, streamFn) {
|
|
|
46
77
|
// neither, so the loop meters this round as 0 (fail-open).
|
|
47
78
|
let inputTokens;
|
|
48
79
|
let outputTokens;
|
|
80
|
+
// Prompt-cache halves of the input, tracked separately so `usageFrom`
|
|
81
|
+
// can both fold them into the true prompt size and report them raw. Read
|
|
82
|
+
// off message_start with message_delta (also cumulative, and nullable
|
|
83
|
+
// there) as a refresh, so a stream that only populates them on the delta
|
|
84
|
+
// is still accounted rather than silently metered as an uncached turn.
|
|
85
|
+
let cacheCreationTokens;
|
|
86
|
+
let cacheReadTokens;
|
|
49
87
|
for await (const event of openStream(params)) {
|
|
50
88
|
if (event.type === 'message_start') {
|
|
51
89
|
inputTokens = event.message.usage.input_tokens;
|
|
52
90
|
outputTokens = event.message.usage.output_tokens;
|
|
91
|
+
cacheCreationTokens = event.message.usage.cache_creation_input_tokens ?? undefined;
|
|
92
|
+
cacheReadTokens = event.message.usage.cache_read_input_tokens ?? undefined;
|
|
53
93
|
}
|
|
54
94
|
else if (event.type === 'message_delta') {
|
|
55
95
|
outputTokens = event.usage.output_tokens;
|
|
96
|
+
cacheCreationTokens =
|
|
97
|
+
event.usage.cache_creation_input_tokens ?? cacheCreationTokens;
|
|
98
|
+
cacheReadTokens = event.usage.cache_read_input_tokens ?? cacheReadTokens;
|
|
56
99
|
}
|
|
57
100
|
else if (event.type === 'content_block_start' &&
|
|
58
101
|
event.content_block.type === 'tool_use') {
|
|
@@ -74,22 +117,13 @@ export function createAnthropicProvider(config, streamFn) {
|
|
|
74
117
|
}
|
|
75
118
|
}
|
|
76
119
|
}
|
|
77
|
-
const usage = usageFrom(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// path: capture stop_reason into the done label if operators hit it.
|
|
85
|
-
return { stop: 'end', ...(usage !== undefined ? { usage } : {}) };
|
|
86
|
-
}
|
|
87
|
-
const calls = [...toolBlocks.values()].map((block) => ({
|
|
88
|
-
id: block.id,
|
|
89
|
-
name: block.name,
|
|
90
|
-
input: parseToolInput(block.json),
|
|
91
|
-
}));
|
|
92
|
-
return { stop: 'tool_use', calls, ...(usage !== undefined ? { usage } : {}) };
|
|
120
|
+
const usage = usageFrom({
|
|
121
|
+
inputTokens,
|
|
122
|
+
outputTokens,
|
|
123
|
+
cacheCreationTokens,
|
|
124
|
+
cacheReadTokens,
|
|
125
|
+
});
|
|
126
|
+
return buildTurnResult([...toolBlocks.values()], usage);
|
|
93
127
|
},
|
|
94
128
|
};
|
|
95
129
|
}
|
|
@@ -104,14 +138,32 @@ function defaultAnthropicStream(config) {
|
|
|
104
138
|
}
|
|
105
139
|
/**
|
|
106
140
|
* Build an LLMUsage from the tracked token counts, or `undefined` when the
|
|
107
|
-
* stream reported
|
|
108
|
-
* missing
|
|
141
|
+
* stream reported no usage at all (so the loop meters this round as 0, which
|
|
142
|
+
* is fail-open). A missing field defaults to 0 rather than dropping the whole
|
|
143
|
+
* usage.
|
|
144
|
+
*
|
|
145
|
+
* `inputTokens` is deliberately NOT the API's `input_tokens`. With caching on,
|
|
146
|
+
* that field counts only the uncached remainder. The total prompt is
|
|
147
|
+
* `input_tokens + cache_creation_input_tokens + cache_read_input_tokens`, so
|
|
148
|
+
* the cached halves are added back here. Reporting the remainder instead would
|
|
149
|
+
* make every cached round look ~25k tokens cheaper than it is to the two
|
|
150
|
+
* consumers that read this number: the per-turn ceiling in `runAgentTurn`
|
|
151
|
+
* (which would stop tripping on a runaway) and the copilot token metric (which
|
|
152
|
+
* would under-report the prompt floor by the whole cached prefix). The raw
|
|
153
|
+
* halves ride alongside, unfolded, as the cache-hit evidence.
|
|
109
154
|
*/
|
|
110
|
-
function usageFrom(
|
|
111
|
-
if (inputTokens === undefined && outputTokens === undefined) {
|
|
155
|
+
function usageFrom(raw) {
|
|
156
|
+
if (raw.inputTokens === undefined && raw.outputTokens === undefined) {
|
|
112
157
|
return undefined;
|
|
113
158
|
}
|
|
114
|
-
|
|
159
|
+
const cacheCreationTokens = raw.cacheCreationTokens ?? 0;
|
|
160
|
+
const cacheReadTokens = raw.cacheReadTokens ?? 0;
|
|
161
|
+
return {
|
|
162
|
+
inputTokens: (raw.inputTokens ?? 0) + cacheCreationTokens + cacheReadTokens,
|
|
163
|
+
outputTokens: raw.outputTokens ?? 0,
|
|
164
|
+
cacheCreationTokens,
|
|
165
|
+
cacheReadTokens,
|
|
166
|
+
};
|
|
115
167
|
}
|
|
116
168
|
function toAnthropicTool(def) {
|
|
117
169
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-anthropic.js","sourceRoot":"","sources":["../../src/copilot/provider-anthropic.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,wCAAwC;AAExC,OAAO,SAAS,MAAM,mBAAmB,CAAA;AAGzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"provider-anthropic.js","sourceRoot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AAC;QAC1E,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAC,CAAA;IAEH,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpE,MAAM,aAAa,GAAkC,KAAK,CAAC,WAAW,CAAC,GAAG,CACxE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACX,IAAI,EAAE,UAAU;YAChB,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,IAAI,EAAE,uBAAuB;YAC7B,KAAK,EAAE,EAAE;SACV,CAAC,CACH,CAAA;QACD,MAAM,gBAAgB,GAAkC,KAAK,CAAC,WAAW,CAAC,GAAG,CAC3E,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACX,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,MAAM,CAAC,EAAE;YACtB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvD,CAAC,CACH,CAAA;QACD,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAA;QAC5D,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAA;IAC5D,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// back into the LLMProvider seam. Stateless per call.
|
|
7
7
|
import OpenAI from 'openai';
|
|
8
8
|
import { CopilotModelRequiredError, CopilotUnconfiguredError } from './provider-factory.js';
|
|
9
|
-
import {
|
|
9
|
+
import { buildTurnResult } from './provider-shared.js';
|
|
10
10
|
const OPENROUTER_BASE_URL = 'https://openrouter.ai/api/v1';
|
|
11
11
|
// The seam's LLMToolResult carries only { id, content }. OpenAI requires each
|
|
12
12
|
// role:'tool' message to answer an assistant message carrying a tool_call with
|
|
@@ -63,7 +63,7 @@ export function createOpenRouterProvider(config, streamFn) {
|
|
|
63
63
|
handlers.onTextDelta(delta.content);
|
|
64
64
|
}
|
|
65
65
|
for (const fragment of delta.tool_calls ?? []) {
|
|
66
|
-
const call = toolCalls.get(fragment.index) ?? { id: '', name: '',
|
|
66
|
+
const call = toolCalls.get(fragment.index) ?? { id: '', name: '', json: '' };
|
|
67
67
|
if (fragment.id !== undefined) {
|
|
68
68
|
call.id = fragment.id;
|
|
69
69
|
}
|
|
@@ -71,28 +71,15 @@ export function createOpenRouterProvider(config, streamFn) {
|
|
|
71
71
|
call.name = fragment.function.name;
|
|
72
72
|
}
|
|
73
73
|
if (fragment.function?.arguments !== undefined) {
|
|
74
|
-
call.
|
|
74
|
+
call.json += fragment.function.arguments;
|
|
75
75
|
}
|
|
76
76
|
toolCalls.set(fragment.index, call);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
if (toolCalls.size === 0) {
|
|
80
|
-
// ponytail: turn-end is inferred from the absence of tool calls — we do
|
|
81
|
-
// NOT inspect finish_reason, so a length-truncated text answer renders as
|
|
82
|
-
// a clean end. Acceptable: 4096 tokens is ample for grounded config
|
|
83
|
-
// answers, and a truncated WRITE fails safe (partial tool JSON →
|
|
84
|
-
// parseToolInput → {} → assemble rejects → proposal_invalid). Upgrade
|
|
85
|
-
// path: capture finish_reason into the done label if operators hit it.
|
|
86
|
-
return { stop: 'end', ...(usage !== undefined ? { usage } : {}) };
|
|
87
|
-
}
|
|
88
79
|
const calls = [...toolCalls.entries()]
|
|
89
80
|
.sort(([a], [b]) => a - b)
|
|
90
|
-
.map(([, call]) =>
|
|
91
|
-
|
|
92
|
-
name: call.name,
|
|
93
|
-
input: parseToolInput(call.args),
|
|
94
|
-
}));
|
|
95
|
-
return { stop: 'tool_use', calls, ...(usage !== undefined ? { usage } : {}) };
|
|
81
|
+
.map(([, call]) => call);
|
|
82
|
+
return buildTurnResult(calls, usage);
|
|
96
83
|
},
|
|
97
84
|
};
|
|
98
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-openrouter.js","sourceRoot":"","sources":["../../src/copilot/provider-openrouter.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,iFAAiF;AACjF,sDAAsD;AAEtD,OAAO,MAAM,MAAM,QAAQ,CAAA;AAG3B,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAC3F,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"provider-openrouter.js","sourceRoot":"","sources":["../../src/copilot/provider-openrouter.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,iFAAiF;AACjF,sDAAsD;AAEtD,OAAO,MAAM,MAAM,QAAQ,CAAA;AAG3B,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAUtD,MAAM,mBAAmB,GAAG,8BAA8B,CAAA;AAE1D,8EAA8E;AAC9E,+EAA+E;AAC/E,gFAAgF;AAChF,iFAAiF;AACjF,mEAAmE;AACnE,mFAAmF;AACnF,MAAM,wBAAwB,GAAG,MAAM,CAAA;AAOvC;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAc,EACd,QAAyB;IAEzB,MAAM,UAAU,GAAG,QAAQ,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAA;IAE9D,OAAO;QACL,KAAK,CAAC,UAAU,CACd,KAAmB,EACnB,QAA2B;YAE3B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,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C;QACpE,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;gBAC7C,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,SAAS,EAAE,IAAI,EAAE;aAC9D,CAAC,CAAC;SACJ,CAAC,CAAA;QACF,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACvC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;QACnF,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
// Helpers shared by the Anthropic and OpenRouter LLMProvider adapters.
|
|
2
|
+
/** Normalize completed calls; each adapter owns ordering and usage accounting.
|
|
3
|
+
* Stop is inferred from calls, not provider finish reasons: truncated text still
|
|
4
|
+
* ends cleanly, while malformed tool JSON becomes {} for downstream validation.
|
|
5
|
+
*/
|
|
6
|
+
export function buildTurnResult(blocks, usage) {
|
|
7
|
+
const metering = usage !== undefined ? { usage } : {};
|
|
8
|
+
if (blocks.length === 0)
|
|
9
|
+
return { stop: 'end', ...metering };
|
|
10
|
+
const calls = blocks.map(({ id, name, json }) => ({ id, name, input: parseToolInput(json) }));
|
|
11
|
+
return { stop: 'tool_use', calls, ...metering };
|
|
12
|
+
}
|
|
2
13
|
/**
|
|
3
14
|
* Parse accumulated tool-call argument JSON into an input object. A blank or
|
|
4
15
|
* unparseable value resolves to `{}` so a malformed stream never crashes the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-shared.js","sourceRoot":"","sources":["../../src/copilot/provider-shared.ts"],"names":[],"mappings":"AAAA,uEAAuE;
|
|
1
|
+
{"version":3,"file":"provider-shared.js","sourceRoot":"","sources":["../../src/copilot/provider-shared.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAIvE;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAoD,EACpD,KAA2B;IAE3B,MAAM,QAAQ,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IACrD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC5D,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IAC7F,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAA;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAA;IAC1B,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QACnB,OAAO,EAAE,CAAA;IACX,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC3C,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5E,OAAO,MAAiC,CAAA;QAC1C,CAAC;QACD,OAAO,EAAE,CAAA;IACX,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/** Thrown by the default transcriber when the endpoint answers badly. Carries a
|
|
2
|
+
* status only — never any part of the request or the response body. */
|
|
3
|
+
export class TranscriptionProviderError extends Error {
|
|
4
|
+
status;
|
|
5
|
+
constructor(status) {
|
|
6
|
+
super(status === undefined
|
|
7
|
+
? 'the transcription endpoint could not be reached'
|
|
8
|
+
: `the transcription endpoint answered ${status}`);
|
|
9
|
+
this.name = 'TranscriptionProviderError';
|
|
10
|
+
this.status = status;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Raised when no transcription capability is configured on this deployment. */
|
|
14
|
+
export class SpeechUnconfiguredError extends Error {
|
|
15
|
+
constructor() {
|
|
16
|
+
super('no transcription capability is configured on this server');
|
|
17
|
+
this.name = 'SpeechUnconfiguredError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Describe the capability for the console's pre-flight probe. */
|
|
21
|
+
export function describeSpeechCapability(config) {
|
|
22
|
+
return {
|
|
23
|
+
available: config.speechTranscriptionEndpoint !== undefined,
|
|
24
|
+
region: config.speechTranscriptionRegion,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The default transcriber: POST the raw bytes to the configured in-region
|
|
29
|
+
* endpoint with the region and locale as query parameters, and read back
|
|
30
|
+
* `{ "text": "…" }`. Deliberately generic — no vendor SDK, no vendor name. A
|
|
31
|
+
* concrete adapter replaces this behind the same seam once a provider is chosen.
|
|
32
|
+
*/
|
|
33
|
+
export function createHttpTranscriber(config) {
|
|
34
|
+
const endpoint = config.speechTranscriptionEndpoint;
|
|
35
|
+
if (endpoint === undefined) {
|
|
36
|
+
throw new SpeechUnconfiguredError();
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
async transcribe(audio, request) {
|
|
40
|
+
const url = new URL(endpoint);
|
|
41
|
+
url.searchParams.set('region', request.region);
|
|
42
|
+
if (request.locale !== undefined) {
|
|
43
|
+
url.searchParams.set('locale', request.locale);
|
|
44
|
+
}
|
|
45
|
+
const headers = { 'Content-Type': request.contentType };
|
|
46
|
+
if (config.speechTranscriptionApiKey !== undefined) {
|
|
47
|
+
headers.Authorization = `Bearer ${config.speechTranscriptionApiKey}`;
|
|
48
|
+
}
|
|
49
|
+
let response;
|
|
50
|
+
try {
|
|
51
|
+
// Bounded like every other outbound call this server makes: a hung
|
|
52
|
+
// provider must not pin the request — and the audio buffer with it —
|
|
53
|
+
// open indefinitely. The abort surfaces as the same generic provider
|
|
54
|
+
// error, so no transport detail reaches the caller.
|
|
55
|
+
response = await fetch(url, {
|
|
56
|
+
method: 'POST',
|
|
57
|
+
headers,
|
|
58
|
+
body: audio,
|
|
59
|
+
signal: AbortSignal.timeout(config.timeoutMs),
|
|
60
|
+
// The configured endpoint is validated HTTPS-only, but a redirect is a
|
|
61
|
+
// second destination that validation never saw: a 307/308 would forward
|
|
62
|
+
// the recording — and the bearer key — wherever the provider points.
|
|
63
|
+
// Refuse redirects outright; the failure surfaces as the same generic
|
|
64
|
+
// provider error every other transport fault maps to.
|
|
65
|
+
redirect: 'error',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// The transport error is swallowed on purpose: an undici/agent error can
|
|
70
|
+
// carry the request (headers, body) in its cause chain.
|
|
71
|
+
throw new TranscriptionProviderError();
|
|
72
|
+
}
|
|
73
|
+
if (!response.ok) {
|
|
74
|
+
throw new TranscriptionProviderError(response.status);
|
|
75
|
+
}
|
|
76
|
+
const payload = (await response.json());
|
|
77
|
+
if (typeof payload.text !== 'string') {
|
|
78
|
+
throw new TranscriptionProviderError(response.status);
|
|
79
|
+
}
|
|
80
|
+
return payload.text;
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=speech-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1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9 @@ export function createSseSink(res) {
|
|
|
66
66
|
isClosed: () => closed,
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
+
/** End a failed turn without changing the sink's recoverable-error contract. */
|
|
70
|
+
export function finishWithError(sink, code, detail) {
|
|
71
|
+
sink.error(code, detail);
|
|
72
|
+
sink.done('end');
|
|
73
|
+
}
|
|
69
74
|
//# sourceMappingURL=sse.js.map
|
package/dist/copilot/sse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../src/copilot/sse.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,uEAAuE;AACvE,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,UAAU;AAIV,8EAA8E;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAA;AAmClC;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,GAAmB;IAC/C,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,MAAM,GAAG,KAAK,CAAA;IAElB,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,IAAa,EAAQ,EAAE;QAClD,IAAI,MAAM;YAAE,OAAM;QAClB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,IAAI,CAAA;YACd,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE;gBACjB,cAAc,EAAE,mBAAmB;gBACnC,eAAe,EAAE,UAAU;gBAC3B,UAAU,EAAE,YAAY;aACzB,CAAC,CAAA;QACJ,CAAC;QACD,GAAG,CAAC,KAAK,CAAC,UAAU,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACjE,CAAC,CAAA;IAED,0EAA0E;IAC1E,2EAA2E;IAC3E,2EAA2E;IAC3E,MAAM,SAAS,GAAG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ED,4DAA4D;IAC5D,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAEtB,OAAO;QACL,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC;QACxC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACtD,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC;QAChD,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACxD,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;YACb,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;YACtB,KAAK,EAAE,CAAA;QACT,CAAC;QACD,KAAK;QACL,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM;KACvB,CAAA;AACH,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,eAAe,CAAC,IAAa,EAAE,IAAY,EAAE,MAAc;IACzE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACxB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAClB,CAAC"}
|
|
@@ -130,6 +130,17 @@ ask the operator which column carries each required field and wait for their \
|
|
|
130
130
|
answer. Never guess a column name, never infer one from the header text, and never \
|
|
131
131
|
propose a field map whose columns did not come from the engine or from the \
|
|
132
132
|
operator's own answer. A camt053 source maps itself and needs none of this.
|
|
133
|
+
- A CSV, JSON or XML file can mark each row as a debit or a credit in a column \
|
|
134
|
+
of its own instead of with a sign on the amount; such a file needs \
|
|
135
|
+
\`mapping.direction\` in its field map, an object with \`column\`, \`debit\` \
|
|
136
|
+
and \`credit\`. \`proposeMapping\` never proposes it. Before proposing a field \
|
|
137
|
+
map for a CSV, JSON or XML source, ask the operator whether the file shows a \
|
|
138
|
+
debit with a minus sign on the amount or with a marker in a column of its own. \
|
|
139
|
+
When it is a column, ask which column carries the marker and which value in it \
|
|
140
|
+
means a debit and which a credit. Add \`direction\` only from that answer, never \
|
|
141
|
+
from your own reading of the sample, and never offer a column or a value you saw \
|
|
142
|
+
in the sample for them to confirm. An update replaces the whole mapping, so carry \
|
|
143
|
+
an existing \`direction\` over unchanged unless the operator changes it.
|
|
133
144
|
- The pasted lines are the customer's own data. Do not echo them back, do not \
|
|
134
145
|
quote rows, and do not restate the sample. Refer to columns by name only when you \
|
|
135
146
|
explain what the mapping does.
|
|
@@ -203,6 +214,9 @@ calendar; a United States one on US_FED. If neither is clear, leave the calendar
|
|
|
203
214
|
unset (raw calendar days) and say that in the ledger.
|
|
204
215
|
- A fee deducted before the money arrives makes the context's feeNormalization NET \
|
|
205
216
|
and calls for a fee schedule; a fee billed separately is GROSS.
|
|
217
|
+
- A payment that arrives with the opposite sign of the invoice it settles makes the \
|
|
218
|
+
context's signConvention OPPOSITE; data where every amount is positive and only \
|
|
219
|
+
reversals are negative is SAME.
|
|
206
220
|
|
|
207
221
|
ASK, DO NOT GUESS. Where an answer does not determine a value, ask one short \
|
|
208
222
|
question instead of picking a plausible default. These are never inferred: the \
|
|
@@ -210,8 +224,9 @@ currency of a context or a fee schedule; the number of days in a date lag when \
|
|
|
210
224
|
they only said "later"; the size of a tolerance when they only said "a few cents \
|
|
211
225
|
off"; the settlement calendar when the country is not clear; which of 1:N and N:M \
|
|
212
226
|
applies when the description fits both; every fee rate, fixed charge and tier \
|
|
213
|
-
boundary;
|
|
214
|
-
|
|
227
|
+
boundary; the signConvention when they have not said how a payment appears next \
|
|
228
|
+
to its invoice; and every column name (those come from \`proposeMapping\` or \
|
|
229
|
+
from their own answer, per the mapping rule above).
|
|
215
230
|
|
|
216
231
|
FEES IN THEIR WORDS. Ask what is deducted and by whom, in money terms, and do the \
|
|
217
232
|
translation yourself. "2.9% plus R$0.39 per transaction" is ONE schedule with TWO \
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/copilot/system-prompt.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,EAAE;AACF,4EAA4E;AAC5E,yEAAyE;AACzE,wEAAwE;AACxE,+EAA+E;AAC/E,4EAA4E;AAC5E,2EAA2E;AAC3E,aAAa;AACb,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,+CAA+C;AAC/C,EAAE;AACF,6EAA6E;AAC7E,qEAAqE;AACrE,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,0EAA0E;AAC1E,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAa5E,MAAM,WAAW,GAAG
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/copilot/system-prompt.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,EAAE;AACF,4EAA4E;AAC5E,yEAAyE;AACzE,wEAAwE;AACxE,+EAA+E;AAC/E,4EAA4E;AAC5E,2EAA2E;AAC3E,aAAa;AACb,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,+CAA+C;AAC/C,EAAE;AACF,6EAA6E;AAC7E,qEAAqE;AACrE,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,0EAA0E;AAC1E,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAa5E,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iEAuQ6C,CAAA;AAEjE;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
package/dist/copilot/tools.js
CHANGED
|
@@ -1,27 +1,9 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// 3. ADVISORY — one def per `ADVISORY_ALLOWLIST` member
|
|
8
|
-
// (`buildAdvisoryToolDefs`). POST-shaped operations that COMPUTE an answer and
|
|
9
|
-
// persist nothing, so they execute INLINE like a read: no proposal, no turn
|
|
10
|
-
// end. A confirmation click on "show me what this fee would compute" is
|
|
11
|
-
// friction with no safety value.
|
|
12
|
-
//
|
|
13
|
-
// The advisory list is enumerated BY HAND and never derived from a spec heuristic
|
|
14
|
-
// — "the summary says simulate" is not a safety property. Its whole risk is that a
|
|
15
|
-
// member which actually writes would write with NO human in the loop, so the
|
|
16
|
-
// widening ships with a behavioural guard rather than a textual one:
|
|
17
|
-
// `tests/integration/server/copilot_advisory_no_write_test.go` reads this list,
|
|
18
|
-
// invokes every member against a live matcher, and fails if any row count in the
|
|
19
|
-
// database moved. A positive control in the same test writes on purpose, so a
|
|
20
|
-
// broken snapshot cannot pass the guard vacuously.
|
|
21
|
-
//
|
|
22
|
-
// The index is parsed once and memoized (`getIndex`), mirroring server.ts's
|
|
23
|
-
// boot-index memo so the tool-list builder and the executor share one parse and
|
|
24
|
-
// importing this module never touches the filesystem.
|
|
1
|
+
// Copilot tools: GET reads execute inline; allowlisted writes become proposals
|
|
2
|
+
// requiring human confirmation; explicitly allowlisted non-persistent POSTs run
|
|
3
|
+
// inline as advisory tools. Never infer advisory safety from spec descriptions.
|
|
4
|
+
// tests/integration/server/copilot_advisory_no_write_test.go verifies every
|
|
5
|
+
// advisory operation leaves database row counts unchanged, with a writing control.
|
|
6
|
+
// The immutable operation index is loaded lazily and shared by builders/executors.
|
|
25
7
|
import { requireMatcherClient } from '../auth/request-token.js';
|
|
26
8
|
import { loadSpec } from '../spec/load.js';
|
|
27
9
|
import { InvokeError, Invoker } from '../tools/generic/invoke.js';
|
|
@@ -36,11 +18,8 @@ export function getIndex() {
|
|
|
36
18
|
return indexCache;
|
|
37
19
|
}
|
|
38
20
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* production path is built once; an injected index (tests) is memoized under its
|
|
42
|
-
* own identity, so it never returns another index's stale lists. The def-array
|
|
43
|
-
* synthesis is pure over the immutable index, so caching it is sound.
|
|
21
|
+
* Cache pure tool definitions by immutable index identity, never across distinct
|
|
22
|
+
* injected indexes. The production index is stable for the process lifetime.
|
|
44
23
|
*/
|
|
45
24
|
const toolDefsCache = new WeakMap();
|
|
46
25
|
export function getToolDefs(index) {
|
|
@@ -56,20 +35,9 @@ export function getToolDefs(index) {
|
|
|
56
35
|
return cached;
|
|
57
36
|
}
|
|
58
37
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* maps, and source bindings — across the create/update/delete/archive/restore/
|
|
63
|
-
* reorder/clone verbs the spec declares. This set is the write-barrier's positive
|
|
64
|
-
* gate: an operationId absent from it produces NO write tool def
|
|
65
|
-
* (`buildWriteToolDefs`) and the agent loop never routes a call to the proposal
|
|
66
|
-
* path — structurally unproposable, mirroring how a non-GET op is unreadable.
|
|
67
|
-
* Exception, match-run, ingestion, discovery, governance and scheduling
|
|
68
|
-
* mutations are deliberately excluded. The simulate/preview POST-shaped "reads"
|
|
69
|
-
* are excluded from THIS list for the opposite reason — they mutate nothing, so
|
|
70
|
-
* there is nothing to confirm; two of them (`proposeMapping`,
|
|
71
|
-
* `simulateFeeSchedule`) are advertised and executed inline through
|
|
72
|
-
* `ADVISORY_ALLOWLIST` below, and the rest are advertised nowhere.
|
|
38
|
+
* Configuration writes the agent may PROPOSE, never execute. Membership gates
|
|
39
|
+
* both advertised write tools and proposal routing. Other mutation families are
|
|
40
|
+
* excluded; non-persistent advisory operations have their own disjoint allowlist.
|
|
73
41
|
*/
|
|
74
42
|
export const WRITE_ALLOWLIST = new Set([
|
|
75
43
|
// match rules
|
|
@@ -106,28 +74,9 @@ export const WRITE_ALLOWLIST = new Set([
|
|
|
106
74
|
'deleteSourceBinding',
|
|
107
75
|
]);
|
|
108
76
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* - `proposeMapping` — the deterministic column-mapping engine. Refusing it does
|
|
114
|
-
* not remove the mapping decision, it moves it from an engine in production to
|
|
115
|
-
* a language model's reading of a pasted header, at the exact step where being
|
|
116
|
-
* wrong means reconciling the wrong column against money.
|
|
117
|
-
* - `simulateFeeSchedule` — computes a fee breakdown for a gross amount.
|
|
118
|
-
*
|
|
119
|
-
* MEMBERSHIP IS THE WHOLE RISK: an advisory member bypasses the proposal barrier,
|
|
120
|
-
* so a member that writes would write with no confirmation. Two rules follow, and
|
|
121
|
-
* both are asserted rather than documented — see this module's header for the
|
|
122
|
-
* behavioural database guard, and `tools.test.ts` for the disjointness assertion
|
|
123
|
-
* against `WRITE_ALLOWLIST`. Gate ORDERING in `runAgentTurn` is load-bearing:
|
|
124
|
-
* `WRITE_ALLOWLIST` is consulted first, so an id on both lists would take the
|
|
125
|
-
* proposal path and stop the turn — failing toward the human gate, but silently
|
|
126
|
-
* breaking this list's execute-inline contract. The disjointness assertion is
|
|
127
|
-
* what keeps that state unrepresentable rather than order-dependent.
|
|
128
|
-
*
|
|
129
|
-
* `suggestMatchRules` is NOT here and must not be: it persists a PENDING_REVIEW
|
|
130
|
-
* row, so it is a write. Advisory means genuinely non-persistent, not "low stakes".
|
|
77
|
+
* Inline advisory POSTs must persist nothing and remain disjoint from writes
|
|
78
|
+
* (tools.test.ts). The write gate runs first as a fail-safe, not a substitute for
|
|
79
|
+
* disjointness. `suggestMatchRules` persists PENDING_REVIEW and is not advisory.
|
|
131
80
|
*/
|
|
132
81
|
export const ADVISORY_ALLOWLIST = new Set([
|
|
133
82
|
'proposeMapping',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/copilot/tools.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/copilot/tools.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,gFAAgF;AAChF,gFAAgF;AAChF,4EAA4E;AAC5E,mFAAmF;AACnF,mFAAmF;AAEnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAG/D,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAG1D;6DAC6D;AAC7D,IAAI,UAAsC,CAAA;AAE1C,MAAM,UAAU,QAAQ;IACtB,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,UAAU,GAAG,QAAQ,EAAE,CAAC,KAAK,CAAA;IAC/B,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AASD;;;GAGG;AACH,MAAM,aAAa,GAAG,IAAI,OAAO,EAA4B,CAAA;AAE7D,MAAM,UAAU,WAAW,CAAC,KAAqB;IAC/C,IAAI,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACrC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,GAAG;YACP,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAAC;YAC9B,KAAK,EAAE,kBAAkB,CAAC,KAAK,CAAC;YAChC,QAAQ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