@tangle-network/agent-app 4.0.0 → 4.0.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.
Files changed (36) hide show
  1. package/dist/agent-profiles/d1.js +1 -1
  2. package/dist/agent-profiles/index.d.ts +2 -1
  3. package/dist/agent-profiles/index.js +1 -1
  4. package/dist/chat-routes/index.js +12 -17
  5. package/dist/chat-routes/index.js.map +1 -1
  6. package/dist/chat-routes/visible-text.d.ts +7 -0
  7. package/dist/{chunk-AFMLLZWU.js → chunk-GWATTXFR.js} +3 -3
  8. package/dist/{chunk-AFMLLZWU.js.map → chunk-GWATTXFR.js.map} +1 -1
  9. package/dist/{chunk-HES3IABJ.js → chunk-JKYCXQFI.js} +2 -2
  10. package/dist/{chunk-PABZALSD.js → chunk-LBMFQLBS.js} +9 -6
  11. package/dist/{chunk-PABZALSD.js.map → chunk-LBMFQLBS.js.map} +1 -1
  12. package/dist/{chunk-5DAEU3CP.js → chunk-SJKQUTGU.js} +11 -6
  13. package/dist/chunk-SJKQUTGU.js.map +1 -0
  14. package/dist/{chunk-JSWBJBPM.js → chunk-W5YQZEE4.js} +15 -10
  15. package/dist/chunk-W5YQZEE4.js.map +1 -0
  16. package/dist/{chunk-PISTUUEZ.js → chunk-XCUT2I52.js} +25 -12
  17. package/dist/{chunk-PISTUUEZ.js.map → chunk-XCUT2I52.js.map} +1 -1
  18. package/dist/{chunk-BRQ2SC6V.js → chunk-XKVJQVOT.js} +2 -1
  19. package/dist/chunk-XKVJQVOT.js.map +1 -0
  20. package/dist/conformance/cli.js +2 -2
  21. package/dist/conformance/cli.js.map +1 -1
  22. package/dist/conformance/index.js +1 -1
  23. package/dist/conformance/run.d.ts +3 -2
  24. package/dist/preset-cloudflare/index.js +2 -2
  25. package/dist/public-consultation/index.d.ts +1 -1
  26. package/dist/public-consultation/index.js +5 -3
  27. package/dist/public-consultation/index.js.map +1 -1
  28. package/dist/runtime/index.js +4 -2
  29. package/dist/runtime/index.js.map +1 -1
  30. package/dist/runtime/router-turn.d.ts +15 -0
  31. package/dist/runtime/router-turn.js +3 -1
  32. package/package.json +1 -1
  33. package/dist/chunk-5DAEU3CP.js.map +0 -1
  34. package/dist/chunk-BRQ2SC6V.js.map +0 -1
  35. package/dist/chunk-JSWBJBPM.js.map +0 -1
  36. /package/dist/{chunk-HES3IABJ.js.map → chunk-JKYCXQFI.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  ProfileConflictError,
4
4
  parseProfileRevisionDiff,
5
5
  serializeProfileRevisionDiff
6
- } from "../chunk-BRQ2SC6V.js";
6
+ } from "../chunk-XKVJQVOT.js";
7
7
  import "../chunk-3CI35I4X.js";
8
8
  import "../chunk-GD4ONMKJ.js";
9
9
  import "../chunk-UGWQLQDS.js";
@@ -3,6 +3,7 @@ import { type AgentProfile, type AgentProfileDiff } from '@tangle-network/agent-
3
3
  import { normalizeProfileName, parseProfileSwitch } from './switch.js';
4
4
  export { normalizeProfileName, parseProfileSwitch };
5
5
  import type { McpToolDefinition } from '../tools/index.js';
6
+ import type { RouterTurnTool } from '../runtime/router-turn.js';
6
7
  export type ProfileAuthorKind = 'person' | 'agent' | 'optimizer';
7
8
  export type ProfileRevisionState = 'active' | 'candidate' | 'pending-consent';
8
9
  export interface ProfileRevision {
@@ -314,6 +315,6 @@ export interface ProfileMemoryStore {
314
315
  /** Workspace-shared memories live under this prefix in the workspace store. */
315
316
  export declare const PROFILE_MEMORY_PREFIX = "/memories/workspace/";
316
317
  /** Shared self-edit tools; only the authenticated active turn can name the profile. */
317
- export declare function profileTools<TTurn extends ProfileToolTurn>(context: ProfileToolContext<TTurn>): McpToolDefinition<Record<string, never>>[];
318
+ export declare function profileTools<TTurn extends ProfileToolTurn>(context: ProfileToolContext<TTurn>): Array<McpToolDefinition<Record<string, never>> & Pick<RouterTurnTool, 'effect'>>;
318
319
  export * from './self-management.js';
319
320
  export * from './release.js';
@@ -26,7 +26,7 @@ import {
26
26
  refreshBuiltinSkills,
27
27
  serializeProfileRevisionDiff,
28
28
  switchProfile
29
- } from "../chunk-BRQ2SC6V.js";
29
+ } from "../chunk-XKVJQVOT.js";
30
30
  import {
31
31
  normalizeProfileName,
32
32
  parseProfileSwitch
@@ -40,10 +40,10 @@ import {
40
40
  observeNativeCompletion,
41
41
  readCompletedSandboxTurn,
42
42
  recoverSandboxAssistantMessage
43
- } from "../chunk-HES3IABJ.js";
43
+ } from "../chunk-JKYCXQFI.js";
44
44
  import {
45
45
  runProtectedRouterTurn
46
- } from "../chunk-AFMLLZWU.js";
46
+ } from "../chunk-GWATTXFR.js";
47
47
  import {
48
48
  DEFAULT_MODEL_FIRST_RESPONSE_TIMEOUT_MS,
49
49
  DEFAULT_MODEL_STREAM_OPEN_TIMEOUT_MS,
@@ -88,7 +88,7 @@ import {
88
88
  turnPromptText,
89
89
  valueRedactor,
90
90
  withProducerStream
91
- } from "../chunk-JSWBJBPM.js";
91
+ } from "../chunk-W5YQZEE4.js";
92
92
  import "../chunk-SBHFMDR7.js";
