@tangle-network/agent-app 0.7.0 → 0.7.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/dist/{chunk-TH2AOJJM.js → chunk-4YTWB5MG.js} +69 -9
- package/dist/chunk-4YTWB5MG.js.map +1 -0
- package/dist/chunk-UIWB2F6N.js +1074 -0
- package/dist/chunk-UIWB2F6N.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +43 -1
- package/dist/missions/index.d.ts +698 -0
- package/dist/missions/index.js +45 -0
- package/dist/missions/index.js.map +1 -0
- package/dist/runtime/index.d.ts +31 -6
- package/dist/runtime/index.js +1 -1
- package/dist/web-react/index.d.ts +89 -1
- package/dist/web-react/index.js +274 -93
- package/dist/web-react/index.js.map +1 -1
- package/package.json +6 -1
- package/dist/chunk-TH2AOJJM.js.map +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_MISSION_STEP_KINDS,
|
|
3
|
+
MISSION_CONTROL_CHANNEL_ID,
|
|
4
|
+
MissionConcurrencyError,
|
|
5
|
+
RetryableStepError,
|
|
6
|
+
applyMissionEvent,
|
|
7
|
+
asMissionStreamEvent,
|
|
8
|
+
budgetGateProposalId,
|
|
9
|
+
buildAgentMissionPlan,
|
|
10
|
+
createInMemoryMissionStore,
|
|
11
|
+
createMissionEngine,
|
|
12
|
+
createMissionService,
|
|
13
|
+
isMissionStopRequested,
|
|
14
|
+
isMissionTerminal,
|
|
15
|
+
mergeMissionState,
|
|
16
|
+
noopEventSink,
|
|
17
|
+
parseMissionBlocks,
|
|
18
|
+
parseSessionStreamEnvelope,
|
|
19
|
+
reduceMissionEvents,
|
|
20
|
+
stepGateProposalId,
|
|
21
|
+
volumeGateProposalId
|
|
22
|
+
} from "../chunk-UIWB2F6N.js";
|
|
23
|
+
export {
|
|
24
|
+
DEFAULT_MISSION_STEP_KINDS,
|
|
25
|
+
MISSION_CONTROL_CHANNEL_ID,
|
|
26
|
+
MissionConcurrencyError,
|
|
27
|
+
RetryableStepError,
|
|
28
|
+
applyMissionEvent,
|
|
29
|
+
asMissionStreamEvent,
|
|
30
|
+
budgetGateProposalId,
|
|
31
|
+
buildAgentMissionPlan,
|
|
32
|
+
createInMemoryMissionStore,
|
|
33
|
+
createMissionEngine,
|
|
34
|
+
createMissionService,
|
|
35
|
+
isMissionStopRequested,
|
|
36
|
+
isMissionTerminal,
|
|
37
|
+
mergeMissionState,
|
|
38
|
+
noopEventSink,
|
|
39
|
+
parseMissionBlocks,
|
|
40
|
+
parseSessionStreamEnvelope,
|
|
41
|
+
reduceMissionEvents,
|
|
42
|
+
stepGateProposalId,
|
|
43
|
+
volumeGateProposalId
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -129,7 +129,8 @@ interface CreateAgentRuntimeOptions {
|
|
|
129
129
|
handlers: AppToolHandlers;
|
|
130
130
|
/** Default agent identity / system prompt. A turn may override it. */
|
|
131
131
|
systemPrompt: string;
|
|
132
|
-
/**
|
|
132
|
+
/** Runaway-backstop cap. Default 200 — set far above any legitimate workflow.
|
|
133
|
+
* For per-workflow limits use `deadlineMs` or `maxCostUsd` on the loop options. */
|
|
133
134
|
maxToolTurns?: number;
|
|
134
135
|
/** Extra OpenAI tool definitions advertised ALONGSIDE the four app tools
|
|
135
136
|
* (e.g. `integration_invoke`). Pair with {@link executeOtherTool}. */
|
|
@@ -228,6 +229,12 @@ type LoopEvent = {
|
|
|
228
229
|
type: 'other';
|
|
229
230
|
event: unknown;
|
|
230
231
|
};
|
|
232
|
+
/** Why the loop stopped. `completed` = model finished naturally; `stuck-loop` =
|
|
233
|
+
* ≥3 consecutive identical tool calls (same tool + args); `backstop` = hit the
|
|
234
|
+
* runaway-backstop cap (200 by default); `deadline` = wall-clock deadlineMs
|
|
235
|
+
* exceeded; `budget` = maxCostUsd exhausted. Non-`completed` stops are infra /
|
|
236
|
+
* resource outcomes — eval scoring must distinguish them from capability failure. */
|
|
237
|
+
type ToolLoopStopReason = 'completed' | 'stuck-loop' | 'backstop' | 'deadline' | 'budget';
|
|
231
238
|
interface ToolLoopResult {
|
|
232
239
|
/** The model's final text across the loop. */
|
|
233
240
|
finalText: string;
|
|
@@ -239,7 +246,9 @@ interface ToolLoopResult {
|
|
|
239
246
|
}>;
|
|
240
247
|
/** Number of model turns run (1 + tool-driven re-runs). */
|
|
241
248
|
turns: number;
|
|
242
|
-
/**
|
|
249
|
+
/** Why the loop stopped. */
|
|
250
|
+
stopReason: ToolLoopStopReason;
|
|
251
|
+
/** @deprecated Use `stopReason !== 'completed'` instead. */
|
|
243
252
|
cappedOut: boolean;
|
|
244
253
|
}
|
|
245
254
|
interface AppToolLoopOptions {
|
|
@@ -260,8 +269,16 @@ interface AppToolLoopOptions {
|
|
|
260
269
|
/** Which emitted tool names are executable (others are ignored — e.g. a UI-only
|
|
261
270
|
* tool the app renders but doesn't run here). */
|
|
262
271
|
isExecutableTool: (toolName: string) => boolean;
|
|
263
|
-
/**
|
|
272
|
+
/** Runaway-backstop cap. Default 200 — set far above any legitimate workflow.
|
|
273
|
+
* For per-workflow limits use `maxCostUsd` or `deadlineMs` instead. */
|
|
264
274
|
maxToolTurns?: number;
|
|
275
|
+
/** Wall-clock deadline in ms since epoch (Date.now()-based). When exceeded the
|
|
276
|
+
* loop stops with stopReason `deadline`. */
|
|
277
|
+
deadlineMs?: number;
|
|
278
|
+
/** Maximum total cost in USD. Requires `costOf` to meter each tool call. */
|
|
279
|
+
maxCostUsd?: number;
|
|
280
|
+
/** Return the USD cost of one outcome. Required for `maxCostUsd` to work. */
|
|
281
|
+
costOf?: (call: LoopToolCall, outcome: AppToolOutcome) => number;
|
|
265
282
|
/** Render one tool outcome as the `content` of its `role: 'tool'` message.
|
|
266
283
|
* Default is a compact `<label> → ok/failed: …`. */
|
|
267
284
|
renderResult?: (label: string, outcome: AppToolOutcome) => string;
|
|
@@ -288,6 +305,7 @@ type StreamLoopYield<Raw> = {
|
|
|
288
305
|
} | {
|
|
289
306
|
kind: 'capped';
|
|
290
307
|
pending: number;
|
|
308
|
+
stopReason: Exclude<ToolLoopStopReason, 'completed'>;
|
|
291
309
|
};
|
|
292
310
|
interface StreamAppToolLoopOptions<Raw> {
|
|
293
311
|
systemPrompt: string;
|
|
@@ -309,16 +327,23 @@ interface StreamAppToolLoopOptions<Raw> {
|
|
|
309
327
|
isExecutableTool: (toolName: string) => boolean;
|
|
310
328
|
/** Execute one call — the app routes to its integration / app-tool executor. */
|
|
311
329
|
executeToolCall: (call: LoopToolCall) => Promise<AppToolOutcome>;
|
|
330
|
+
/** Runaway-backstop cap. Default 200 — set far above any legitimate workflow. */
|
|
312
331
|
maxToolTurns?: number;
|
|
332
|
+
/** Wall-clock deadline in ms since epoch (Date.now()-based). */
|
|
333
|
+
deadlineMs?: number;
|
|
334
|
+
/** Maximum total cost in USD. Requires `costOf` to meter each tool call. */
|
|
335
|
+
maxCostUsd?: number;
|
|
336
|
+
/** Return the USD cost of one outcome. Required for `maxCostUsd` to work. */
|
|
337
|
+
costOf?: (call: LoopToolCall, outcome: AppToolOutcome) => number;
|
|
313
338
|
renderResult?: (label: string, outcome: AppToolOutcome) => string;
|
|
314
339
|
labelFor?: (call: LoopToolCall) => string;
|
|
315
340
|
}
|
|
316
341
|
/**
|
|
317
342
|
* The streaming bounded tool loop. Yields `event` for each raw turn event and
|
|
318
|
-
* `tool_result` for each executed tool; emits a single `capped`
|
|
319
|
-
*
|
|
343
|
+
* `tool_result` for each executed tool; emits a single `capped` (with stopReason)
|
|
344
|
+
* when it stops for any non-completed reason. The app drives telemetry + UI
|
|
320
345
|
* emission off the yielded items.
|
|
321
346
|
*/
|
|
322
347
|
declare function streamAppToolLoop<Raw>(opts: StreamAppToolLoopOptions<Raw>): AsyncGenerator<StreamLoopYield<Raw>, void, unknown>;
|
|
323
348
|
|
|
324
|
-
export { type AgentRuntime, type AgentRuntimeModelConfig, type AgentTurnOptions, type AppToolLoopOptions, type CreateAgentRuntimeOptions, type LoopAssistantToolCall, type LoopEvent, type LoopMessage, type LoopToolCall, type OpenAICompatStreamTurnOptions, type OpenAIStreamChunk, type StreamAppToolLoopOptions, type StreamLoopYield, type ToolLoopResult, createAgentRuntime, createOpenAICompatStreamTurn, runAppToolLoop, streamAppToolLoop, toLoopEvents };
|
|
349
|
+
export { type AgentRuntime, type AgentRuntimeModelConfig, type AgentTurnOptions, type AppToolLoopOptions, type CreateAgentRuntimeOptions, type LoopAssistantToolCall, type LoopEvent, type LoopMessage, type LoopToolCall, type OpenAICompatStreamTurnOptions, type OpenAIStreamChunk, type StreamAppToolLoopOptions, type StreamLoopYield, type ToolLoopResult, type ToolLoopStopReason, createAgentRuntime, createOpenAICompatStreamTurn, runAppToolLoop, streamAppToolLoop, toLoopEvents };
|
package/dist/runtime/index.js
CHANGED
|
@@ -2,6 +2,94 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { C as CatalogModel } from '../model-catalog-BEAEVDaa.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Client-side chat-stream consumption — the NDJSON parse loop every agent
|
|
7
|
+
* app's chat UI hand-rolls (and breaks). Normalizes the three line shapes the
|
|
8
|
+
* agent-app chat routes emit:
|
|
9
|
+
*
|
|
10
|
+
* {kind:'event', event:{type:'text'|'reasoning'|'tool_call'|'usage', ...}}
|
|
11
|
+
* {kind:'tool_result', toolCallId, toolName, label, outcome}
|
|
12
|
+
* {type:'turn'|'metadata'|'error'|'turn_status', ...} (route-level)
|
|
13
|
+
*
|
|
14
|
+
* Replayed lines carry an extra `seq` — transparently ignored. Works for
|
|
15
|
+
* router-backed and sandbox-backed chats alike: anything producing these
|
|
16
|
+
* lines (live pump, queued follow, resume replay) feeds the same callbacks.
|
|
17
|
+
*/
|
|
18
|
+
interface ChatStreamToolCall {
|
|
19
|
+
toolCallId?: string;
|
|
20
|
+
toolName: string;
|
|
21
|
+
args: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
interface ChatStreamToolResult {
|
|
24
|
+
toolCallId?: string;
|
|
25
|
+
toolName?: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
outcome: {
|
|
28
|
+
ok: boolean;
|
|
29
|
+
result?: unknown;
|
|
30
|
+
code?: string;
|
|
31
|
+
message?: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
interface ChatStreamCallbacks {
|
|
35
|
+
onTurnId?: (turnId: string) => void;
|
|
36
|
+
onText?: (delta: string) => void;
|
|
37
|
+
onReasoning?: (delta: string) => void;
|
|
38
|
+
onToolCall?: (call: ChatStreamToolCall) => void;
|
|
39
|
+
onToolResult?: (result: ChatStreamToolResult) => void;
|
|
40
|
+
onUsage?: (usage: {
|
|
41
|
+
promptTokens: number;
|
|
42
|
+
completionTokens: number;
|
|
43
|
+
}) => void;
|
|
44
|
+
onMetadata?: (data: Record<string, unknown>) => void;
|
|
45
|
+
/** A loop-level error event (the turn failed server-side). */
|
|
46
|
+
onErrorEvent?: (message: string) => void;
|
|
47
|
+
}
|
|
48
|
+
interface ConsumeChatStreamResult {
|
|
49
|
+
turnId: string | null;
|
|
50
|
+
/** True when any text/reasoning/tool activity was received. */
|
|
51
|
+
receivedContent: boolean;
|
|
52
|
+
}
|
|
53
|
+
/** Parse one NDJSON line into the callbacks. Exposed for tests. */
|
|
54
|
+
declare function dispatchChatStreamLine(line: string, cb: ChatStreamCallbacks): {
|
|
55
|
+
turnId?: string;
|
|
56
|
+
receivedContent: boolean;
|
|
57
|
+
};
|
|
58
|
+
/** Drain one NDJSON body into the callbacks. Throws on transport failure
|
|
59
|
+
* (caller decides whether to resume). */
|
|
60
|
+
declare function consumeChatStream(body: ReadableStream<Uint8Array>, cb: ChatStreamCallbacks): Promise<ConsumeChatStreamResult>;
|
|
61
|
+
interface StreamChatOptions {
|
|
62
|
+
/** Start the turn (POST the chat request); must return a streaming Response. */
|
|
63
|
+
start: () => Promise<Response>;
|
|
64
|
+
/** Re-attach to a turn after a transport drop (GET the resume route). */
|
|
65
|
+
resume?: (turnId: string, fromSeq: number) => Promise<Response>;
|
|
66
|
+
callbacks: ChatStreamCallbacks;
|
|
67
|
+
/** Called before a resume replays from 0 so the UI can reset accumulated
|
|
68
|
+
* turn state (text, reasoning, tool chips). */
|
|
69
|
+
onResetForResume?: () => void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Run one chat turn with automatic single-shot resume: if the transport drops
|
|
73
|
+
* mid-turn and the server announced a turnId, reset and replay the buffered
|
|
74
|
+
* turn. Server-side the turn keeps running either way (queued runner).
|
|
75
|
+
*/
|
|
76
|
+
declare function streamChatTurn(opts: StreamChatOptions): Promise<ConsumeChatStreamResult>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Provider brand marks — real logo path data (simple-icons / SVG Logos, both
|
|
80
|
+
* CC0) inlined so the picker shows actual provider identity instead of
|
|
81
|
+
* colored-initial monograms. Providers without a usable mark fall back to a
|
|
82
|
+
* tinted monogram chip. Aliases (z-ai/zai, moonshot/moonshotai, deepseek_ai)
|
|
83
|
+
* normalize to one entry.
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
interface ProviderLogoProps {
|
|
87
|
+
provider?: string;
|
|
88
|
+
size?: number;
|
|
89
|
+
}
|
|
90
|
+
/** Real brand mark when we have one; tinted monogram otherwise. */
|
|
91
|
+
declare function ProviderLogo({ provider, size }: ProviderLogoProps): ReactNode;
|
|
92
|
+
|
|
5
93
|
interface ChatMessageMetrics {
|
|
6
94
|
modelUsed?: string;
|
|
7
95
|
promptTokens?: number;
|
|
@@ -114,4 +202,4 @@ interface ProposalApprovalHandlers {
|
|
|
114
202
|
*/
|
|
115
203
|
declare function ChatMessages({ messages, models, renderMarkdown, renderExtras, userLabel, agentLabel, loading, approval, onToolCallClick, }: ChatMessagesProps): react.JSX.Element;
|
|
116
204
|
|
|
117
|
-
export { type ChatMessageMetrics, ChatMessages, type ChatMessagesProps, type ChatToolCallInfo, type ChatUiMessage, EffortPicker, type EffortPickerProps, ModelPicker, type ModelPickerProps, type ProposalApprovalHandlers, RunDrillIn, type RunDrillInProps, type ToolRunRecord, type ToolRunStep, formatModelCost, formatTokensPerSecond, pendingApprovalOf };
|
|
205
|
+
export { type ChatMessageMetrics, ChatMessages, type ChatMessagesProps, type ChatStreamCallbacks, type ChatStreamToolCall, type ChatStreamToolResult, type ChatToolCallInfo, type ChatUiMessage, type ConsumeChatStreamResult, EffortPicker, type EffortPickerProps, ModelPicker, type ModelPickerProps, type ProposalApprovalHandlers, ProviderLogo, type ProviderLogoProps, RunDrillIn, type RunDrillInProps, type StreamChatOptions, type ToolRunRecord, type ToolRunStep, consumeChatStream, dispatchChatStreamLine, formatModelCost, formatTokensPerSecond, pendingApprovalOf, streamChatTurn };
|