@dudousxd/nestjs-agent-opencode 0.3.0 → 0.4.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/dist/durable/index.cjs +22 -2
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +1 -1
- package/dist/durable/index.d.ts +1 -1
- package/dist/durable/index.js +23 -3
- package/dist/durable/index.js.map +1 -1
- package/dist/{engine-Cp5uysaN.d.cts → engine-BNNxQAFV.d.cts} +7 -2
- package/dist/{engine-Cp5uysaN.d.ts → engine-BNNxQAFV.d.ts} +7 -2
- package/dist/index.cjs +22 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -685,6 +685,8 @@ declare class OpenCodeToolRefusedError extends Error {
|
|
|
685
685
|
declare class OpenCodeMcpEndpoint {
|
|
686
686
|
private readonly turns;
|
|
687
687
|
private readonly tokens;
|
|
688
|
+
/** Genui telemetry of the UI calls OpenCode makes (its code mode calls tools here, not in the loop). */
|
|
689
|
+
private readonly genui;
|
|
688
690
|
constructor(turns: OpenCodeTurns, tokens: OpenCodeToolsTokens);
|
|
689
691
|
/** The claims of a request's bearer token, or `null`. */
|
|
690
692
|
authenticate(authorization: string | string[] | undefined): OpenCodeToolsClaims | null;
|
|
@@ -796,7 +798,8 @@ declare class OpenCodeTurns implements OnApplicationShutdown {
|
|
|
796
798
|
private readonly host;
|
|
797
799
|
private readonly sessions;
|
|
798
800
|
private readonly settings;
|
|
799
|
-
|
|
801
|
+
/** Read by the MCP endpoint too (genui telemetry of the calls OpenCode makes). */
|
|
802
|
+
readonly store: AgentStore;
|
|
800
803
|
private readonly sink;
|
|
801
804
|
private readonly deps;
|
|
802
805
|
readonly registry: ToolRegistry;
|
|
@@ -812,7 +815,9 @@ declare class OpenCodeTurns implements OnApplicationShutdown {
|
|
|
812
815
|
private readonly spent;
|
|
813
816
|
/** When the tools endpoint was last registered for a location (`server|boot|directory|actor`). */
|
|
814
817
|
private readonly toolsIssued;
|
|
815
|
-
constructor(host: OpenCodeHost, sessions: OpenCodeSessionStore, settings: OpenCodeEngineSettings,
|
|
818
|
+
constructor(host: OpenCodeHost, sessions: OpenCodeSessionStore, settings: OpenCodeEngineSettings,
|
|
819
|
+
/** Read by the MCP endpoint too (genui telemetry of the calls OpenCode makes). */
|
|
820
|
+
store: AgentStore, sink: TokenStreamSink, deps: AgentDepsFactory, registry: ToolRegistry, skills?: SkillsConfig | undefined, memory?: MemoryConfig | undefined, queue?: ChatQueueService | undefined, toolsTokens?: (OpenCodeToolsTokens | null) | undefined, pricingStore?: AgentPricingStore, agentOptions?: {
|
|
816
821
|
priceCatalog?: PriceCatalogOptions | false;
|
|
817
822
|
});
|
|
818
823
|
private readonly prices;
|
|
@@ -685,6 +685,8 @@ declare class OpenCodeToolRefusedError extends Error {
|
|
|
685
685
|
declare class OpenCodeMcpEndpoint {
|
|
686
686
|
private readonly turns;
|
|
687
687
|
private readonly tokens;
|
|
688
|
+
/** Genui telemetry of the UI calls OpenCode makes (its code mode calls tools here, not in the loop). */
|
|
689
|
+
private readonly genui;
|
|
688
690
|
constructor(turns: OpenCodeTurns, tokens: OpenCodeToolsTokens);
|
|
689
691
|
/** The claims of a request's bearer token, or `null`. */
|
|
690
692
|
authenticate(authorization: string | string[] | undefined): OpenCodeToolsClaims | null;
|
|
@@ -796,7 +798,8 @@ declare class OpenCodeTurns implements OnApplicationShutdown {
|
|
|
796
798
|
private readonly host;
|
|
797
799
|
private readonly sessions;
|
|
798
800
|
private readonly settings;
|
|
799
|
-
|
|
801
|
+
/** Read by the MCP endpoint too (genui telemetry of the calls OpenCode makes). */
|
|
802
|
+
readonly store: AgentStore;
|
|
800
803
|
private readonly sink;
|
|
801
804
|
private readonly deps;
|
|
802
805
|
readonly registry: ToolRegistry;
|
|
@@ -812,7 +815,9 @@ declare class OpenCodeTurns implements OnApplicationShutdown {
|
|
|
812
815
|
private readonly spent;
|
|
813
816
|
/** When the tools endpoint was last registered for a location (`server|boot|directory|actor`). */
|
|
814
817
|
private readonly toolsIssued;
|
|
815
|
-
constructor(host: OpenCodeHost, sessions: OpenCodeSessionStore, settings: OpenCodeEngineSettings,
|
|
818
|
+
constructor(host: OpenCodeHost, sessions: OpenCodeSessionStore, settings: OpenCodeEngineSettings,
|
|
819
|
+
/** Read by the MCP endpoint too (genui telemetry of the calls OpenCode makes). */
|
|
820
|
+
store: AgentStore, sink: TokenStreamSink, deps: AgentDepsFactory, registry: ToolRegistry, skills?: SkillsConfig | undefined, memory?: MemoryConfig | undefined, queue?: ChatQueueService | undefined, toolsTokens?: (OpenCodeToolsTokens | null) | undefined, pricingStore?: AgentPricingStore, agentOptions?: {
|
|
816
821
|
priceCatalog?: PriceCatalogOptions | false;
|
|
817
822
|
});
|
|
818
823
|
private readonly prices;
|
package/dist/index.cjs
CHANGED
|
@@ -195,6 +195,7 @@ OpenCodeMcpController = _ts_decorate([
|
|
|
195
195
|
// src/mcp.ts
|
|
196
196
|
var import_node_crypto = require("crypto");
|
|
197
197
|
var import_nestjs_agent_core3 = require("@dudousxd/nestjs-agent-core");
|
|
198
|
+
var import_genui = require("@dudousxd/nestjs-agent-core/genui");
|
|
198
199
|
var import_server = require("@modelcontextprotocol/sdk/server/index.js");
|
|
199
200
|
var import_streamableHttp = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
200
201
|
var import_zod_json_schema_compat = require("@modelcontextprotocol/sdk/server/zod-json-schema-compat.js");
|
|
@@ -1515,6 +1516,8 @@ var OpenCodeMcpEndpoint2 = class {
|
|
|
1515
1516
|
}
|
|
1516
1517
|
turns;
|
|
1517
1518
|
tokens;
|
|
1519
|
+
/** Genui telemetry of the UI calls OpenCode makes (its code mode calls tools here, not in the loop). */
|
|
1520
|
+
genui = new import_nestjs_agent_core3.GenuiRunRecorder();
|
|
1518
1521
|
constructor(turns, tokens) {
|
|
1519
1522
|
this.turns = turns;
|
|
1520
1523
|
this.tokens = tokens;
|
|
@@ -1646,7 +1649,7 @@ var OpenCodeMcpEndpoint2 = class {
|
|
|
1646
1649
|
if (spec.kind === "action" && !await this.turns.spendApproval(turn.runId, name, turn.input)) {
|
|
1647
1650
|
throw new OpenCodeToolRefusedError(`"${name}" is an action and nobody approved this call; ask for the permission first.`);
|
|
1648
1651
|
}
|
|
1649
|
-
|
|
1652
|
+
const invoke = /* @__PURE__ */ __name(() => registry.invoke(name, args ?? {}, {
|
|
1650
1653
|
actor,
|
|
1651
1654
|
threadId: turn.ctx.threadId,
|
|
1652
1655
|
runId: turn.runId,
|
|
@@ -1663,7 +1666,24 @@ var OpenCodeMcpEndpoint2 = class {
|
|
|
1663
1666
|
} : {}
|
|
1664
1667
|
}, this.turns.rolesPolicyFor(turn.input), allowed !== void 0 ? {
|
|
1665
1668
|
allowedTools: allowed
|
|
1666
|
-
} : {});
|
|
1669
|
+
} : {}), "invoke");
|
|
1670
|
+
return this.genui.track({
|
|
1671
|
+
store: this.turns.store,
|
|
1672
|
+
marker: spec.genui,
|
|
1673
|
+
runId: turn.runId,
|
|
1674
|
+
threadId: turn.ctx.threadId,
|
|
1675
|
+
actorRef: actor.id,
|
|
1676
|
+
...turn.input.agentName !== void 0 ? {
|
|
1677
|
+
agentName: turn.input.agentName
|
|
1678
|
+
} : {},
|
|
1679
|
+
channel: (0, import_genui.turnChannel)(turn.input.pageContext),
|
|
1680
|
+
modelId: turn.input.model ?? "opencode",
|
|
1681
|
+
call: {
|
|
1682
|
+
id: `mcp:${turn.runId}:${requestId}`,
|
|
1683
|
+
name,
|
|
1684
|
+
input: args ?? {}
|
|
1685
|
+
}
|
|
1686
|
+
}, invoke);
|
|
1667
1687
|
}
|
|
1668
1688
|
/** `remember`: one fact, at the actor's own scope only — as the loop serves it. */
|
|
1669
1689
|
async remember(turn, args) {
|