@agent-city/langgraph 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +39 -2
- package/dist/handler.d.ts +82 -0
- package/dist/handler.js +251 -0
- package/dist/handler.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentCity contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @agent-city/langgraph
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Callback handler for LangChain.js / LangGraph.js that sends graph runs to the local AgentCity engine
|
|
4
|
+
(127.0.0.1:4317) using `@agent-city/sdk`.
|
|
5
|
+
|
|
6
|
+
| LangChain callback | AgentCity event |
|
|
7
|
+
| --- | --- |
|
|
8
|
+
| outermost chain start/end | `session.start` / `session.end` |
|
|
9
|
+
| graph node start/end (`metadata.langgraph_node === runName`) | `step.start`/`step.end` (`node:<name>`), `plan.update` (one `PlanNode` per node: pending → active → done/failed) |
|
|
10
|
+
| moving from node A to node B | `handoff` (`toAgentId: B`) |
|
|
11
|
+
| `handleToolStart/End/Error` | `step.start`/`step.end`, category via `categorize()` |
|
|
12
|
+
| `handleLLMStart`/`handleChatModelStart`/`handleLLMEnd` | `step.*` with `model`, `tokens`, `costUsd` (estimate) + `metric` events |
|
|
13
|
+
| errors | `step.end` with `status: error` (or `blocked` if denied) |
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createLangGraphHandler } from '@agent-city/langgraph';
|
|
17
|
+
|
|
18
|
+
const agentcity = createLangGraphHandler({
|
|
19
|
+
nodes: ['agent', 'tools'],
|
|
20
|
+
requireApprovalFor: (tool, input) => tool === 'bash' || tool.startsWith('delete'),
|
|
21
|
+
});
|
|
22
|
+
await graph.invoke(input, { callbacks: [agentcity] });
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Control:** when `requireApprovalFor` returns true, the handler calls `requestApproval` (engine `/hooks/pre-tool`) and
|
|
26
|
+
waits. If denied it throws `AgentCityApprovalDeniedError`; the handler sets `raiseError = true` and `awaitHandlers = true`
|
|
27
|
+
so LangChain waits for the decision and propagates the error, so the tool does not run. If the engine is down, the
|
|
28
|
+
`failOpen` option decides (default: allow).
|
|
29
|
+
|
|
30
|
+
`@langchain/core` is an optional peer dependency: the handler is duck-typed (it has `name`, so LangChain uses it as is).
|
|
31
|
+
Costs use `DEFAULT_PRICING` (approximate USD per 1M tokens, matched by model prefix); override them with `pricing`.
|
|
32
|
+
|
|
33
|
+
Official docs consulted:
|
|
34
|
+
- https://js.langchain.com/docs/concepts/callbacks/
|
|
35
|
+
- https://v03.api.js.langchain.com/classes/_langchain_core.callbacks_base.BaseCallbackHandler.html
|
|
36
|
+
- https://langchain-ai.github.io/langgraphjs/how-tos/streaming/ (node metadata `langgraph_node`, `langgraph_step`)
|
|
37
|
+
|
|
38
|
+
Tests: `pnpm --filter @agent-city/langgraph test`. These use mocked objects and no network, plus a contract test that
|
|
39
|
+
runs the Python emitter (`../python/tests/emit_fixture.py`) and validates its events with `parseEvent`. The contract
|
|
40
|
+
test is skipped when Python is missing.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type AgentCity, type AgentCityOptions } from '@agent-city/sdk';
|
|
2
|
+
/** Price per 1M tokens (USD). */
|
|
3
|
+
export type ModelPrice = {
|
|
4
|
+
inputPer1M: number;
|
|
5
|
+
outputPer1M: number;
|
|
6
|
+
};
|
|
7
|
+
/** Rough public list prices used only for an estimate; override with `pricing`. Matched by model-name prefix. */
|
|
8
|
+
export declare const DEFAULT_PRICING: Record<string, ModelPrice>;
|
|
9
|
+
export type TokenUsage = {
|
|
10
|
+
input: number;
|
|
11
|
+
output: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function estimateLlmCost(model: string | undefined, usage: TokenUsage, pricing?: Record<string, ModelPrice>): number | undefined;
|
|
14
|
+
/** Thrown from handleToolStart when a human (or policy) denies the tool call. Requires raiseError (set by default). */
|
|
15
|
+
export declare class AgentCityApprovalDeniedError extends Error {
|
|
16
|
+
readonly toolName: string;
|
|
17
|
+
constructor(toolName: string, reason?: string);
|
|
18
|
+
}
|
|
19
|
+
export type LangGraphHandlerOptions = Partial<AgentCityOptions> & {
|
|
20
|
+
/** Existing SDK client (otherwise one is created with `tool: 'langgraph'`). */
|
|
21
|
+
client?: AgentCity;
|
|
22
|
+
/** Known graph node names, emitted up-front as the plan. Nodes seen at runtime are appended. */
|
|
23
|
+
nodes?: string[];
|
|
24
|
+
/** Return true to require a human decision (engine /hooks/pre-tool) before running a tool. */
|
|
25
|
+
requireApprovalFor?: (toolName: string, input: unknown) => boolean;
|
|
26
|
+
/** Emit a `handoff` when execution moves from one graph node to another. Default true. */
|
|
27
|
+
handoffs?: boolean;
|
|
28
|
+
pricing?: Record<string, ModelPrice>;
|
|
29
|
+
/** Emit session.start/end around the outermost run. Default true. */
|
|
30
|
+
manageSession?: boolean;
|
|
31
|
+
};
|
|
32
|
+
type Json = Record<string, unknown>;
|
|
33
|
+
type Serialized = {
|
|
34
|
+
id?: string[];
|
|
35
|
+
name?: string;
|
|
36
|
+
kwargs?: Json;
|
|
37
|
+
} | undefined;
|
|
38
|
+
/** Extracts token usage from an LLMResult (llmOutput.tokenUsage, estimatedTokenUsage or message usage_metadata). */
|
|
39
|
+
export declare function usageOf(output: unknown): TokenUsage | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* LangChain.js / LangGraph.js callback handler that streams runs to AgentCity.
|
|
42
|
+
* Duck-typed: it has `name`, so LangChain uses it directly as a handler without importing @langchain/core.
|
|
43
|
+
* Docs: https://js.langchain.com/docs/concepts/callbacks/ and https://langchain-ai.github.io/langgraphjs/how-tos/streaming/
|
|
44
|
+
*/
|
|
45
|
+
export declare class AgentCityCallbackHandler {
|
|
46
|
+
readonly name = "agentcity";
|
|
47
|
+
/** Needed so that a denied approval actually stops the tool (control real). */
|
|
48
|
+
readonly raiseError = true;
|
|
49
|
+
/** Needed so LangChain waits for the approval decision before running the tool. */
|
|
50
|
+
readonly awaitHandlers = true;
|
|
51
|
+
readonly ignoreLLM = false;
|
|
52
|
+
readonly ignoreChain = false;
|
|
53
|
+
readonly ignoreAgent = false;
|
|
54
|
+
readonly ignoreRetriever = true;
|
|
55
|
+
readonly ignoreCustomEvent = true;
|
|
56
|
+
readonly ignoreRetry = true;
|
|
57
|
+
readonly client: AgentCity;
|
|
58
|
+
private readonly opts;
|
|
59
|
+
private readonly runs;
|
|
60
|
+
private readonly plan;
|
|
61
|
+
private lastNode;
|
|
62
|
+
private rootRunId;
|
|
63
|
+
constructor(opts?: LangGraphHandlerOptions);
|
|
64
|
+
copy(): this;
|
|
65
|
+
private emitPlan;
|
|
66
|
+
private setNode;
|
|
67
|
+
private start;
|
|
68
|
+
private end;
|
|
69
|
+
handleChainStart(chain: Serialized, _inputs: unknown, runId: string, parentRunId?: string, _tags?: string[], metadata?: Json, _runType?: string, runName?: string): Promise<void>;
|
|
70
|
+
handleChainEnd(_outputs: unknown, runId: string): Promise<void>;
|
|
71
|
+
handleChainError(err: unknown, runId: string): Promise<void>;
|
|
72
|
+
private finishRoot;
|
|
73
|
+
handleToolStart(tool: Serialized, input: unknown, runId: string, _parentRunId?: string, _tags?: string[], metadata?: Json, runName?: string): Promise<void>;
|
|
74
|
+
handleToolEnd(output: unknown, runId: string): Promise<void>;
|
|
75
|
+
handleToolError(err: unknown, runId: string): Promise<void>;
|
|
76
|
+
handleLLMStart(llm: Serialized, _prompts: unknown, runId: string, _parentRunId?: string, extraParams?: Json, _tags?: string[], metadata?: Json): Promise<void>;
|
|
77
|
+
handleChatModelStart(llm: Serialized, messages: unknown, runId: string, parentRunId?: string, extraParams?: Json, tags?: string[], metadata?: Json): Promise<void>;
|
|
78
|
+
handleLLMEnd(output: unknown, runId: string): Promise<void>;
|
|
79
|
+
handleLLMError(err: unknown, runId: string): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
export declare function createLangGraphHandler(opts?: LangGraphHandlerOptions): AgentCityCallbackHandler;
|
|
82
|
+
export {};
|
package/dist/handler.js
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { createAgentCity } from '@agent-city/sdk';
|
|
2
|
+
import { categorize, newId } from '@agent-city/spec';
|
|
3
|
+
/** Rough public list prices used only for an estimate; override with `pricing`. Matched by model-name prefix. */
|
|
4
|
+
export const DEFAULT_PRICING = {
|
|
5
|
+
'gpt-4o-mini': { inputPer1M: 0.15, outputPer1M: 0.6 },
|
|
6
|
+
'gpt-4o': { inputPer1M: 2.5, outputPer1M: 10 },
|
|
7
|
+
'gpt-4.1-mini': { inputPer1M: 0.4, outputPer1M: 1.6 },
|
|
8
|
+
'gpt-4.1': { inputPer1M: 2, outputPer1M: 8 },
|
|
9
|
+
'claude-3-5-haiku': { inputPer1M: 0.8, outputPer1M: 4 },
|
|
10
|
+
'claude-haiku': { inputPer1M: 1, outputPer1M: 5 },
|
|
11
|
+
'claude-sonnet': { inputPer1M: 3, outputPer1M: 15 },
|
|
12
|
+
'claude-3-5-sonnet': { inputPer1M: 3, outputPer1M: 15 },
|
|
13
|
+
'claude-opus': { inputPer1M: 15, outputPer1M: 75 },
|
|
14
|
+
'gemini-1.5-flash': { inputPer1M: 0.075, outputPer1M: 0.3 },
|
|
15
|
+
'gemini-2.0-flash': { inputPer1M: 0.1, outputPer1M: 0.4 },
|
|
16
|
+
};
|
|
17
|
+
export function estimateLlmCost(model, usage, pricing = DEFAULT_PRICING) {
|
|
18
|
+
if (!model)
|
|
19
|
+
return undefined;
|
|
20
|
+
const m = model.toLowerCase();
|
|
21
|
+
const key = Object.keys(pricing).filter((k) => m.startsWith(k.toLowerCase()) || m.includes(k.toLowerCase())).sort((a, b) => b.length - a.length)[0];
|
|
22
|
+
if (!key)
|
|
23
|
+
return undefined;
|
|
24
|
+
const p = pricing[key];
|
|
25
|
+
return (usage.input * p.inputPer1M + usage.output * p.outputPer1M) / 1_000_000;
|
|
26
|
+
}
|
|
27
|
+
/** Thrown from handleToolStart when a human (or policy) denies the tool call. Requires raiseError (set by default). */
|
|
28
|
+
export class AgentCityApprovalDeniedError extends Error {
|
|
29
|
+
toolName;
|
|
30
|
+
constructor(toolName, reason) {
|
|
31
|
+
super(`AgentCity: tool "${toolName}" was denied${reason ? `: ${reason}` : ''}`);
|
|
32
|
+
this.name = 'AgentCityApprovalDeniedError';
|
|
33
|
+
this.toolName = toolName;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const now = () => performance.now();
|
|
37
|
+
function str(v, max = 160) {
|
|
38
|
+
if (v === undefined || v === null)
|
|
39
|
+
return undefined;
|
|
40
|
+
const s = typeof v === 'string' ? v : (() => { try {
|
|
41
|
+
return JSON.stringify(v);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return String(v);
|
|
45
|
+
} })();
|
|
46
|
+
return s.length > max ? s.slice(0, max - 1) + '…' : s;
|
|
47
|
+
}
|
|
48
|
+
function serializedName(s) {
|
|
49
|
+
return s?.name ?? s?.id?.[s.id.length - 1];
|
|
50
|
+
}
|
|
51
|
+
function modelOf(llm, extra, metadata) {
|
|
52
|
+
const inv = (extra?.invocation_params ?? {});
|
|
53
|
+
const kw = llm?.kwargs ?? {};
|
|
54
|
+
const cand = metadata?.ls_model_name ?? inv.model ?? inv.model_name ?? inv.modelName ?? kw.model ?? kw.model_name ?? kw.modelName;
|
|
55
|
+
return typeof cand === 'string' ? cand : undefined;
|
|
56
|
+
}
|
|
57
|
+
/** Extracts token usage from an LLMResult (llmOutput.tokenUsage, estimatedTokenUsage or message usage_metadata). */
|
|
58
|
+
export function usageOf(output) {
|
|
59
|
+
const o = (output ?? {});
|
|
60
|
+
const lo = (o.llmOutput ?? o.llm_output ?? {});
|
|
61
|
+
const tu = (lo.tokenUsage ?? lo.estimatedTokenUsage ?? lo.token_usage ?? lo.usage);
|
|
62
|
+
if (tu) {
|
|
63
|
+
const input = Number(tu.promptTokens ?? tu.prompt_tokens ?? tu.input_tokens ?? 0);
|
|
64
|
+
const out = Number(tu.completionTokens ?? tu.completion_tokens ?? tu.output_tokens ?? 0);
|
|
65
|
+
if (input || out)
|
|
66
|
+
return { input, output: out };
|
|
67
|
+
}
|
|
68
|
+
const gens = (o.generations ?? []);
|
|
69
|
+
let input = 0, out = 0;
|
|
70
|
+
for (const g of gens)
|
|
71
|
+
for (const c of g ?? []) {
|
|
72
|
+
const um = c?.message?.usage_metadata;
|
|
73
|
+
if (um) {
|
|
74
|
+
input += Number(um.input_tokens ?? 0);
|
|
75
|
+
out += Number(um.output_tokens ?? 0);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return input || out ? { input, output: out } : undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* LangChain.js / LangGraph.js callback handler that streams runs to AgentCity.
|
|
82
|
+
* Duck-typed: it has `name`, so LangChain uses it directly as a handler without importing @langchain/core.
|
|
83
|
+
* Docs: https://js.langchain.com/docs/concepts/callbacks/ and https://langchain-ai.github.io/langgraphjs/how-tos/streaming/
|
|
84
|
+
*/
|
|
85
|
+
export class AgentCityCallbackHandler {
|
|
86
|
+
name = 'agentcity';
|
|
87
|
+
/** Needed so that a denied approval actually stops the tool (control real). */
|
|
88
|
+
raiseError = true;
|
|
89
|
+
/** Needed so LangChain waits for the approval decision before running the tool. */
|
|
90
|
+
awaitHandlers = true;
|
|
91
|
+
ignoreLLM = false;
|
|
92
|
+
ignoreChain = false;
|
|
93
|
+
ignoreAgent = false;
|
|
94
|
+
ignoreRetriever = true;
|
|
95
|
+
ignoreCustomEvent = true;
|
|
96
|
+
ignoreRetry = true;
|
|
97
|
+
client;
|
|
98
|
+
opts;
|
|
99
|
+
runs = new Map();
|
|
100
|
+
plan = new Map();
|
|
101
|
+
lastNode;
|
|
102
|
+
rootRunId;
|
|
103
|
+
constructor(opts = {}) {
|
|
104
|
+
this.opts = opts;
|
|
105
|
+
this.client = opts.client ?? createAgentCity({ ...opts, tool: opts.tool ?? 'langgraph' });
|
|
106
|
+
for (const n of opts.nodes ?? [])
|
|
107
|
+
this.plan.set(n, { id: n, label: n, state: 'pending' });
|
|
108
|
+
}
|
|
109
|
+
copy() { return this; }
|
|
110
|
+
emitPlan() {
|
|
111
|
+
if (this.plan.size > 0)
|
|
112
|
+
this.client.plan([...this.plan.values()]);
|
|
113
|
+
}
|
|
114
|
+
setNode(node, state) {
|
|
115
|
+
const prev = this.plan.get(node);
|
|
116
|
+
this.plan.set(node, { ...(prev ?? { id: node, label: node }), state });
|
|
117
|
+
this.emitPlan();
|
|
118
|
+
}
|
|
119
|
+
start(runId, run, extra = {}) {
|
|
120
|
+
const r = { ...run, stepId: newId(), t0: now() };
|
|
121
|
+
this.runs.set(runId, r);
|
|
122
|
+
this.client.emit('step.start', {
|
|
123
|
+
step: { id: r.stepId, action: r.action, category: r.category, ...(r.target ? { target: r.target } : {}), ...extra },
|
|
124
|
+
...(r.node ? { langgraph: { node: r.node } } : {}),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
end(runId, status, summary, extra = {}) {
|
|
128
|
+
const r = this.runs.get(runId);
|
|
129
|
+
if (!r)
|
|
130
|
+
return undefined;
|
|
131
|
+
this.runs.delete(runId);
|
|
132
|
+
this.client.emit('step.end', {
|
|
133
|
+
step: {
|
|
134
|
+
id: r.stepId, action: r.action, category: r.category, ...(r.target ? { target: r.target } : {}),
|
|
135
|
+
status, durationMs: Math.max(0, Math.round(now() - r.t0)), ...(summary ? { summary: str(summary, 200) } : {}), ...extra,
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
return r;
|
|
139
|
+
}
|
|
140
|
+
// ---- chains / graph nodes ----
|
|
141
|
+
async handleChainStart(chain, _inputs, runId, parentRunId, _tags, metadata, _runType, runName) {
|
|
142
|
+
const node = typeof metadata?.langgraph_node === 'string' ? metadata.langgraph_node : undefined;
|
|
143
|
+
const name = runName ?? serializedName(chain) ?? 'chain';
|
|
144
|
+
if (!parentRunId && !this.rootRunId) {
|
|
145
|
+
this.rootRunId = runId;
|
|
146
|
+
if (this.opts.manageSession !== false)
|
|
147
|
+
this.client.sessionStart();
|
|
148
|
+
this.emitPlan();
|
|
149
|
+
this.runs.set(runId, { stepId: newId(), action: name, category: 'plan', t0: now(), kind: 'root' });
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (node && name === node && !node.startsWith('__')) {
|
|
153
|
+
if (this.opts.handoffs !== false && this.lastNode && this.lastNode !== node)
|
|
154
|
+
this.client.handoff(node, `${this.lastNode} -> ${node}`);
|
|
155
|
+
this.lastNode = node;
|
|
156
|
+
this.setNode(node, 'active');
|
|
157
|
+
this.start(runId, { action: `node:${node}`, category: 'plan', kind: 'node', node, target: node });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async handleChainEnd(_outputs, runId) {
|
|
161
|
+
if (runId === this.rootRunId)
|
|
162
|
+
return this.finishRoot();
|
|
163
|
+
const r = this.end(runId, 'ok');
|
|
164
|
+
if (r?.node)
|
|
165
|
+
this.setNode(r.node, 'done');
|
|
166
|
+
}
|
|
167
|
+
async handleChainError(err, runId) {
|
|
168
|
+
if (runId === this.rootRunId)
|
|
169
|
+
return this.finishRoot();
|
|
170
|
+
const denied = err instanceof AgentCityApprovalDeniedError;
|
|
171
|
+
const r = this.end(runId, denied ? 'blocked' : 'error', errMsg(err));
|
|
172
|
+
if (r?.node)
|
|
173
|
+
this.setNode(r.node, 'failed');
|
|
174
|
+
}
|
|
175
|
+
async finishRoot() {
|
|
176
|
+
this.runs.delete(this.rootRunId);
|
|
177
|
+
this.rootRunId = undefined;
|
|
178
|
+
this.lastNode = undefined;
|
|
179
|
+
if (this.opts.manageSession !== false)
|
|
180
|
+
await this.client.sessionEnd();
|
|
181
|
+
else
|
|
182
|
+
await this.client.flush();
|
|
183
|
+
}
|
|
184
|
+
// ---- tools ----
|
|
185
|
+
async handleToolStart(tool, input, runId, _parentRunId, _tags, metadata, runName) {
|
|
186
|
+
const name = runName ?? serializedName(tool) ?? 'tool';
|
|
187
|
+
const node = typeof metadata?.langgraph_node === 'string' ? metadata.langgraph_node : undefined;
|
|
188
|
+
const target = str(input);
|
|
189
|
+
let parsed = input;
|
|
190
|
+
if (typeof input === 'string') {
|
|
191
|
+
try {
|
|
192
|
+
parsed = JSON.parse(input);
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
parsed = input;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (this.opts.requireApprovalFor?.(name, parsed)) {
|
|
199
|
+
const decision = await this.client.requestApproval({ action: name, category: categorize(name), ...(target ? { target } : {}), reason: 'requireApprovalFor' });
|
|
200
|
+
if (decision === 'deny') {
|
|
201
|
+
const stepId = newId();
|
|
202
|
+
this.client.emit('step.end', { step: { id: stepId, action: name, category: categorize(name), ...(target ? { target } : {}), status: 'blocked', summary: 'Denied by AgentCity' } });
|
|
203
|
+
throw new AgentCityApprovalDeniedError(name);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
this.start(runId, { action: name, category: categorize(name), kind: 'tool', ...(target ? { target } : {}), ...(node ? { node } : {}) });
|
|
207
|
+
}
|
|
208
|
+
async handleToolEnd(output, runId) {
|
|
209
|
+
const content = output?.content ?? output;
|
|
210
|
+
this.end(runId, 'ok', str(content, 200));
|
|
211
|
+
}
|
|
212
|
+
async handleToolError(err, runId) {
|
|
213
|
+
this.end(runId, 'error', errMsg(err));
|
|
214
|
+
}
|
|
215
|
+
// ---- LLMs ----
|
|
216
|
+
async handleLLMStart(llm, _prompts, runId, _parentRunId, extraParams, _tags, metadata) {
|
|
217
|
+
const model = modelOf(llm, extraParams, metadata);
|
|
218
|
+
const node = typeof metadata?.langgraph_node === 'string' ? metadata.langgraph_node : undefined;
|
|
219
|
+
this.start(runId, { action: 'llm', category: 'other', kind: 'llm', ...(model ? { model, target: model } : {}), ...(node ? { node } : {}) }, model ? { model } : {});
|
|
220
|
+
}
|
|
221
|
+
async handleChatModelStart(llm, messages, runId, parentRunId, extraParams, tags, metadata) {
|
|
222
|
+
return this.handleLLMStart(llm, messages, runId, parentRunId, extraParams, tags, metadata);
|
|
223
|
+
}
|
|
224
|
+
async handleLLMEnd(output, runId) {
|
|
225
|
+
const r = this.runs.get(runId);
|
|
226
|
+
const usage = usageOf(output);
|
|
227
|
+
const model = r?.model;
|
|
228
|
+
const cost = usage ? estimateLlmCost(model, usage, this.opts.pricing ?? DEFAULT_PRICING) : undefined;
|
|
229
|
+
this.end(runId, 'ok', undefined, {
|
|
230
|
+
...(model ? { model } : {}),
|
|
231
|
+
...(usage ? { tokens: { input: usage.input, output: usage.output } } : {}),
|
|
232
|
+
...(cost !== undefined ? { costUsd: cost } : {}),
|
|
233
|
+
});
|
|
234
|
+
if (usage) {
|
|
235
|
+
this.client.metric({ name: 'tokens.input', value: usage.input, unit: 'tokens' });
|
|
236
|
+
this.client.metric({ name: 'tokens.output', value: usage.output, unit: 'tokens' });
|
|
237
|
+
}
|
|
238
|
+
if (cost !== undefined)
|
|
239
|
+
this.client.metric({ name: 'cost', value: cost, unit: 'usd' });
|
|
240
|
+
}
|
|
241
|
+
async handleLLMError(err, runId) {
|
|
242
|
+
this.end(runId, 'error', errMsg(err));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function errMsg(err) {
|
|
246
|
+
return err instanceof Error ? err.message : String(err);
|
|
247
|
+
}
|
|
248
|
+
export function createLangGraphHandler(opts = {}) {
|
|
249
|
+
return new AgentCityCallbackHandler(opts);
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAyC,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,KAAK,EAAoC,MAAM,kBAAkB,CAAC;AAKvF,iHAAiH;AACjH,MAAM,CAAC,MAAM,eAAe,GAA+B;IACzD,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE;IACrD,QAAQ,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE;IAC9C,cAAc,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE;IACrD,SAAS,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE;IAC5C,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KAAa;QAC9C,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACxC,CAAC;CACF;AAED,SAAS,MAAM,CAAC,GAAY;IAC1B,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAgC,EAAE;IACvE,OAAO,IAAI,wBAAwB,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,GAC1H,MAAM,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-city/langgraph",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AgentCity callback handler for LangChain.js / LangGraph.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@agent-city/sdk": "0.1.0",
|
|
20
|
+
"@agent-city/spec": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@langchain/core": ">=0.3.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependenciesMeta": {
|
|
26
|
+
"@langchain/core": {
|
|
27
|
+
"optional": true
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/marlonyi/agentcity-kit.git",
|
|
33
|
+
"directory": "packages/adapters/langgraph"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/marlonyi/agentcity-kit#readme",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/marlonyi/agentcity-kit/issues"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=22.13"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc -p tsconfig.json",
|
|
47
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
48
|
+
"test": "vitest run"
|
|
49
|
+
}
|
|
6
50
|
}
|