93
93
  import "../chunk-H6BRJU5M.js";
94
94
  import "../chunk-4DBHC63F.js";
@@ -107,8 +107,9 @@ import {
107
107
  isDraftContentEvent,
108
108
  measuredUsage,
109
109
  rowIdOf,
110
- storeSupportsDraftPersistence
111
- } from "../chunk-5DAEU3CP.js";
110
+ storeSupportsDraftPersistence,
111
+ transformVisibleTextParts
112
+ } from "../chunk-SJKQUTGU.js";
112
113
  import "../chunk-2PCNHHN2.js";
113
114
  import "../chunk-YG66IHDU.js";
114
115
  import {
@@ -183,7 +184,7 @@ import "../chunk-S5SRJJQG.js";
183
184
  import "../chunk-GD4ONMKJ.js";
184
185
  import "../chunk-UGWQLQDS.js";
185
186
  import "../chunk-R32MULDK.js";
186
- import "../chunk-PISTUUEZ.js";
187
+ import "../chunk-XCUT2I52.js";
187
188
  import "../chunk-D6UJEOZQ.js";
188
189
  import "../chunk-YYA2CVOY.js";
189
190
  import "../chunk-KSLTD4FI.js";
@@ -322,7 +323,6 @@ function createProtectedRuntimeChatProducer(options) {
322
323
  const channelWriter = writer = channel.writable.getWriter();
323
324
  reader = channel.readable.getReader();
324
325
  const emit = (event) => channelWriter.write(event);
325
- const segments = [];
326
326
  const { profileMaterializationAxes } = await import("@tangle-network/agent-interface");
327
327
  execution = runProtectedRouterTurn({
328
328
  ...protectedTurnSettings(profile, tools, profileMaterializationAxes),
@@ -334,10 +334,12 @@ function createProtectedRuntimeChatProducer(options) {
334
334
  stream: false,
335
335
  maxToolCalls: options.maxToolCalls,
336
336
  maxToolTurns: options.grant.reserve.limits.maxModelCalls,
337
+ // A tool definition here cannot declare an effect, so every tool is a lookup: the lane keeps main's rule.
337
338
  tools: options.tools.map((tool) => ({
338
339
  name: tool.name,
339
340
  description: tool.description,
340
341
  inputSchema: tool.inputSchema,
342
+ effect: "lookup",
341
343
  run: (args) => {
342
344
  const work = (async () => {
343
345
  signal.throwIfAborted();
@@ -361,10 +363,7 @@ function createProtectedRuntimeChatProducer(options) {
361
363
  }
362
364
  })),
363
365
  toolError: (error) => ({ code: "tool_failed", message: error instanceof Error ? error.message : "Tool failed" }),
364
- renderToolResult: (_toolName, outcome) => outcome.ok ? JSON.stringify(outcome.result) ?? "null" : `error: ${outcome.message}`,
365
- onEvent: (event) => {
366
- if (event.type === "text") segments[event.segment - 1] = (segments[event.segment - 1] ?? "") + event.delta;
367
- }
366
+ renderToolResult: (_toolName, outcome) => outcome.ok ? JSON.stringify(outcome.result) ?? "null" : `error: ${outcome.message}`
368
367
  }).then(async (outcome) => {
369
368
  if (outcome.settlement) {
370
369
  usage = { ...outcome.settlement.usage };
@@ -380,7 +379,7 @@ function createProtectedRuntimeChatProducer(options) {
380
379
  } });
381
380
  }
382
381
  if (!outcome.failure || outcome.failure.code.startsWith("settlement_")) {
383
- const finalText = segments.filter(Boolean).at(-1) ?? "";
382
+ const finalText = outcome.answer;
384
383
  if (finalText) await emit({ type: "message.part.updated", data: { part: { id: "text_delta", type: "text" }, delta: finalText } });
385
384
  await emit({ type: "result", data: { finalText } });
386
385
  }
@@ -510,11 +509,7 @@ async function runDetachedTurn(opts) {
510
509
  if (!draft) return result;
511
510
  const transform = opts.persist?.transformText;
512
511
  const content = transform ? await transform(result.text) : result.text;
513
- const rawParts = transform ? await Promise.all(
514
- result.parts.map(
515
- async (part) => String(part.type ?? "") === "text" ? { ...part, text: await transform(String(part.text ?? "")) } : part
516
- )
517
- ) : result.parts;
512
+ const rawParts = transform ? await transformVisibleTextParts(result.parts, transform) : result.parts;
518
513
  const parts2 = toChatMessageParts(rawParts);
519
514
  if (!content.trim() && parts2.length === 0) {
520
515
  await draft.discard();