@dudousxd/nestjs-agent-opencode 0.4.1 → 1.0.0
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 +1 -1
- package/dist/durable/index.cjs +69 -57
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.js +14 -2
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +67 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -188,7 +188,7 @@ The endpoint serves turns, nothing else. A token alone runs nothing:
|
|
|
188
188
|
- `remember` is served here only — it is not added to the module's registry, so it is not on
|
|
189
189
|
`AgentMcpServerModule` or the `/tools` catalog.
|
|
190
190
|
|
|
191
|
-
The module's `
|
|
191
|
+
The module's `decorators` are not applied to the endpoint (its callers are OpenCode sessions, not the
|
|
192
192
|
app's users); a global guard of your own must let `opencode/mcp` through.
|
|
193
193
|
|
|
194
194
|
## Several processes
|
package/dist/durable/index.cjs
CHANGED
|
@@ -47,6 +47,7 @@ var InMemoryOpenCodeSessionStore = class {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
// src/mcp.controller.ts
|
|
50
|
+
var import_nestjs_agent_core = require("@dudousxd/nestjs-agent-core");
|
|
50
51
|
var import_common = require("@nestjs/common");
|
|
51
52
|
|
|
52
53
|
// src/tokens.ts
|
|
@@ -143,6 +144,7 @@ _ts_decorate([
|
|
|
143
144
|
_ts_metadata("design:returntype", void 0)
|
|
144
145
|
], OpenCodeMcpController.prototype, "delete", null);
|
|
145
146
|
OpenCodeMcpController = _ts_decorate([
|
|
147
|
+
(0, import_nestjs_agent_core.CanAnyone)(),
|
|
146
148
|
(0, import_common.Controller)("opencode/mcp"),
|
|
147
149
|
_ts_param(0, (0, import_common.Inject)(OPENCODE_MCP_ENDPOINT)),
|
|
148
150
|
_ts_metadata("design:type", Function),
|
|
@@ -153,7 +155,7 @@ OpenCodeMcpController = _ts_decorate([
|
|
|
153
155
|
|
|
154
156
|
// src/mcp.ts
|
|
155
157
|
var import_node_crypto = require("crypto");
|
|
156
|
-
var
|
|
158
|
+
var import_nestjs_agent_core4 = require("@dudousxd/nestjs-agent-core");
|
|
157
159
|
var import_genui = require("@dudousxd/nestjs-agent-core/genui");
|
|
158
160
|
var import_server = require("@modelcontextprotocol/sdk/server/index.js");
|
|
159
161
|
var import_streamableHttp = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
@@ -161,11 +163,11 @@ var import_zod_json_schema_compat = require("@modelcontextprotocol/sdk/server/zo
|
|
|
161
163
|
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
162
164
|
|
|
163
165
|
// src/turn.ts
|
|
164
|
-
var
|
|
166
|
+
var import_nestjs_agent_core3 = require("@dudousxd/nestjs-agent-core");
|
|
165
167
|
var import_common2 = require("@nestjs/common");
|
|
166
168
|
|
|
167
169
|
// src/forms.ts
|
|
168
|
-
var
|
|
170
|
+
var import_nestjs_agent_core2 = require("@dudousxd/nestjs-agent-core");
|
|
169
171
|
function toQuestion(field) {
|
|
170
172
|
const required = field.required === true ? {
|
|
171
173
|
required: true
|
|
@@ -235,7 +237,7 @@ function toFormAnswer(form, answers = {}) {
|
|
|
235
237
|
for (const field of formFields(form)) {
|
|
236
238
|
const question = toQuestion(field);
|
|
237
239
|
const values = answers[field.key] ?? question.defaults ?? [];
|
|
238
|
-
const problem = (0,
|
|
240
|
+
const problem = (0, import_nestjs_agent_core2.validateElicitationAnswer)(question, values);
|
|
239
241
|
if (problem) throw new FormAnswerError(`answers["${field.key}"] ${problem}`);
|
|
240
242
|
const present = values.filter((v) => v !== "");
|
|
241
243
|
const [value] = present;
|
|
@@ -547,7 +549,7 @@ var OpenCodeTurn = class {
|
|
|
547
549
|
});
|
|
548
550
|
}
|
|
549
551
|
async write(event) {
|
|
550
|
-
await this.a.writer.write((0,
|
|
552
|
+
await this.a.writer.write((0, import_nestjs_agent_core3.encodeStreamEvent)(event));
|
|
551
553
|
}
|
|
552
554
|
async step() {
|
|
553
555
|
if (this.stepOpen) return;
|
|
@@ -1081,7 +1083,7 @@ ${delta}` : delta;
|
|
|
1081
1083
|
const ttlMs = requirement.ttlMs !== void 0 && Number.isFinite(requirement.ttlMs) && requirement.ttlMs > 0 ? Math.floor(requirement.ttlMs) : void 0;
|
|
1082
1084
|
const expiresAt = ttlMs !== void 0 ? new Date(Date.now() + ttlMs).toISOString() : void 0;
|
|
1083
1085
|
const tool = this.a.approvalPresentation?.(action);
|
|
1084
|
-
const confirmation = tool !== void 0 ? (0,
|
|
1086
|
+
const confirmation = tool !== void 0 ? (0, import_nestjs_agent_core3.resolveToolConfirmation)(tool.name, args, tool.presentation) : void 0;
|
|
1085
1087
|
this.segment.calls.push({
|
|
1086
1088
|
id: req.id,
|
|
1087
1089
|
name: action,
|
|
@@ -1308,7 +1310,7 @@ ${delta}` : delta;
|
|
|
1308
1310
|
answer: toFormAnswer(form, answer.answers)
|
|
1309
1311
|
});
|
|
1310
1312
|
}
|
|
1311
|
-
const result = (0,
|
|
1313
|
+
const result = (0, import_nestjs_agent_core3.settleElicitation)(request, answer);
|
|
1312
1314
|
await this.a.store.updateToolCall({
|
|
1313
1315
|
toolCallId: form.id,
|
|
1314
1316
|
status: result.skipped ? "rejected" : "executed",
|
|
@@ -1663,7 +1665,7 @@ function isZodSchema(schema) {
|
|
|
1663
1665
|
}
|
|
1664
1666
|
__name(isZodSchema, "isZodSchema");
|
|
1665
1667
|
function toInputSchema(schema) {
|
|
1666
|
-
const extension = (0,
|
|
1668
|
+
const extension = (0, import_nestjs_agent_core4.schemaExtensionOf)(schema);
|
|
1667
1669
|
if (extension !== void 0) {
|
|
1668
1670
|
const base = toInputSchema(extension.base);
|
|
1669
1671
|
const properties = {
|
|
@@ -1707,7 +1709,7 @@ var OpenCodeMcpEndpoint2 = class {
|
|
|
1707
1709
|
turns;
|
|
1708
1710
|
tokens;
|
|
1709
1711
|
/** Genui telemetry of the UI calls OpenCode makes (its code mode calls tools here, not in the loop). */
|
|
1710
|
-
genui = new
|
|
1712
|
+
genui = new import_nestjs_agent_core4.GenuiRunRecorder();
|
|
1711
1713
|
constructor(turns, tokens) {
|
|
1712
1714
|
this.turns = turns;
|
|
1713
1715
|
this.tokens = tokens;
|
|
@@ -1788,9 +1790,9 @@ var OpenCodeMcpEndpoint2 = class {
|
|
|
1788
1790
|
}));
|
|
1789
1791
|
if (this.turns.memoryWritable()) {
|
|
1790
1792
|
tools.push({
|
|
1791
|
-
name:
|
|
1792
|
-
description:
|
|
1793
|
-
inputSchema: toInputSchema(
|
|
1793
|
+
name: import_nestjs_agent_core4.REMEMBER_TOOL_NAME,
|
|
1794
|
+
description: import_nestjs_agent_core4.REMEMBER_TOOL_DESCRIPTION,
|
|
1795
|
+
inputSchema: toInputSchema(import_nestjs_agent_core4.rememberInputSchema),
|
|
1794
1796
|
annotations: {
|
|
1795
1797
|
readOnlyHint: false
|
|
1796
1798
|
}
|
|
@@ -1807,7 +1809,7 @@ var OpenCodeMcpEndpoint2 = class {
|
|
|
1807
1809
|
if (turn === void 0) {
|
|
1808
1810
|
throw new OpenCodeToolRefusedError("This endpoint serves OpenCode turns: no turn of yours is running on this session.");
|
|
1809
1811
|
}
|
|
1810
|
-
const output = name ===
|
|
1812
|
+
const output = name === import_nestjs_agent_core4.REMEMBER_TOOL_NAME && this.turns.memoryWritable() ? await this.remember(turn, args) : await this.invoke(turn, actor, name, args, String(extra.requestId ?? ""));
|
|
1811
1813
|
return {
|
|
1812
1814
|
content: [
|
|
1813
1815
|
{
|
|
@@ -1833,9 +1835,9 @@ var OpenCodeMcpEndpoint2 = class {
|
|
|
1833
1835
|
async invoke(turn, actor, name, args, requestId) {
|
|
1834
1836
|
const { registry } = this.turns;
|
|
1835
1837
|
const spec = registry.spec(name);
|
|
1836
|
-
if (spec === void 0 || LOOP_SERVED_KINDS.has(spec.kind)) throw new
|
|
1838
|
+
if (spec === void 0 || LOOP_SERVED_KINDS.has(spec.kind)) throw new import_nestjs_agent_core4.ToolNotFoundError(name);
|
|
1837
1839
|
const allowed = this.turns.allowedTools(turn.input);
|
|
1838
|
-
if (allowed !== void 0 && !allowed.includes(name)) throw new
|
|
1840
|
+
if (allowed !== void 0 && !allowed.includes(name)) throw new import_nestjs_agent_core4.ToolNotFoundError(name);
|
|
1839
1841
|
if (spec.kind === "action" && !await this.turns.spendApproval(turn.runId, name, turn.input)) {
|
|
1840
1842
|
throw new OpenCodeToolRefusedError(`"${name}" is an action and nobody approved this call; ask for the permission first.`);
|
|
1841
1843
|
}
|
|
@@ -1877,7 +1879,7 @@ var OpenCodeMcpEndpoint2 = class {
|
|
|
1877
1879
|
}
|
|
1878
1880
|
/** `remember`: one fact, at the actor's own scope only — as the loop serves it. */
|
|
1879
1881
|
async remember(turn, args) {
|
|
1880
|
-
const parsed = await
|
|
1882
|
+
const parsed = await import_nestjs_agent_core4.rememberInputSchema["~standard"].validate(args ?? {});
|
|
1881
1883
|
if (parsed.issues !== void 0) {
|
|
1882
1884
|
throw new OpenCodeToolRefusedError(`remember: ${parsed.issues.map((issue) => issue.message).join("; ")}`);
|
|
1883
1885
|
}
|
|
@@ -1886,13 +1888,13 @@ var OpenCodeMcpEndpoint2 = class {
|
|
|
1886
1888
|
};
|
|
1887
1889
|
|
|
1888
1890
|
// src/runner.ts
|
|
1889
|
-
var
|
|
1891
|
+
var import_nestjs_agent_core6 = require("@dudousxd/nestjs-agent-core");
|
|
1890
1892
|
var import_common5 = require("@nestjs/common");
|
|
1891
1893
|
|
|
1892
1894
|
// src/turns.ts
|
|
1893
1895
|
var import_node_crypto2 = require("crypto");
|
|
1894
1896
|
var import_nestjs_agent = require("@dudousxd/nestjs-agent");
|
|
1895
|
-
var
|
|
1897
|
+
var import_nestjs_agent_core5 = require("@dudousxd/nestjs-agent-core");
|
|
1896
1898
|
var import_common4 = require("@nestjs/common");
|
|
1897
1899
|
|
|
1898
1900
|
// src/event-hub.ts
|
|
@@ -2071,7 +2073,7 @@ var OpenCodeTurns = class {
|
|
|
2071
2073
|
this.memory = memory;
|
|
2072
2074
|
this.queue = queue;
|
|
2073
2075
|
this.toolsTokens = toolsTokens2;
|
|
2074
|
-
this.prices = new
|
|
2076
|
+
this.prices = new import_nestjs_agent_core5.ModelPriceResolver({
|
|
2075
2077
|
pricingStore,
|
|
2076
2078
|
catalog: agentOptions?.priceCatalog,
|
|
2077
2079
|
log: {
|
|
@@ -2091,10 +2093,10 @@ var OpenCodeTurns = class {
|
|
|
2091
2093
|
const tokens = usage.inputTokens + usage.outputTokens;
|
|
2092
2094
|
const reported = reportedCostUsd !== void 0 && (reportedCostUsd > 0 || tokens === 0);
|
|
2093
2095
|
if (reported && this.settings.cost !== "estimate") {
|
|
2094
|
-
return (0,
|
|
2096
|
+
return (0, import_nestjs_agent_core5.resolveUsageCost)(usage, reportedCostUsd, void 0);
|
|
2095
2097
|
}
|
|
2096
2098
|
const price = model !== void 0 && tokens > 0 ? await this.prices.priceFor(priceRef(model)) : void 0;
|
|
2097
|
-
return (0,
|
|
2099
|
+
return (0, import_nestjs_agent_core5.resolveUsageCost)(usage, price === void 0 ? reportedCostUsd : void 0, price);
|
|
2098
2100
|
}
|
|
2099
2101
|
/** The tools server's name in OpenCode. */
|
|
2100
2102
|
get toolsServer() {
|
|
@@ -2149,7 +2151,7 @@ var OpenCodeTurns = class {
|
|
|
2149
2151
|
const memory = this.memory;
|
|
2150
2152
|
const write = memory?.provider.write?.bind(memory.provider);
|
|
2151
2153
|
if (memory === void 0 || write === void 0) return "Memory is read-only here.";
|
|
2152
|
-
const max = memory.maxFactChars ??
|
|
2154
|
+
const max = memory.maxFactChars ?? import_nestjs_agent_core5.DEFAULT_MAX_FACT_CHARS;
|
|
2153
2155
|
if (input.fact.length > max) return `Not recorded: a fact is at most ${max} characters.`;
|
|
2154
2156
|
const actor = turn.input.actor;
|
|
2155
2157
|
const scopeCtx = {
|
|
@@ -2159,9 +2161,9 @@ var OpenCodeTurns = class {
|
|
|
2159
2161
|
agentName: turn.input.agentName
|
|
2160
2162
|
} : {}
|
|
2161
2163
|
};
|
|
2162
|
-
const scopes = await (memory.scopes ??
|
|
2163
|
-
const scope = (0,
|
|
2164
|
-
const verdict = (0,
|
|
2164
|
+
const scopes = await (memory.scopes ?? import_nestjs_agent_core5.defaultScopeResolver).resolve(scopeCtx);
|
|
2165
|
+
const scope = (0, import_nestjs_agent_core5.actorScope)(actor);
|
|
2166
|
+
const verdict = (0, import_nestjs_agent_core5.memoryWriteVerdict)({
|
|
2165
2167
|
scope,
|
|
2166
2168
|
scopes,
|
|
2167
2169
|
actor,
|
|
@@ -2243,7 +2245,7 @@ var OpenCodeTurns = class {
|
|
|
2243
2245
|
runId,
|
|
2244
2246
|
emitUi: uiEmitter(scope(runId), async (component) => {
|
|
2245
2247
|
const writer = await this.sink.open(runId);
|
|
2246
|
-
await writer.write((0,
|
|
2248
|
+
await writer.write((0, import_nestjs_agent_core5.encodeStreamEvent)({
|
|
2247
2249
|
kind: "ui",
|
|
2248
2250
|
...component
|
|
2249
2251
|
}));
|
|
@@ -2571,12 +2573,12 @@ ${transcript}` : "",
|
|
|
2571
2573
|
const memory = this.memory;
|
|
2572
2574
|
if (memory === void 0) return void 0;
|
|
2573
2575
|
const ctx = this.scopeContext(input);
|
|
2574
|
-
const scopes = await (memory.scopes ??
|
|
2576
|
+
const scopes = await (memory.scopes ?? import_nestjs_agent_core5.defaultScopeResolver).resolve(ctx);
|
|
2575
2577
|
const records = await memory.provider.list({
|
|
2576
2578
|
scopes,
|
|
2577
2579
|
ctx
|
|
2578
2580
|
});
|
|
2579
|
-
const digest = (0,
|
|
2581
|
+
const digest = (0, import_nestjs_agent_core5.resolveMemoryDigest)({
|
|
2580
2582
|
records,
|
|
2581
2583
|
scopes,
|
|
2582
2584
|
...memory.maxMemories !== void 0 ? {
|
|
@@ -2584,7 +2586,7 @@ ${transcript}` : "",
|
|
|
2584
2586
|
} : {}
|
|
2585
2587
|
});
|
|
2586
2588
|
if (digest.entries.length === 0) return void 0;
|
|
2587
|
-
return (0,
|
|
2589
|
+
return (0, import_nestjs_agent_core5.buildMemoryBlock)({
|
|
2588
2590
|
entries: digest.entries,
|
|
2589
2591
|
writable: this.memoryWritable(),
|
|
2590
2592
|
partial: digest.omitted > 0
|
|
@@ -2598,12 +2600,12 @@ ${transcript}` : "",
|
|
|
2598
2600
|
const skills = this.skills;
|
|
2599
2601
|
if (skills === void 0 || client.file === void 0 || directory === void 0) return [];
|
|
2600
2602
|
const ctx = this.scopeContext(input);
|
|
2601
|
-
const scopes = await (skills.scopes ??
|
|
2603
|
+
const scopes = await (skills.scopes ?? import_nestjs_agent_core5.defaultScopeResolver).resolve(ctx);
|
|
2602
2604
|
const summaries = await skills.provider.list({
|
|
2603
2605
|
scopes,
|
|
2604
2606
|
ctx
|
|
2605
2607
|
});
|
|
2606
|
-
const { entries } = (0,
|
|
2608
|
+
const { entries } = (0, import_nestjs_agent_core5.resolveSkillCatalog)(summaries, scopes, skills.maxSkills);
|
|
2607
2609
|
const dir = this.settings.skillsDir ?? ".opencode/skills";
|
|
2608
2610
|
const written = [];
|
|
2609
2611
|
for (const entry of entries) {
|
|
@@ -2842,7 +2844,7 @@ ${body}
|
|
|
2842
2844
|
current?.stop();
|
|
2843
2845
|
const server = await this.host.server(input.actor);
|
|
2844
2846
|
const deps = this.deps.forAgent(input.agentName);
|
|
2845
|
-
const policy = deps.approvalPolicy ?? new
|
|
2847
|
+
const policy = deps.approvalPolicy ?? new import_nestjs_agent_core5.DefaultApprovalPolicy();
|
|
2846
2848
|
const writer = await this.sink.open(input.sinkRunId ?? runId);
|
|
2847
2849
|
const turn = new OpenCodeTurn({
|
|
2848
2850
|
runId,
|
|
@@ -2952,7 +2954,7 @@ ${body}
|
|
|
2952
2954
|
const ui = amendment.ui ?? [];
|
|
2953
2955
|
const last = result.messages.at(-1);
|
|
2954
2956
|
if (ui.length > 0) {
|
|
2955
|
-
for (const component of ui) await writer.write((0,
|
|
2957
|
+
for (const component of ui) await writer.write((0, import_nestjs_agent_core5.encodeStreamEvent)({
|
|
2956
2958
|
kind: "ui",
|
|
2957
2959
|
...component
|
|
2958
2960
|
}));
|
|
@@ -2999,13 +3001,19 @@ ${body}
|
|
|
2999
3001
|
await this.amend(writer, result);
|
|
3000
3002
|
if (outcome.status === "interrupted") {
|
|
3001
3003
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
3002
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
3004
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core5.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
3003
3005
|
await this.handoff(writer, input, runId, "cancelled");
|
|
3004
|
-
await (0,
|
|
3005
|
-
await writer.write((0,
|
|
3006
|
+
await (0, import_nestjs_agent_core5.releaseThreadRun)(this.store, input.threadId, runId);
|
|
3007
|
+
await writer.write((0, import_nestjs_agent_core5.encodeStreamEvent)({
|
|
3006
3008
|
kind: "cancelled"
|
|
3007
3009
|
}));
|
|
3008
3010
|
await writer.end();
|
|
3011
|
+
(0, import_nestjs_agent_core5.publishAgentRunCancelled)({
|
|
3012
|
+
runId,
|
|
3013
|
+
threadId: input.threadId,
|
|
3014
|
+
durationMs,
|
|
3015
|
+
context: (0, import_nestjs_agent_core5.agentRunContext)(input)
|
|
3016
|
+
});
|
|
3009
3017
|
await this.store.recordRunEnd?.({
|
|
3010
3018
|
runId,
|
|
3011
3019
|
status: "cancelled",
|
|
@@ -3013,7 +3021,7 @@ ${body}
|
|
|
3013
3021
|
});
|
|
3014
3022
|
} else {
|
|
3015
3023
|
await this.handoff(writer, input, runId, "completed");
|
|
3016
|
-
await (0,
|
|
3024
|
+
await (0, import_nestjs_agent_core5.releaseThreadRun)(this.store, input.threadId, runId);
|
|
3017
3025
|
await writer.end();
|
|
3018
3026
|
await this.store.recordRunEnd?.({
|
|
3019
3027
|
runId,
|
|
@@ -3032,22 +3040,26 @@ ${body}
|
|
|
3032
3040
|
error
|
|
3033
3041
|
}, durationMs, usage);
|
|
3034
3042
|
const worded = (await this.amend(writer, result)).error;
|
|
3035
|
-
const message = worded ?? (0,
|
|
3043
|
+
const message = worded ?? (0, import_nestjs_agent_core5.streamFailure)(new Error(error)).message;
|
|
3036
3044
|
this.logger.error(`agent run ${runId} failed: ${error}`);
|
|
3037
|
-
(0,
|
|
3045
|
+
(0, import_nestjs_agent_core5.publishAgentRunFailed)({
|
|
3038
3046
|
runId,
|
|
3047
|
+
threadId: input.threadId,
|
|
3039
3048
|
code: "opencode_failed",
|
|
3040
|
-
message: error
|
|
3049
|
+
message: error,
|
|
3050
|
+
durationMs,
|
|
3051
|
+
context: (0, import_nestjs_agent_core5.agentRunContext)(input)
|
|
3041
3052
|
});
|
|
3042
3053
|
await this.store.recordRunEnd?.({
|
|
3043
3054
|
runId,
|
|
3044
3055
|
status: "failed",
|
|
3056
|
+
durationMs,
|
|
3045
3057
|
errorCode: "opencode_failed",
|
|
3046
3058
|
errorMessage: error
|
|
3047
3059
|
});
|
|
3048
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
3060
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core5.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
3049
3061
|
await this.handoff(writer, input, runId, "failed", error);
|
|
3050
|
-
await (0,
|
|
3062
|
+
await (0, import_nestjs_agent_core5.releaseThreadRun)(this.store, input.threadId, runId);
|
|
3051
3063
|
await writer.fail({
|
|
3052
3064
|
code: "opencode_failed",
|
|
3053
3065
|
message
|
|
@@ -3077,7 +3089,7 @@ ${body}
|
|
|
3077
3089
|
error
|
|
3078
3090
|
} : {}
|
|
3079
3091
|
}, (next, nextRunId) => startNext(next, nextRunId));
|
|
3080
|
-
if (frame !== void 0) await writer.write((0,
|
|
3092
|
+
if (frame !== void 0) await writer.write((0, import_nestjs_agent_core5.encodeStreamEvent)(frame));
|
|
3081
3093
|
} catch (failure) {
|
|
3082
3094
|
this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
3083
3095
|
}
|
|
@@ -3088,22 +3100,22 @@ OpenCodeTurns = _ts_decorate2([
|
|
|
3088
3100
|
_ts_param2(0, (0, import_common4.Inject)(OPENCODE_HOST)),
|
|
3089
3101
|
_ts_param2(1, (0, import_common4.Inject)(OPENCODE_SESSIONS)),
|
|
3090
3102
|
_ts_param2(2, (0, import_common4.Inject)(OPENCODE_OPTIONS)),
|
|
3091
|
-
_ts_param2(3, (0, import_common4.Inject)(
|
|
3092
|
-
_ts_param2(4, (0, import_common4.Inject)(
|
|
3093
|
-
_ts_param2(5, (0, import_common4.Inject)(
|
|
3094
|
-
_ts_param2(6, (0, import_common4.Inject)(
|
|
3103
|
+
_ts_param2(3, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_STORE)),
|
|
3104
|
+
_ts_param2(4, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_SINK)),
|
|
3105
|
+
_ts_param2(5, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_DEPS_FACTORY)),
|
|
3106
|
+
_ts_param2(6, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_TOOL_REGISTRY)),
|
|
3095
3107
|
_ts_param2(7, (0, import_common4.Optional)()),
|
|
3096
|
-
_ts_param2(7, (0, import_common4.Inject)(
|
|
3108
|
+
_ts_param2(7, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_SKILLS)),
|
|
3097
3109
|
_ts_param2(8, (0, import_common4.Optional)()),
|
|
3098
|
-
_ts_param2(8, (0, import_common4.Inject)(
|
|
3110
|
+
_ts_param2(8, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_MEMORY)),
|
|
3099
3111
|
_ts_param2(9, (0, import_common4.Optional)()),
|
|
3100
3112
|
_ts_param2(9, (0, import_common4.Inject)(import_nestjs_agent.AGENT_CHAT_QUEUE)),
|
|
3101
3113
|
_ts_param2(10, (0, import_common4.Optional)()),
|
|
3102
3114
|
_ts_param2(10, (0, import_common4.Inject)(OPENCODE_TOOLS_TOKENS)),
|
|
3103
3115
|
_ts_param2(11, (0, import_common4.Optional)()),
|
|
3104
|
-
_ts_param2(11, (0, import_common4.Inject)(
|
|
3116
|
+
_ts_param2(11, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_PRICING_STORE)),
|
|
3105
3117
|
_ts_param2(12, (0, import_common4.Optional)()),
|
|
3106
|
-
_ts_param2(12, (0, import_common4.Inject)(
|
|
3118
|
+
_ts_param2(12, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_OPTIONS)),
|
|
3107
3119
|
_ts_metadata2("design:type", Function),
|
|
3108
3120
|
_ts_metadata2("design:paramtypes", [
|
|
3109
3121
|
typeof OpenCodeHost === "undefined" ? Object : OpenCodeHost,
|
|
@@ -3165,7 +3177,7 @@ function priceRef(model) {
|
|
|
3165
3177
|
model.id
|
|
3166
3178
|
];
|
|
3167
3179
|
const tail = model.id.slice(model.id.lastIndexOf("/") + 1);
|
|
3168
|
-
if (tail !== model.id && (0,
|
|
3180
|
+
if (tail !== model.id && (0, import_nestjs_agent_core5.parseBedrockModelId)(tail) !== void 0) aliases.push(tail);
|
|
3169
3181
|
return {
|
|
3170
3182
|
modelId: `${model.providerID}/${model.id}`,
|
|
3171
3183
|
provider: model.providerID,
|
|
@@ -3265,7 +3277,7 @@ var OpenCodeAgentRunner = class {
|
|
|
3265
3277
|
]) {
|
|
3266
3278
|
if (!key.startsWith(`${runId}:`)) continue;
|
|
3267
3279
|
this.pending.delete(key);
|
|
3268
|
-
waiter.reject(new
|
|
3280
|
+
waiter.reject(new import_nestjs_agent_core6.RunCancelledError());
|
|
3269
3281
|
}
|
|
3270
3282
|
const input = this.inputs.get(runId);
|
|
3271
3283
|
if (input !== void 0) await this.turns.interrupt(input).catch(() => void 0);
|
|
@@ -3277,7 +3289,7 @@ var OpenCodeAgentRunner = class {
|
|
|
3277
3289
|
let spent = emptyUsage();
|
|
3278
3290
|
try {
|
|
3279
3291
|
let handle = await this.turns.begin(runId, input);
|
|
3280
|
-
if (this.cancelled.has(runId)) throw new
|
|
3292
|
+
if (this.cancelled.has(runId)) throw new import_nestjs_agent_core6.RunCancelledError();
|
|
3281
3293
|
await this.turns.prompt(runId, input, handle, spent);
|
|
3282
3294
|
for (; ; ) {
|
|
3283
3295
|
const milestone = await this.turns.observe(runId, input, handle, spent);
|
|
@@ -3290,7 +3302,7 @@ var OpenCodeAgentRunner = class {
|
|
|
3290
3302
|
handle = await this.turns.reply(runId, input, handle, milestone.ask, reply, spent);
|
|
3291
3303
|
}
|
|
3292
3304
|
} catch (error) {
|
|
3293
|
-
if (error instanceof
|
|
3305
|
+
if (error instanceof import_nestjs_agent_core6.RunCancelledError) {
|
|
3294
3306
|
await this.turns.interrupt(input).catch(() => void 0);
|
|
3295
3307
|
await this.turns.settle(runId, input, {
|
|
3296
3308
|
status: "interrupted"
|
|
@@ -3418,7 +3430,7 @@ __name(openCodeProviders, "openCodeProviders");
|
|
|
3418
3430
|
|
|
3419
3431
|
// src/durable/runner.ts
|
|
3420
3432
|
var import_node_crypto3 = require("crypto");
|
|
3421
|
-
var
|
|
3433
|
+
var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
|
|
3422
3434
|
var import_nestjs_durable2 = require("@dudousxd/nestjs-durable");
|
|
3423
3435
|
var import_nestjs_durable_core2 = require("@dudousxd/nestjs-durable-core");
|
|
3424
3436
|
var import_common8 = require("@nestjs/common");
|
|
@@ -3667,7 +3679,7 @@ DurableOpenCodeAgentRunner = _ts_decorate5([
|
|
|
3667
3679
|
_ts_param5(1, (0, import_common8.Inject)(import_nestjs_durable2.RUN_GATEWAY)),
|
|
3668
3680
|
_ts_param5(3, (0, import_common8.Inject)(OPENCODE_OPTIONS)),
|
|
3669
3681
|
_ts_param5(4, (0, import_common8.Inject)(OPENCODE_HOST)),
|
|
3670
|
-
_ts_param5(5, (0, import_common8.Inject)(
|
|
3682
|
+
_ts_param5(5, (0, import_common8.Inject)(import_nestjs_agent_core7.AGENT_STORE)),
|
|
3671
3683
|
_ts_metadata5("design:type", Function),
|
|
3672
3684
|
_ts_metadata5("design:paramtypes", [
|
|
3673
3685
|
typeof import_nestjs_durable2.WorkflowService === "undefined" ? Object : import_nestjs_durable2.WorkflowService,
|