@try-works/dsh-model-as-tool 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/bin/dsh-tool-mode-mcp-stdio.mjs +80 -0
- package/catalog/desert-ant-models.json +77 -13
- package/lib/adapters/index.d.ts +19 -6
- package/lib/adapters/index.d.ts.map +1 -1
- package/lib/adapters/index.js +28 -13
- package/lib/adapters/tongue.d.ts +11 -3
- package/lib/adapters/tongue.d.ts.map +1 -1
- package/lib/adapters/tongue.js +12 -4
- package/lib/adapters/types.d.ts +11 -0
- package/lib/adapters/types.d.ts.map +1 -1
- package/lib/adapters/voz.d.ts +7 -1
- package/lib/adapters/voz.d.ts.map +1 -1
- package/lib/adapters/voz.js +16 -4
- package/lib/asset-acquisition.d.ts +137 -0
- package/lib/asset-acquisition.d.ts.map +1 -0
- package/lib/asset-acquisition.js +161 -0
- package/lib/authority.d.ts +153 -0
- package/lib/authority.d.ts.map +1 -0
- package/lib/authority.js +194 -0
- package/lib/bindings.d.ts +115 -0
- package/lib/bindings.d.ts.map +1 -0
- package/lib/bindings.js +239 -0
- package/lib/catalog.d.ts.map +1 -1
- package/lib/catalog.js +57 -0
- package/lib/contract-payload.d.ts +47 -0
- package/lib/contract-payload.d.ts.map +1 -0
- package/lib/contract-payload.js +137 -0
- package/lib/deployment-coordinator.d.ts +213 -0
- package/lib/deployment-coordinator.d.ts.map +1 -0
- package/lib/deployment-coordinator.js +274 -0
- package/lib/harness-budgets.d.ts +158 -0
- package/lib/harness-budgets.d.ts.map +1 -0
- package/lib/harness-budgets.js +152 -0
- package/lib/index.d.ts +41 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +424 -16
- package/lib/licensing.d.ts +221 -0
- package/lib/licensing.d.ts.map +1 -0
- package/lib/licensing.js +188 -0
- package/lib/mcp/host-binding.d.ts +91 -0
- package/lib/mcp/host-binding.d.ts.map +1 -0
- package/lib/mcp/host-binding.js +133 -0
- package/lib/mcp/http.d.ts +130 -0
- package/lib/mcp/http.d.ts.map +1 -0
- package/lib/mcp/http.js +274 -0
- package/lib/mcp/protocol.d.ts +261 -0
- package/lib/mcp/protocol.d.ts.map +1 -0
- package/lib/mcp/protocol.js +387 -0
- package/lib/mcp/server.d.ts +115 -0
- package/lib/mcp/server.d.ts.map +1 -0
- package/lib/mcp/server.js +200 -0
- package/lib/mcp/stdio.d.ts +80 -0
- package/lib/mcp/stdio.d.ts.map +1 -0
- package/lib/mcp/stdio.js +176 -0
- package/lib/mcp/subscriptions.d.ts +135 -0
- package/lib/mcp/subscriptions.d.ts.map +1 -0
- package/lib/mcp/subscriptions.js +207 -0
- package/lib/provider-bridge.d.ts +69 -0
- package/lib/provider-bridge.d.ts.map +1 -0
- package/lib/provider-bridge.js +218 -0
- package/lib/publication.d.ts +160 -0
- package/lib/publication.d.ts.map +1 -0
- package/lib/publication.js +173 -0
- package/lib/receipt.d.ts +208 -0
- package/lib/receipt.d.ts.map +1 -0
- package/lib/receipt.js +150 -0
- package/lib/registrar.d.ts +13 -0
- package/lib/registrar.d.ts.map +1 -1
- package/lib/registrar.js +20 -3
- package/lib/resource-governance.d.ts +204 -0
- package/lib/resource-governance.d.ts.map +1 -0
- package/lib/resource-governance.js +213 -0
- package/lib/server-lifecycle.d.ts +175 -0
- package/lib/server-lifecycle.d.ts.map +1 -0
- package/lib/server-lifecycle.js +269 -0
- package/lib/types.d.ts +21 -0
- package/lib/types.d.ts.map +1 -1
- package/package.json +9 -2
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness budgets and foreground invocation semantics (RES-08, RES-10).
|
|
3
|
+
*
|
|
4
|
+
* Two rules here exist to stop a system reporting something it does not know.
|
|
5
|
+
*
|
|
6
|
+
* - **Unknown cost stays unknown** (RES-10). A budget report has three states for
|
|
7
|
+
* money: a known amount, "no monetary budget applies", and UNKNOWN. Collapsing
|
|
8
|
+
* unknown into zero reports a paid call as free, which is the failure the
|
|
9
|
+
* requirement names.
|
|
10
|
+
* - **A foreground invocation is not a job** (RES-08). It is cancelled or it finishes;
|
|
11
|
+
* it is never replayed on reconnect, because a call that may already have run is not
|
|
12
|
+
* safely repeatable — the result could be billed or delivered twice.
|
|
13
|
+
*
|
|
14
|
+
* The initial per-leaf maxima are the numbers the requirement states, asserted
|
|
15
|
+
* individually, because a budget that drifts silently is a limit nobody agreed to.
|
|
16
|
+
*
|
|
17
|
+
* @module @try-works/dsh-model-as-tool/harness-budgets
|
|
18
|
+
*/
|
|
19
|
+
/** A spending figure that may genuinely be unknown (RES-10). */
|
|
20
|
+
export type MonetaryAmount =
|
|
21
|
+
/** A known amount in a named currency. */
|
|
22
|
+
{
|
|
23
|
+
readonly known: true;
|
|
24
|
+
readonly currency: string;
|
|
25
|
+
readonly amount: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The cost is not known.
|
|
29
|
+
*
|
|
30
|
+
* Distinct from a zero amount: a zero would report a call that may be billed as
|
|
31
|
+
* free.
|
|
32
|
+
*/
|
|
33
|
+
| {
|
|
34
|
+
readonly known: false;
|
|
35
|
+
readonly reason: string;
|
|
36
|
+
};
|
|
37
|
+
/** Limits for one tool invocation (RES-10). */
|
|
38
|
+
export interface HarnessBudget {
|
|
39
|
+
/** Provider attempts permitted. The initial maximum is ONE. */
|
|
40
|
+
readonly providerAttempts: number;
|
|
41
|
+
/** Whether an automatic repair pass is permitted. The initial maximum is NONE. */
|
|
42
|
+
readonly automaticRepairs: number;
|
|
43
|
+
/** Wall-clock deadline in seconds. The initial maximum is 60. */
|
|
44
|
+
readonly deadlineSeconds: number;
|
|
45
|
+
/** Output tokens permitted. The initial maximum is 1024. */
|
|
46
|
+
readonly outputTokens: number;
|
|
47
|
+
/** Image inputs permitted. The initial maximum is 2. */
|
|
48
|
+
readonly imageInputs: number;
|
|
49
|
+
/** Model calls permitted, when a server grant sets one. */
|
|
50
|
+
readonly modelCalls: number | null;
|
|
51
|
+
/** Whether remote model destinations are permitted at all. */
|
|
52
|
+
readonly remoteDestinations: boolean;
|
|
53
|
+
/** The monetary budget, when one applies. */
|
|
54
|
+
readonly monetary: MonetaryAmount;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The initial per-leaf maxima (RES-10).
|
|
58
|
+
*
|
|
59
|
+
* A reviewed recipe or profile may LOWER these, or explicitly permit one repair under
|
|
60
|
+
* the same root deadline and accounting. It may not raise them silently.
|
|
61
|
+
*/
|
|
62
|
+
export declare const INITIAL_BUDGET: HarnessBudget;
|
|
63
|
+
/** A local-only profile, which forbids remote destinations however the tool was built. */
|
|
64
|
+
export declare const LOCAL_ONLY_BUDGET: HarnessBudget;
|
|
65
|
+
/**
|
|
66
|
+
* Narrow a budget by a requested reduction (RES-10).
|
|
67
|
+
*
|
|
68
|
+
* Every figure takes the MINIMUM, so a request can only ever lower a limit. That
|
|
69
|
+
* direction is the point: a caller asking for more than the profile permits gets the
|
|
70
|
+
* profile's figure, not its own.
|
|
71
|
+
* @param base - the budget in force.
|
|
72
|
+
* @param requested - what the caller asked for.
|
|
73
|
+
* @returns the effective budget.
|
|
74
|
+
*/
|
|
75
|
+
export declare function narrowBudget(base: HarnessBudget, requested: Partial<HarnessBudget>): HarnessBudget;
|
|
76
|
+
/**
|
|
77
|
+
* Whether a repair pass may run (RES-10).
|
|
78
|
+
*
|
|
79
|
+
* The initial maximum is none, and a repair is only permitted when a reviewed profile
|
|
80
|
+
* explicitly allowed one AND the same root deadline still has time in it — a repair
|
|
81
|
+
* that consumes a fresh deadline would evade the budget rather than fit inside it.
|
|
82
|
+
* @param budget - the effective budget.
|
|
83
|
+
* @param repairsSoFar - repairs already performed.
|
|
84
|
+
* @param remainingSeconds - time left on the ROOT deadline.
|
|
85
|
+
* @returns whether to repair.
|
|
86
|
+
*/
|
|
87
|
+
export declare function mayRepair(budget: HarnessBudget, repairsSoFar: number, remainingSeconds: number): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Whether another provider attempt may run (RES-10).
|
|
90
|
+
* @param budget - the effective budget.
|
|
91
|
+
* @param attemptsSoFar - attempts already made.
|
|
92
|
+
* @returns whether to attempt.
|
|
93
|
+
*/
|
|
94
|
+
export declare function mayAttempt(budget: HarnessBudget, attemptsSoFar: number): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Render a monetary figure for a report (RES-10).
|
|
97
|
+
*
|
|
98
|
+
* An unknown cost is reported as unknown. Reporting it as zero would present a call
|
|
99
|
+
* that may be billed as free, which is the specific failure the requirement names.
|
|
100
|
+
* @param amount - the figure.
|
|
101
|
+
* @returns the reportable string.
|
|
102
|
+
*/
|
|
103
|
+
export declare function describeCost(amount: MonetaryAmount): string;
|
|
104
|
+
/**
|
|
105
|
+
* Whether a budget permits reaching a remote destination (RES-10).
|
|
106
|
+
*
|
|
107
|
+
* A local-only profile prohibits remote destinations INDEPENDENTLY of how the tool was
|
|
108
|
+
* implemented, so this asks the budget rather than the implementation.
|
|
109
|
+
* @param budget - the effective budget.
|
|
110
|
+
* @param destination - the destination being considered.
|
|
111
|
+
* @returns whether it is permitted.
|
|
112
|
+
*/
|
|
113
|
+
export declare function permitsDestination(budget: HarnessBudget, destination: 'local' | 'remote'): boolean;
|
|
114
|
+
/** How a foreground invocation ended (RES-08). */
|
|
115
|
+
export type InvocationEnd =
|
|
116
|
+
/** The tool completed normally. */
|
|
117
|
+
{
|
|
118
|
+
readonly kind: 'completed';
|
|
119
|
+
}
|
|
120
|
+
/** The tool failed; the failure is the result. */
|
|
121
|
+
| {
|
|
122
|
+
readonly kind: 'failed';
|
|
123
|
+
readonly reason: string;
|
|
124
|
+
}
|
|
125
|
+
/** Cancellation was requested and honoured on the originating stream. */
|
|
126
|
+
| {
|
|
127
|
+
readonly kind: 'cancelled';
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The connection dropped without an answer.
|
|
131
|
+
*
|
|
132
|
+
* Distinct from `failed`, because there is no result to report — and distinct from
|
|
133
|
+
* `completed`, because the call may have run.
|
|
134
|
+
*/
|
|
135
|
+
| {
|
|
136
|
+
readonly kind: 'disconnected';
|
|
137
|
+
readonly mayHaveRun: boolean;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Whether an interrupted foreground invocation may be REPLAYED on reconnect (RES-08).
|
|
141
|
+
*
|
|
142
|
+
* Never. A foreground invocation is not a persistent job, and the requirement forbids
|
|
143
|
+
* automatically replaying completed or uncertain calls: a call that may already have
|
|
144
|
+
* run is not safely repeatable, because its effects could be billed or delivered
|
|
145
|
+
* twice. A retry is a NEW request with fresh authorization and budget.
|
|
146
|
+
* @returns always false.
|
|
147
|
+
*/
|
|
148
|
+
export declare function mayReplayAfterReconnect(): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Whether a dropped connection should be reported as ambiguous (RES-08, P26-07).
|
|
151
|
+
*
|
|
152
|
+
* It should, whenever the work may have run: the client cannot otherwise tell a call
|
|
153
|
+
* that never started from one that completed and whose response was lost.
|
|
154
|
+
* @param mayHaveRun - whether work had started.
|
|
155
|
+
* @returns whether the completion is ambiguous.
|
|
156
|
+
*/
|
|
157
|
+
export declare function isAmbiguousCompletion(mayHaveRun: boolean): boolean;
|
|
158
|
+
//# sourceMappingURL=harness-budgets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness-budgets.d.ts","sourceRoot":"","sources":["../src/harness-budgets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,gEAAgE;AAChE,MAAM,MAAM,cAAc;AACxB,0CAA0C;AACxC;IAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AAC9E;;;;;GAKG;GACD;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE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kDAAkD;AAClD,MAAM,MAAM,aAAa;AACvB,mCAAmC;AACjC;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAE;AAChC,kDAAkD;GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACtD,yEAAyE;GACvE;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAE;AAChC;;;;;GAKG;GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAA;AAEnE;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,CAElE"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness budgets and foreground invocation semantics (RES-08, RES-10).
|
|
3
|
+
*
|
|
4
|
+
* Two rules here exist to stop a system reporting something it does not know.
|
|
5
|
+
*
|
|
6
|
+
* - **Unknown cost stays unknown** (RES-10). A budget report has three states for
|
|
7
|
+
* money: a known amount, "no monetary budget applies", and UNKNOWN. Collapsing
|
|
8
|
+
* unknown into zero reports a paid call as free, which is the failure the
|
|
9
|
+
* requirement names.
|
|
10
|
+
* - **A foreground invocation is not a job** (RES-08). It is cancelled or it finishes;
|
|
11
|
+
* it is never replayed on reconnect, because a call that may already have run is not
|
|
12
|
+
* safely repeatable — the result could be billed or delivered twice.
|
|
13
|
+
*
|
|
14
|
+
* The initial per-leaf maxima are the numbers the requirement states, asserted
|
|
15
|
+
* individually, because a budget that drifts silently is a limit nobody agreed to.
|
|
16
|
+
*
|
|
17
|
+
* @module @try-works/dsh-model-as-tool/harness-budgets
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* The initial per-leaf maxima (RES-10).
|
|
21
|
+
*
|
|
22
|
+
* A reviewed recipe or profile may LOWER these, or explicitly permit one repair under
|
|
23
|
+
* the same root deadline and accounting. It may not raise them silently.
|
|
24
|
+
*/
|
|
25
|
+
export const INITIAL_BUDGET = {
|
|
26
|
+
providerAttempts: 1,
|
|
27
|
+
automaticRepairs: 0,
|
|
28
|
+
deadlineSeconds: 60,
|
|
29
|
+
outputTokens: 1024,
|
|
30
|
+
imageInputs: 2,
|
|
31
|
+
modelCalls: null,
|
|
32
|
+
remoteDestinations: true,
|
|
33
|
+
monetary: { known: false, reason: 'no monetary budget was configured for this invocation' },
|
|
34
|
+
};
|
|
35
|
+
/** A local-only profile, which forbids remote destinations however the tool was built. */
|
|
36
|
+
export const LOCAL_ONLY_BUDGET = {
|
|
37
|
+
...INITIAL_BUDGET,
|
|
38
|
+
remoteDestinations: false,
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Narrow a budget by a requested reduction (RES-10).
|
|
42
|
+
*
|
|
43
|
+
* Every figure takes the MINIMUM, so a request can only ever lower a limit. That
|
|
44
|
+
* direction is the point: a caller asking for more than the profile permits gets the
|
|
45
|
+
* profile's figure, not its own.
|
|
46
|
+
* @param base - the budget in force.
|
|
47
|
+
* @param requested - what the caller asked for.
|
|
48
|
+
* @returns the effective budget.
|
|
49
|
+
*/
|
|
50
|
+
export function narrowBudget(base, requested) {
|
|
51
|
+
const lower = (a, b) => (b === undefined ? a : Math.min(a, b));
|
|
52
|
+
/**
|
|
53
|
+
* A nullable limit narrows the same way, with `null` meaning "no limit set".
|
|
54
|
+
*
|
|
55
|
+
* A request can INTRODUCE one where the base had none, and can only lower it where
|
|
56
|
+
* the base already had one — so a caller can never widen a grant by asking.
|
|
57
|
+
*/
|
|
58
|
+
const lowerNullable = (a, b) => {
|
|
59
|
+
if (b === undefined)
|
|
60
|
+
return a;
|
|
61
|
+
if (a === null)
|
|
62
|
+
return b;
|
|
63
|
+
if (b === null)
|
|
64
|
+
return a;
|
|
65
|
+
return Math.min(a, b);
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
providerAttempts: lower(base.providerAttempts, requested.providerAttempts),
|
|
69
|
+
automaticRepairs: lower(base.automaticRepairs, requested.automaticRepairs),
|
|
70
|
+
deadlineSeconds: lower(base.deadlineSeconds, requested.deadlineSeconds),
|
|
71
|
+
outputTokens: lower(base.outputTokens, requested.outputTokens),
|
|
72
|
+
imageInputs: lower(base.imageInputs, requested.imageInputs),
|
|
73
|
+
modelCalls: lowerNullable(base.modelCalls, requested.modelCalls),
|
|
74
|
+
// A reduction can never ENABLE remote destinations, so this is an AND.
|
|
75
|
+
remoteDestinations: base.remoteDestinations && (requested.remoteDestinations ?? true),
|
|
76
|
+
monetary: base.monetary,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Whether a repair pass may run (RES-10).
|
|
81
|
+
*
|
|
82
|
+
* The initial maximum is none, and a repair is only permitted when a reviewed profile
|
|
83
|
+
* explicitly allowed one AND the same root deadline still has time in it — a repair
|
|
84
|
+
* that consumes a fresh deadline would evade the budget rather than fit inside it.
|
|
85
|
+
* @param budget - the effective budget.
|
|
86
|
+
* @param repairsSoFar - repairs already performed.
|
|
87
|
+
* @param remainingSeconds - time left on the ROOT deadline.
|
|
88
|
+
* @returns whether to repair.
|
|
89
|
+
*/
|
|
90
|
+
export function mayRepair(budget, repairsSoFar, remainingSeconds) {
|
|
91
|
+
if (budget.automaticRepairs <= repairsSoFar)
|
|
92
|
+
return false;
|
|
93
|
+
return remainingSeconds > 0;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Whether another provider attempt may run (RES-10).
|
|
97
|
+
* @param budget - the effective budget.
|
|
98
|
+
* @param attemptsSoFar - attempts already made.
|
|
99
|
+
* @returns whether to attempt.
|
|
100
|
+
*/
|
|
101
|
+
export function mayAttempt(budget, attemptsSoFar) {
|
|
102
|
+
return attemptsSoFar < budget.providerAttempts;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Render a monetary figure for a report (RES-10).
|
|
106
|
+
*
|
|
107
|
+
* An unknown cost is reported as unknown. Reporting it as zero would present a call
|
|
108
|
+
* that may be billed as free, which is the specific failure the requirement names.
|
|
109
|
+
* @param amount - the figure.
|
|
110
|
+
* @returns the reportable string.
|
|
111
|
+
*/
|
|
112
|
+
export function describeCost(amount) {
|
|
113
|
+
return amount.known
|
|
114
|
+
? `${amount.amount} ${amount.currency}`
|
|
115
|
+
: `unknown (${amount.reason})`;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Whether a budget permits reaching a remote destination (RES-10).
|
|
119
|
+
*
|
|
120
|
+
* A local-only profile prohibits remote destinations INDEPENDENTLY of how the tool was
|
|
121
|
+
* implemented, so this asks the budget rather than the implementation.
|
|
122
|
+
* @param budget - the effective budget.
|
|
123
|
+
* @param destination - the destination being considered.
|
|
124
|
+
* @returns whether it is permitted.
|
|
125
|
+
*/
|
|
126
|
+
export function permitsDestination(budget, destination) {
|
|
127
|
+
return destination === 'local' ? true : budget.remoteDestinations;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Whether an interrupted foreground invocation may be REPLAYED on reconnect (RES-08).
|
|
131
|
+
*
|
|
132
|
+
* Never. A foreground invocation is not a persistent job, and the requirement forbids
|
|
133
|
+
* automatically replaying completed or uncertain calls: a call that may already have
|
|
134
|
+
* run is not safely repeatable, because its effects could be billed or delivered
|
|
135
|
+
* twice. A retry is a NEW request with fresh authorization and budget.
|
|
136
|
+
* @returns always false.
|
|
137
|
+
*/
|
|
138
|
+
export function mayReplayAfterReconnect() {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Whether a dropped connection should be reported as ambiguous (RES-08, P26-07).
|
|
143
|
+
*
|
|
144
|
+
* It should, whenever the work may have run: the client cannot otherwise tell a call
|
|
145
|
+
* that never started from one that completed and whose response was lost.
|
|
146
|
+
* @param mayHaveRun - whether work had started.
|
|
147
|
+
* @returns whether the completion is ambiguous.
|
|
148
|
+
*/
|
|
149
|
+
export function isAmbiguousCompletion(mayHaveRun) {
|
|
150
|
+
return mayHaveRun;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=harness-budgets.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -16,6 +16,11 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
16
16
|
import z from '@deepseek-ai/schemastery';
|
|
17
17
|
export declare const name = "model-tools";
|
|
18
18
|
export declare const inject: string[];
|
|
19
|
+
/**
|
|
20
|
+
* This package's version, stamped into every result as `extensionVersion`.
|
|
21
|
+
* Kept as a literal so the runtime does not depend on reading its own manifest.
|
|
22
|
+
*/
|
|
23
|
+
export declare const MAX_RETAINED_RECEIPTS = 200;
|
|
19
24
|
/** Plugin configuration. */
|
|
20
25
|
export interface Config {
|
|
21
26
|
/** Catalog document to load; defaults to the bundled Desert Ant catalog. */
|
|
@@ -84,6 +89,42 @@ export interface Config {
|
|
|
84
89
|
* restores the earlier session-scoped behaviour.
|
|
85
90
|
*/
|
|
86
91
|
persist?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Which model serves each standard contract, as `{ "stt.transcribe": "voz" }`.
|
|
94
|
+
*
|
|
95
|
+
* Provider selection is host configuration (BASE-02), not something a caller
|
|
96
|
+
* chooses per call. An override naming a model that cannot run here is ignored
|
|
97
|
+
* in favour of the first eligible implementation rather than silently
|
|
98
|
+
* registering a tool that would fail.
|
|
99
|
+
*/
|
|
100
|
+
providers?: Record<string, string>;
|
|
101
|
+
/**
|
|
102
|
+
* Register the deprecated per-model compatibility aliases.
|
|
103
|
+
*
|
|
104
|
+
* Off by default so they stay out of the default catalog and a caller sees one
|
|
105
|
+
* transcription tool rather than two (BASE-03). When on, the alias keeps its
|
|
106
|
+
* original argument and result contract through a tested adapter — it is never
|
|
107
|
+
* silently reinterpreted as the new contract.
|
|
108
|
+
*/
|
|
109
|
+
legacyAliases?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Filesystem roots this deployment authorizes (SEC-06).
|
|
112
|
+
*
|
|
113
|
+
* Empty by default, which fails closed: a path-bearing tool then refuses every
|
|
114
|
+
* call rather than admitting an arbitrary path. An operator adds the roots this
|
|
115
|
+
* machine may read from.
|
|
116
|
+
*/
|
|
117
|
+
approvedRoots?: string[];
|
|
118
|
+
/** Grant identity recorded in receipts; defaults to `local-interactive`. */
|
|
119
|
+
grantId?: string;
|
|
120
|
+
/** Whether receipts may be recorded (SEC-03); default true. */
|
|
121
|
+
recordReceipts?: boolean;
|
|
122
|
+
/** Hard resource limits overriding the conservative defaults. */
|
|
123
|
+
limits?: {
|
|
124
|
+
maxInputBytes?: number;
|
|
125
|
+
maxAudioSeconds?: number;
|
|
126
|
+
maxResultBytes?: number;
|
|
127
|
+
};
|
|
87
128
|
}
|
|
88
129
|
/** Validate and default the plugin configuration. */
|
|
89
130
|
export declare const Config: z<Config>;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AA+BxC,eAAO,MAAM,IAAI,gBAAgB,CAAA;AACjC,eAAO,MAAM,MAAM,UAAY,CAAA;AAE/B;;;GAGG;AACH,eACA,MAAM,qBAAqB,MAAM,CAAA;AAIjC,4BAA4B;AAC5B,MAAM,WAAW,MAAM;IACrB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAA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