@ouro.bot/cli 0.1.0-alpha.1316 → 0.1.0-alpha.1318
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/changelog.json +12 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/repertoire/tools-a2a.js +72 -22
- package/dist/repertoire/tools-bridge.js +15 -6
- package/dist/repertoire/tools-trip.js +120 -61
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1318",
|
|
6
|
+
"changes": [
|
|
7
|
+
"The trip ledger tools carry Ouro AX cards, and their errors end with a code the card explains."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1317",
|
|
12
|
+
"changes": [
|
|
13
|
+
"The A2A peer tools and bridge_manage now carry Ouro AX cards, and their refusals end with a code the card names."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1316",
|
|
6
18
|
"changes": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1318</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -47,6 +47,7 @@ const transport_1 = require("../a2a/transport");
|
|
|
47
47
|
const relay_contacts_1 = require("../a2a/relay-contacts");
|
|
48
48
|
const delegation_stores_1 = require("../a2a/delegation-stores");
|
|
49
49
|
const mission_result_wire_1 = require("../a2a/mission-result-wire");
|
|
50
|
+
const tools_base_1 = require("./tools-base");
|
|
50
51
|
const outboundTaskTokens = new Map();
|
|
51
52
|
function tokenKey(ctx, friendId, taskId) {
|
|
52
53
|
return `${ctx?.agentRoot ?? "ambient"}\n${friendId}\n${taskId}`;
|
|
@@ -86,9 +87,9 @@ function storeFor(ctx) {
|
|
|
86
87
|
}
|
|
87
88
|
function requireTrustedRequester(ctx) {
|
|
88
89
|
if (!ctx?.context?.friend?.id)
|
|
89
|
-
return "no friend context — cannot use A2A tools.";
|
|
90
|
+
return (0, tools_base_1.withCode)("no friend context — cannot use A2A tools.", "no-friend-context");
|
|
90
91
|
if (!(0, friends_1.isTrustedLevel)(ctx.context.friend.trustLevel))
|
|
91
|
-
return "A2A tools require friend or family trust.";
|
|
92
|
+
return (0, tools_base_1.withCode)("A2A tools require friend or family trust.", "untrusted-requester");
|
|
92
93
|
return null;
|
|
93
94
|
}
|
|
94
95
|
function isA2APeer(friend) {
|
|
@@ -300,7 +301,7 @@ exports.a2aToolDefinitions = [
|
|
|
300
301
|
message: "connect_to refused (non-owner management sense)",
|
|
301
302
|
meta: { tool: "connect_to", senseType, reason: authorization.reason },
|
|
302
303
|
});
|
|
303
|
-
return `connect_to is available only from your own local management sense (the CLI you launched). This sense (${senseType}) is not permitted to link agents
|
|
304
|
+
return (0, tools_base_1.withCode)(`connect_to is available only from your own local management sense (the CLI you launched). This sense (${senseType}) is not permitted to link agents.`, "not-local-sense");
|
|
304
305
|
}
|
|
305
306
|
const agentName = agentNameFromRoot(ctx?.agentRoot);
|
|
306
307
|
// ONE store for both halves — the DID-keyed onboarding write and the
|
|
@@ -340,9 +341,15 @@ exports.a2aToolDefinitions = [
|
|
|
340
341
|
return `connected ${result.record.name} (${did ?? result.record.id}) at family trust.`;
|
|
341
342
|
}
|
|
342
343
|
catch (error) {
|
|
343
|
-
return `connect_to error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive non-Error failures @preserve */ String(error)}
|
|
344
|
+
return (0, tools_base_1.withCode)(`connect_to error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive non-Error failures @preserve */ String(error)}`, "connect-failed");
|
|
344
345
|
}
|
|
345
346
|
},
|
|
347
|
+
ax: { id: "tool:connect_to", group: "a2a", when: "Pick this when your owner, at their own terminal, hands you another agent's card link to add as a trusted peer you can then message.", effect: "write", errors: [
|
|
348
|
+
{ code: "no-friend-context", means: "This turn has no friend behind it, so A2A tools can't tell who is asking.", fix: "Use A2A tools only on a turn that a known friend or family member started." },
|
|
349
|
+
{ code: "untrusted-requester", means: "The person on this turn is below friend trust, and A2A tools need friend or family.", fix: "Tell them you can't reach other agents for them; your owner can raise their trust." },
|
|
350
|
+
{ code: "not-local-sense", means: "Linking agents works only from the owner's own CLI session, and this turn came from another sense.", fix: "Ask your owner to make the link in a CLI session with you, where connect_to is allowed." },
|
|
351
|
+
{ code: "connect-failed", means: "Fetching the card, checking its DID or saving the peer failed; the reason follows the colon.", fix: "Check card_url opens the agent's /.well-known/agent-card.json, then try once more." },
|
|
352
|
+
] },
|
|
346
353
|
summaryKeys: ["card_url", "name"],
|
|
347
354
|
riskProfile: { mutates: "durable_state_write", risk: "high", reason: "links a new agent peer into the friend model at family trust" },
|
|
348
355
|
},
|
|
@@ -371,7 +378,7 @@ exports.a2aToolDefinitions = [
|
|
|
371
378
|
const store = storeFor(ctx);
|
|
372
379
|
const listAll = store.listAll;
|
|
373
380
|
if (!listAll)
|
|
374
|
-
return "friend store does not support listing.";
|
|
381
|
+
return (0, tools_base_1.withCode)("friend store does not support listing.", "no-peer-listing");
|
|
375
382
|
const peers = (await listAll.call(store)).filter(isA2APeer);
|
|
376
383
|
return JSON.stringify(peers.map((peer) => ({
|
|
377
384
|
id: peer.id,
|
|
@@ -381,6 +388,12 @@ exports.a2aToolDefinitions = [
|
|
|
381
388
|
cardUrl: peer.agentMeta?.a2a?.cardUrl,
|
|
382
389
|
})), null, 2);
|
|
383
390
|
},
|
|
391
|
+
ax: { id: "tool:a2a_list_peers", group: "a2a", when: "Pick this first when you need another agent's friend_id, or to see which agents you are linked with and how far each is trusted.", effect: "read", idempotent: true, errors: [
|
|
392
|
+
{ code: "no-friend-context", means: "This turn has no friend behind it, so A2A tools can't tell who is asking.", fix: "Use A2A tools only on a turn that a known friend or family member started." },
|
|
393
|
+
{ code: "untrusted-requester", means: "The person on this turn is below friend trust, and A2A tools need friend or family.", fix: "Tell them you can't reach other agents for them; your owner can raise their trust." },
|
|
394
|
+
{ code: "no-peer-listing", means: "This friend store can't list its records, so no peers can be shown.", fix: "Use a friend_id you already know, or ask your owner which agents are linked." },
|
|
395
|
+
] },
|
|
396
|
+
riskProfile: { mutates: "none", risk: "low" },
|
|
384
397
|
summaryKeys: [],
|
|
385
398
|
},
|
|
386
399
|
{
|
|
@@ -412,9 +425,9 @@ exports.a2aToolDefinitions = [
|
|
|
412
425
|
return guard;
|
|
413
426
|
const peer = await storeFor(ctx).get(args.friend_id);
|
|
414
427
|
if (!peer || !isA2APeer(peer))
|
|
415
|
-
return `A2A peer not found: ${args.friend_id}
|
|
428
|
+
return (0, tools_base_1.withCode)(`A2A peer not found: ${args.friend_id}`, "peer-not-found");
|
|
416
429
|
if (!(0, friends_1.isTrustedLevel)(peer.trustLevel))
|
|
417
|
-
return "target A2A peer must be friend or family trust before outbound messages.";
|
|
430
|
+
return (0, tools_base_1.withCode)("target A2A peer must be friend or family trust before outbound messages.", "untrusted-peer");
|
|
418
431
|
// ROUTING (explicit, no impl judgment): a DID-keyed peer → seal+sign via
|
|
419
432
|
// sendShare over the direct rung (E2E, verified-DID inbound). A legacy peer
|
|
420
433
|
// with no pinned DID → the existing text send, byte-for-byte unchanged.
|
|
@@ -434,7 +447,7 @@ exports.a2aToolDefinitions = [
|
|
|
434
447
|
return deliveryText(peer.name, did, delivery);
|
|
435
448
|
}
|
|
436
449
|
catch (error) {
|
|
437
|
-
return `A2A sealed send error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive non-Error transport failures @preserve */ String(error)}
|
|
450
|
+
return (0, tools_base_1.withCode)(`A2A sealed send error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive non-Error transport failures @preserve */ String(error)}`, "send-failed");
|
|
438
451
|
}
|
|
439
452
|
}
|
|
440
453
|
try {
|
|
@@ -451,9 +464,16 @@ exports.a2aToolDefinitions = [
|
|
|
451
464
|
return JSON.stringify(redactTaskToken(task), null, 2);
|
|
452
465
|
}
|
|
453
466
|
catch (error) {
|
|
454
|
-
return `A2A send error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive non-Error transport failures */ String(error)}
|
|
467
|
+
return (0, tools_base_1.withCode)(`A2A send error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive non-Error transport failures */ String(error)}`, "send-failed");
|
|
455
468
|
}
|
|
456
469
|
},
|
|
470
|
+
ax: { id: "tool:a2a_send_message", group: "a2a", when: "Pick this to say something to another agent or ask it a one-off favour; for tracked work on a shared mission, coordinate records the request.", effect: "write", errors: [
|
|
471
|
+
{ code: "no-friend-context", means: "This turn has no friend behind it, so A2A tools can't tell who is asking.", fix: "Use A2A tools only on a turn that a known friend or family member started." },
|
|
472
|
+
{ code: "untrusted-requester", means: "The person on this turn is below friend trust, and A2A tools need friend or family.", fix: "Tell them you can't reach other agents for them; your owner can raise their trust." },
|
|
473
|
+
{ code: "peer-not-found", means: "friend_id names no onboarded A2A agent peer.", fix: "Call a2a_list_peers and pass one of the ids it shows." },
|
|
474
|
+
{ code: "untrusted-peer", means: "That agent peer is below friend trust, so I won't talk to it.", fix: "Ask your owner to raise the peer's trust, or pick a trusted peer from a2a_list_peers." },
|
|
475
|
+
{ code: "send-failed", means: "The message didn't reach the peer; the transport's reason follows the colon.", fix: "Try once more later; if it fails again, tell your owner that peer can't be reached." },
|
|
476
|
+
] },
|
|
457
477
|
summaryKeys: ["friend_id", "session_key"],
|
|
458
478
|
riskProfile: { mutates: "external_side_effect", risk: "high", reason: "sends a message to a remote agent peer" },
|
|
459
479
|
},
|
|
@@ -486,9 +506,9 @@ exports.a2aToolDefinitions = [
|
|
|
486
506
|
return guard;
|
|
487
507
|
const peer = await storeFor(ctx).get(args.friend_id);
|
|
488
508
|
if (!peer || !isA2APeer(peer))
|
|
489
|
-
return `A2A peer not found: ${args.friend_id}
|
|
509
|
+
return (0, tools_base_1.withCode)(`A2A peer not found: ${args.friend_id}`, "peer-not-found");
|
|
490
510
|
if (!(0, friends_1.isTrustedLevel)(peer.trustLevel))
|
|
491
|
-
return "target A2A peer must be friend or family trust before task lookup.";
|
|
511
|
+
return (0, tools_base_1.withCode)("target A2A peer must be friend or family trust before task lookup.", "untrusted-peer");
|
|
492
512
|
try {
|
|
493
513
|
const endpoint = await resolveA2AEndpoint(peer);
|
|
494
514
|
const task = await (0, client_1.getA2ATask)({
|
|
@@ -503,9 +523,17 @@ exports.a2aToolDefinitions = [
|
|
|
503
523
|
return JSON.stringify(redactTaskToken(task), null, 2);
|
|
504
524
|
}
|
|
505
525
|
catch (error) {
|
|
506
|
-
return `A2A task error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive non-Error transport failures */ String(error)}
|
|
526
|
+
return (0, tools_base_1.withCode)(`A2A task error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive non-Error transport failures */ String(error)}`, "task-fetch-failed");
|
|
507
527
|
}
|
|
508
528
|
},
|
|
529
|
+
ax: { id: "tool:a2a_get_task", group: "a2a", when: "Pick this after a2a_send_message gave you a task id, to see whether the other agent has finished it and what it answered.", effect: "read", idempotent: true, errors: [
|
|
530
|
+
{ code: "no-friend-context", means: "This turn has no friend behind it, so A2A tools can't tell who is asking.", fix: "Use A2A tools only on a turn that a known friend or family member started." },
|
|
531
|
+
{ code: "untrusted-requester", means: "The person on this turn is below friend trust, and A2A tools need friend or family.", fix: "Tell them you can't reach other agents for them; your owner can raise their trust." },
|
|
532
|
+
{ code: "peer-not-found", means: "friend_id names no onboarded A2A agent peer.", fix: "Call a2a_list_peers and pass one of the ids it shows." },
|
|
533
|
+
{ code: "untrusted-peer", means: "That agent peer is below friend trust, so I won't talk to it.", fix: "Ask your owner to raise the peer's trust, or pick a trusted peer from a2a_list_peers." },
|
|
534
|
+
{ code: "task-fetch-failed", means: "The peer didn't return the task; its reason follows the colon.", fix: "Check task_id came from that same peer's reply; pass access_token if an outside agent gave you one." },
|
|
535
|
+
] },
|
|
536
|
+
riskProfile: { mutates: "none", risk: "low" },
|
|
509
537
|
summaryKeys: ["friend_id", "task_id"],
|
|
510
538
|
},
|
|
511
539
|
{
|
|
@@ -539,12 +567,12 @@ exports.a2aToolDefinitions = [
|
|
|
539
567
|
return guard;
|
|
540
568
|
const peer = await storeFor(ctx).get(args.friend_id);
|
|
541
569
|
if (!peer || !isA2APeer(peer))
|
|
542
|
-
return `A2A peer not found: ${args.friend_id}
|
|
570
|
+
return (0, tools_base_1.withCode)(`A2A peer not found: ${args.friend_id}`, "peer-not-found");
|
|
543
571
|
if (!(0, friends_1.isTrustedLevel)(peer.trustLevel))
|
|
544
|
-
return "target A2A peer must be friend or family trust before delegating.";
|
|
572
|
+
return (0, tools_base_1.withCode)("target A2A peer must be friend or family trust before delegating.", "untrusted-peer");
|
|
545
573
|
const did = peerDid(peer);
|
|
546
574
|
if (!did)
|
|
547
|
-
return "coordinate requires a DID-keyed peer (connect_to it first to pin its did:key).";
|
|
575
|
+
return (0, tools_base_1.withCode)("coordinate requires a DID-keyed peer (connect_to it first to pin its did:key).", "peer-not-did-keyed");
|
|
548
576
|
/* v8 ignore next -- in-turn coordinate always carries a bundle agentRoot; the ambient-name fallback is defensive (same pattern as connect_to) @preserve */
|
|
549
577
|
const agentName = agentNameFromRoot(ctx?.agentRoot) ?? "ouro-agent";
|
|
550
578
|
const store = storeFor(ctx);
|
|
@@ -587,9 +615,17 @@ exports.a2aToolDefinitions = [
|
|
|
587
615
|
return `coordinated: delegated "${args.task_summary}" to ${peer.name} on mission ${args.mission_key} (requestId ${requestId}).${queued}`;
|
|
588
616
|
}
|
|
589
617
|
catch (error) {
|
|
590
|
-
return `coordinate error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive non-Error failures @preserve */ String(error)}
|
|
618
|
+
return (0, tools_base_1.withCode)(`coordinate error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive non-Error failures @preserve */ String(error)}`, "coordinate-failed");
|
|
591
619
|
}
|
|
592
620
|
},
|
|
621
|
+
ax: { id: "tool:coordinate", group: "a2a", when: "Pick this to hand a piece of work on a named shared mission to another agent and track it until it answers with send_result.", effect: "write", errors: [
|
|
622
|
+
{ code: "no-friend-context", means: "This turn has no friend behind it, so A2A tools can't tell who is asking.", fix: "Use A2A tools only on a turn that a known friend or family member started." },
|
|
623
|
+
{ code: "untrusted-requester", means: "The person on this turn is below friend trust, and A2A tools need friend or family.", fix: "Tell them you can't reach other agents for them; your owner can raise their trust." },
|
|
624
|
+
{ code: "peer-not-found", means: "friend_id names no onboarded A2A agent peer.", fix: "Call a2a_list_peers and pass one of the ids it shows." },
|
|
625
|
+
{ code: "untrusted-peer", means: "That agent peer is below friend trust, so I won't talk to it.", fix: "Ask your owner to raise the peer's trust, or pick a trusted peer from a2a_list_peers." },
|
|
626
|
+
{ code: "peer-not-did-keyed", means: "The peer has no pinned did:key, so the request can't be sealed to it.", fix: "Ask your owner to link the peer again with connect_to, which pins its DID." },
|
|
627
|
+
{ code: "coordinate-failed", means: "Recording or sealing the delegation failed; the reason follows the colon.", fix: "Read the reason, fix what it names, and call coordinate again with the same mission_key." },
|
|
628
|
+
] },
|
|
593
629
|
summaryKeys: ["friend_id", "mission_key"],
|
|
594
630
|
riskProfile: { mutates: "external_side_effect", risk: "high", reason: "delegates a task to a remote agent peer" },
|
|
595
631
|
},
|
|
@@ -633,6 +669,11 @@ exports.a2aToolDefinitions = [
|
|
|
633
669
|
}
|
|
634
670
|
return JSON.stringify(rows, null, 2);
|
|
635
671
|
},
|
|
672
|
+
ax: { id: "tool:list_delegations", group: "a2a", when: "Pick this to check for jobs peers handed you before you start on them, and to find the requestId to answer with.", effect: "read", idempotent: true, errors: [
|
|
673
|
+
{ code: "no-friend-context", means: "This turn has no friend behind it, so A2A tools can't tell who is asking.", fix: "Use A2A tools only on a turn that a known friend or family member started." },
|
|
674
|
+
{ code: "untrusted-requester", means: "The person on this turn is below friend trust, and A2A tools need friend or family.", fix: "Tell them you can't reach other agents for them; your owner can raise their trust." },
|
|
675
|
+
] },
|
|
676
|
+
riskProfile: { mutates: "none", risk: "low" },
|
|
636
677
|
summaryKeys: [],
|
|
637
678
|
},
|
|
638
679
|
{
|
|
@@ -670,24 +711,24 @@ exports.a2aToolDefinitions = [
|
|
|
670
711
|
const missions = missionStore.listAll ? await missionStore.listAll() : [];
|
|
671
712
|
const found = findImportedDelegation(missions, args.request_id);
|
|
672
713
|
if (!found)
|
|
673
|
-
return `no imported delegation found for requestId ${args.request_id} (check list_delegations)
|
|
714
|
+
return (0, tools_base_1.withCode)(`no imported delegation found for requestId ${args.request_id} (check list_delegations).`, "delegation-not-found");
|
|
674
715
|
// The delegator (the recipient of the result) must be a trusted, reachable,
|
|
675
716
|
// DID-keyed peer in our store.
|
|
676
717
|
const delegator = await (0, friends_1.findFriendByDid)(store, found.fromAgentId);
|
|
677
718
|
if (!delegator || !isA2APeer(delegator))
|
|
678
|
-
return `delegating peer not found for ${found.fromAgentId}
|
|
719
|
+
return (0, tools_base_1.withCode)(`delegating peer not found for ${found.fromAgentId}.`, "delegator-not-found");
|
|
679
720
|
if (!(0, friends_1.isTrustedLevel)(delegator.trustLevel))
|
|
680
|
-
return "delegating peer must be friend or family trust to return a result.";
|
|
721
|
+
return (0, tools_base_1.withCode)("delegating peer must be friend or family trust to return a result.", "untrusted-peer");
|
|
681
722
|
const delegatorDid = peerDid(delegator);
|
|
682
723
|
/* v8 ignore next -- unreachable: findFriendByDid matched this record BY its DID (via resolveAgentIdentity, which omits empty DIDs), so a2a.did is always present here. Defensive. @preserve */
|
|
683
724
|
if (!delegatorDid)
|
|
684
725
|
return "delegating peer is not DID-keyed (cannot seal the result).";
|
|
685
726
|
const parsedDelegator = (0, a2a_client_1.parseDidKey)(delegatorDid);
|
|
686
727
|
if (!parsedDelegator)
|
|
687
|
-
return `cannot seal: delegating peer DID is unparseable (${delegatorDid})
|
|
728
|
+
return (0, tools_base_1.withCode)(`cannot seal: delegating peer DID is unparseable (${delegatorDid}).`, "delegator-unreachable");
|
|
688
729
|
const endpointUrl = delegator.agentMeta?.a2a?.endpointUrl;
|
|
689
730
|
if (!endpointUrl)
|
|
690
|
-
return "delegating peer has no reachable A2A endpoint to return the result to.";
|
|
731
|
+
return (0, tools_base_1.withCode)("delegating peer has no reachable A2A endpoint to return the result to.", "delegator-unreachable");
|
|
691
732
|
/* v8 ignore next -- in-turn send_result always carries a bundle agentRoot; the ambient-name fallback is defensive (same pattern as connect_to) @preserve */
|
|
692
733
|
const agentName = agentNameFromRoot(ctx?.agentRoot) ?? "ouro-agent";
|
|
693
734
|
try {
|
|
@@ -733,9 +774,18 @@ exports.a2aToolDefinitions = [
|
|
|
733
774
|
: `${deliveryText(delegator.name, delegatorDid, delivery, "result")} (requestId ${args.request_id})`;
|
|
734
775
|
}
|
|
735
776
|
catch (error) {
|
|
736
|
-
return `send_result error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive non-Error failures @preserve */ String(error)}
|
|
777
|
+
return (0, tools_base_1.withCode)(`send_result error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive non-Error failures @preserve */ String(error)}`, "send-result-failed");
|
|
737
778
|
}
|
|
738
779
|
},
|
|
780
|
+
ax: { id: "tool:send_result", group: "a2a", when: "Pick this once you have finished work another agent delegated to you, to deliver the outcome back against its requestId.", effect: "write", errors: [
|
|
781
|
+
{ code: "no-friend-context", means: "This turn has no friend behind it, so A2A tools can't tell who is asking.", fix: "Use A2A tools only on a turn that a known friend or family member started." },
|
|
782
|
+
{ code: "untrusted-requester", means: "The person on this turn is below friend trust, and A2A tools need friend or family.", fix: "Tell them you can't reach other agents for them; your owner can raise their trust." },
|
|
783
|
+
{ code: "delegation-not-found", means: "No delegation sent to you has that request_id.", fix: "Call list_delegations and pass the requestId it shows." },
|
|
784
|
+
{ code: "delegator-not-found", means: "The agent that sent the delegation isn't a linked peer any more.", fix: "Ask your owner to link that agent again with connect_to, then send the result." },
|
|
785
|
+
{ code: "untrusted-peer", means: "The delegating agent is below friend trust, so I won't send it the result.", fix: "Ask your owner whether to raise its trust before you send." },
|
|
786
|
+
{ code: "delegator-unreachable", means: "The delegating agent's DID can't be read or it has no A2A endpoint, so the result can't be delivered.", fix: "Ask your owner to link that agent again with connect_to, which refreshes its DID and endpoint." },
|
|
787
|
+
{ code: "send-result-failed", means: "Sealing or delivering the result failed; the reason follows the colon.", fix: "Try send_result once more; if it fails again, tell your owner the result is ready but undelivered." },
|
|
788
|
+
] },
|
|
739
789
|
summaryKeys: ["request_id"],
|
|
740
790
|
riskProfile: { mutates: "external_side_effect", risk: "high", reason: "returns a result to a remote agent peer" },
|
|
741
791
|
},
|
|
@@ -5,6 +5,7 @@ const config_1 = require("../heart/config");
|
|
|
5
5
|
const manager_1 = require("../heart/bridges/manager");
|
|
6
6
|
const runtime_1 = require("../nerves/runtime");
|
|
7
7
|
const session_transcript_1 = require("../heart/session-transcript");
|
|
8
|
+
const tools_base_1 = require("./tools-base");
|
|
8
9
|
const NO_SESSION_FOUND_MESSAGE = "no session found for that friend/channel/key combination.";
|
|
9
10
|
const EMPTY_SESSION_MESSAGE = "session exists but has no non-system messages.";
|
|
10
11
|
async function summarizeSessionTailSafely(options) {
|
|
@@ -72,11 +73,11 @@ exports.bridgeToolDefinitions = [
|
|
|
72
73
|
const action = (args.action || "").trim();
|
|
73
74
|
if (action === "begin") {
|
|
74
75
|
if (!ctx?.currentSession) {
|
|
75
|
-
return "bridge_manage begin requires an active session context.";
|
|
76
|
+
return (0, tools_base_1.withCode)("bridge_manage begin requires an active session context.", "no-active-session");
|
|
76
77
|
}
|
|
77
78
|
const objective = (args.objective || "").trim();
|
|
78
79
|
if (!objective)
|
|
79
|
-
return "objective is required for bridge begin.";
|
|
80
|
+
return (0, tools_base_1.withCode)("objective is required for bridge begin.", "missing-objective");
|
|
80
81
|
return (0, manager_1.formatBridgeStatus)(manager.beginBridge({
|
|
81
82
|
objective,
|
|
82
83
|
summary: (args.summary || objective).trim(),
|
|
@@ -85,14 +86,14 @@ exports.bridgeToolDefinitions = [
|
|
|
85
86
|
}
|
|
86
87
|
const bridgeId = (args.bridgeId || "").trim();
|
|
87
88
|
if (!bridgeId) {
|
|
88
|
-
return "bridgeId is required for this bridge action.";
|
|
89
|
+
return (0, tools_base_1.withCode)("bridgeId is required for this bridge action.", "missing-bridge-id");
|
|
89
90
|
}
|
|
90
91
|
if (action === "attach") {
|
|
91
92
|
const friendId = (args.friendId || "").trim();
|
|
92
93
|
const channel = (args.channel || "").trim();
|
|
93
94
|
const key = (args.key || "session").trim();
|
|
94
95
|
if (!friendId || !channel) {
|
|
95
|
-
return "friendId and channel are required for bridge attach.";
|
|
96
|
+
return (0, tools_base_1.withCode)("friendId and channel are required for bridge attach.", "missing-attach-target");
|
|
96
97
|
}
|
|
97
98
|
const sessionPath = (0, config_1.resolveSessionPath)(friendId, channel, key);
|
|
98
99
|
const sessionTail = await summarizeSessionTailSafely({
|
|
@@ -105,7 +106,7 @@ exports.bridgeToolDefinitions = [
|
|
|
105
106
|
summarize: ctx?.summarize,
|
|
106
107
|
});
|
|
107
108
|
if (sessionTail.kind === "missing") {
|
|
108
|
-
return NO_SESSION_FOUND_MESSAGE;
|
|
109
|
+
return (0, tools_base_1.withCode)(NO_SESSION_FOUND_MESSAGE, "session-not-found");
|
|
109
110
|
}
|
|
110
111
|
return (0, manager_1.formatBridgeStatus)(manager.attachSession(bridgeId, {
|
|
111
112
|
friendId,
|
|
@@ -118,7 +119,7 @@ exports.bridgeToolDefinitions = [
|
|
|
118
119
|
if (action === "status") {
|
|
119
120
|
const bridge = manager.getBridge(bridgeId);
|
|
120
121
|
if (!bridge)
|
|
121
|
-
return `bridge not found: ${bridgeId}
|
|
122
|
+
return (0, tools_base_1.withCode)(`bridge not found: ${bridgeId}`, "bridge-not-found");
|
|
122
123
|
return (0, manager_1.formatBridgeStatus)(bridge);
|
|
123
124
|
}
|
|
124
125
|
if (action === "promote_task") {
|
|
@@ -136,6 +137,14 @@ exports.bridgeToolDefinitions = [
|
|
|
136
137
|
}
|
|
137
138
|
return `unknown bridge action: ${action}`;
|
|
138
139
|
},
|
|
140
|
+
ax: { id: "tool:bridge_manage", group: "turn-sessions", when: "Pick this when one piece of work spans conversations already under way, such as two friends' chats, so each can share its status and progress.", effect: "write", errors: [
|
|
141
|
+
{ code: "no-active-session", means: "begin needs the conversation you're in, and this turn has none.", fix: "Start the bridge from a turn inside one of the conversations it should join." },
|
|
142
|
+
{ code: "missing-objective", means: "begin came without an objective.", fix: "Call begin again with objective set to the shared goal in one line." },
|
|
143
|
+
{ code: "missing-bridge-id", means: "Every action but begin needs bridgeId.", fix: "Pass the bridge id that begin returned." },
|
|
144
|
+
{ code: "missing-attach-target", means: "attach needs both friendId and channel.", fix: "Call attach again with the friend's id and the channel of their session, plus key if it isn't 'session'." },
|
|
145
|
+
{ code: "session-not-found", means: "No saved session matches that friendId, channel and key.", fix: "Check the friend, channel and key with query_session, then attach again." },
|
|
146
|
+
{ code: "bridge-not-found", means: "No bridge has that bridgeId.", fix: "Check the id from begin's reply, or begin a new bridge." },
|
|
147
|
+
] },
|
|
139
148
|
summaryKeys: ["action", "bridgeId", "objective", "friendId", "channel", "key"],
|
|
140
149
|
riskProfile: (args) => args.action === "status"
|
|
141
150
|
? { mutates: "none", risk: "low", reason: "bridge status is read-only" }
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tripToolDefinitions = void 0;
|
|
4
4
|
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const tools_base_1 = require("./tools-base");
|
|
5
6
|
const friends_1 = require("@ouro.bot/friends");
|
|
6
7
|
const runtime_1 = require("../nerves/runtime");
|
|
7
8
|
const store_1 = require("../trips/store");
|
|
@@ -120,19 +121,19 @@ function consumePreview(input) {
|
|
|
120
121
|
const token = typeof input.token === "string" ? input.token.trim() : "";
|
|
121
122
|
if (!token) {
|
|
122
123
|
const guidance = `previewToken is required. Call ${input.previewToolName} first, inspect the diff, then retry with its previewToken.`;
|
|
123
|
-
return `${guidance}\nAttempted change:\n${input.attemptSummary}
|
|
124
|
+
return (0, tools_base_1.withCode)(`${guidance}\nAttempted change:\n${input.attemptSummary}`, "preview-token-required");
|
|
124
125
|
}
|
|
125
126
|
pruneExpiredPreviews();
|
|
126
127
|
const preview = pendingTripMutationPreviews.get(token);
|
|
127
128
|
if (!preview)
|
|
128
|
-
return `previewToken is invalid or expired. Call ${input.previewToolName} again
|
|
129
|
+
return (0, tools_base_1.withCode)(`previewToken is invalid or expired. Call ${input.previewToolName} again.`, "preview-token-expired");
|
|
129
130
|
const matches = preview.kind === input.kind
|
|
130
131
|
&& preview.agentName === input.agentName
|
|
131
132
|
&& preview.tripId === input.tripId
|
|
132
133
|
&& preview.legId === input.legId
|
|
133
134
|
&& preview.digest === input.digest;
|
|
134
135
|
if (!matches)
|
|
135
|
-
return `previewToken does not match the current trip state or requested change. Call ${input.previewToolName} again
|
|
136
|
+
return (0, tools_base_1.withCode)(`previewToken does not match the current trip state or requested change. Call ${input.previewToolName} again.`, "preview-token-stale");
|
|
136
137
|
pendingTripMutationPreviews.delete(token);
|
|
137
138
|
return null;
|
|
138
139
|
}
|
|
@@ -393,6 +394,16 @@ function renderTripCalendar(trips, includeUndated) {
|
|
|
393
394
|
}
|
|
394
395
|
return lines.join("\n");
|
|
395
396
|
}
|
|
397
|
+
const TRIP_PRIVATE_ERROR = { code: "trip-ledger-private", means: "The person in this conversation isn't a trusted friend, so the private trip ledger stays closed.", fix: "Don't retry here; trip details are read or changed only in a trusted friend's conversation." };
|
|
398
|
+
const MISSING_ARGUMENT_ERROR = { code: "missing-argument", means: "An argument the text names is empty or missing.", fix: "Call again with that argument filled in." };
|
|
399
|
+
const TRIP_NOT_FOUND_ERROR = { code: "trip-not-found", means: "No trip with that tripId is on this agent's ledger.", fix: "Call trip_status for the ids that exist, and use one of those." };
|
|
400
|
+
const LEG_NOT_FOUND_ERROR = { code: "leg-not-found", means: "The trip has no leg with that legId.", fix: "Read the trip with trip_get and use one of its legIds." };
|
|
401
|
+
const UPDATES_INVALID_ERROR = { code: "updates-invalid", means: "updates isn't a JSON object with at least one field, or it tries to change legId or kind.", fix: "Send only the fields to change; for a different kind, remove the leg and add a new one through trip_upsert." };
|
|
402
|
+
const PREVIEW_TOKEN_ERRORS = [
|
|
403
|
+
{ code: "preview-token-required", means: "No previewToken was given; the text shows the change you attempted.", fix: "Call the preview tool the text names, check its diff, then retry with the previewToken it returns." },
|
|
404
|
+
{ code: "preview-token-expired", means: "The previewToken is unknown, already used, or older than 15 minutes.", fix: "Call the preview tool the text names again, and retry with its new token." },
|
|
405
|
+
{ code: "preview-token-stale", means: "The trip or the requested change differs from what that previewToken previewed.", fix: "Preview the exact change you mean to make again, then retry with the new token." },
|
|
406
|
+
];
|
|
396
407
|
exports.tripToolDefinitions = [
|
|
397
408
|
{
|
|
398
409
|
tool: {
|
|
@@ -405,13 +416,14 @@ exports.tripToolDefinitions = [
|
|
|
405
416
|
},
|
|
406
417
|
handler: async (_args, ctx) => {
|
|
407
418
|
if (!trustAllowsTripAccess(ctx))
|
|
408
|
-
return "trip ledger is private; this tool is only available in trusted contexts.";
|
|
419
|
+
return (0, tools_base_1.withCode)("trip ledger is private; this tool is only available in trusted contexts.", "trip-ledger-private");
|
|
409
420
|
const result = (0, store_1.ensureAgentTripLedger)({ agentName: (0, identity_1.getAgentName)() });
|
|
410
421
|
const verb = result.added ? "created" : "already present";
|
|
411
422
|
return `trip ledger ${verb}: ledgerId=${result.ledger.ledgerId}, keyId=${result.ledger.keyId}, createdAt=${result.ledger.createdAt}`;
|
|
412
423
|
},
|
|
413
424
|
summaryKeys: [],
|
|
414
425
|
riskProfile: { mutates: "durable_state_write", risk: "high", reason: "creates trip ledger state" },
|
|
426
|
+
ax: { id: "tool:trip_ensure_ledger", group: "turn-travel", when: "Pick this first on an agent that has never kept trips, before any trip_upsert; calling it again changes nothing.", effect: "write", idempotent: true, errors: [TRIP_PRIVATE_ERROR] },
|
|
415
427
|
},
|
|
416
428
|
{
|
|
417
429
|
tool: {
|
|
@@ -424,13 +436,17 @@ exports.tripToolDefinitions = [
|
|
|
424
436
|
},
|
|
425
437
|
handler: async (_args, ctx) => {
|
|
426
438
|
if (!trustAllowsTripAccess(ctx))
|
|
427
|
-
return "trip ledger is private; this tool is only available in trusted contexts.";
|
|
439
|
+
return (0, tools_base_1.withCode)("trip ledger is private; this tool is only available in trusted contexts.", "trip-ledger-private");
|
|
428
440
|
const tripIds = (0, store_1.listTripIds)((0, identity_1.getAgentName)());
|
|
429
441
|
if (tripIds.length === 0)
|
|
430
442
|
return "no trips on the ledger yet.";
|
|
431
443
|
return `${tripIds.length} trip(s):\n${tripIds.map((id) => `- ${id}`).join("\n")}`;
|
|
432
444
|
},
|
|
433
445
|
summaryKeys: [],
|
|
446
|
+
riskProfile: { mutates: "none", risk: "low", reason: "lists trip ids from the ledger" },
|
|
447
|
+
ax: { id: "tool:trip_status", group: "turn-travel", when: "Pick this to see which trips exist, as ids only, before opening one with trip_get or listing dates with trip_calendar.", effect: "read", idempotent: true, errors: [
|
|
448
|
+
{ ...TRIP_PRIVATE_ERROR, fix: "Don't retry here; even the list of trips is shown only in a trusted friend's conversation." },
|
|
449
|
+
] },
|
|
434
450
|
},
|
|
435
451
|
{
|
|
436
452
|
tool: {
|
|
@@ -449,10 +465,10 @@ exports.tripToolDefinitions = [
|
|
|
449
465
|
},
|
|
450
466
|
handler: async (args, ctx) => {
|
|
451
467
|
if (!trustAllowsTripAccess(ctx))
|
|
452
|
-
return "trip ledger is private; this tool is only available in trusted contexts.";
|
|
468
|
+
return (0, tools_base_1.withCode)("trip ledger is private; this tool is only available in trusted contexts.", "trip-ledger-private");
|
|
453
469
|
const tripId = args.tripId;
|
|
454
470
|
if (typeof tripId !== "string" || tripId.length === 0)
|
|
455
|
-
return "tripId is required.";
|
|
471
|
+
return (0, tools_base_1.withCode)("tripId is required.", "missing-argument");
|
|
456
472
|
try {
|
|
457
473
|
const trip = (0, store_1.readTripRecord)((0, identity_1.getAgentName)(), tripId);
|
|
458
474
|
return [
|
|
@@ -464,11 +480,13 @@ exports.tripToolDefinitions = [
|
|
|
464
480
|
}
|
|
465
481
|
catch (error) {
|
|
466
482
|
if (error instanceof store_1.TripNotFoundError)
|
|
467
|
-
return error.message;
|
|
483
|
+
return (0, tools_base_1.withCode)(error.message, "trip-not-found");
|
|
468
484
|
throw error;
|
|
469
485
|
}
|
|
470
486
|
},
|
|
471
487
|
summaryKeys: ["tripId"],
|
|
488
|
+
riskProfile: { mutates: "none", risk: "low", reason: "reads one trip record" },
|
|
489
|
+
ax: { id: "tool:trip_get", group: "turn-travel", when: "Pick this to read every field of one trip, including its legs and their evidence, before you change any of it.", effect: "read", idempotent: true, errors: [TRIP_PRIVATE_ERROR, MISSING_ARGUMENT_ERROR, TRIP_NOT_FOUND_ERROR] },
|
|
472
490
|
},
|
|
473
491
|
{
|
|
474
492
|
tool: {
|
|
@@ -487,7 +505,7 @@ exports.tripToolDefinitions = [
|
|
|
487
505
|
},
|
|
488
506
|
handler: async (args, ctx) => {
|
|
489
507
|
if (!trustAllowsTripAccess(ctx))
|
|
490
|
-
return "trip ledger is private; this tool is only available in trusted contexts.";
|
|
508
|
+
return (0, tools_base_1.withCode)("trip ledger is private; this tool is only available in trusted contexts.", "trip-ledger-private");
|
|
491
509
|
try {
|
|
492
510
|
const parsed = parseJsonArg(args.record, "record");
|
|
493
511
|
const replacementTrip = validateTripRecord(parsed);
|
|
@@ -499,11 +517,17 @@ exports.tripToolDefinitions = [
|
|
|
499
517
|
}
|
|
500
518
|
catch (error) {
|
|
501
519
|
if (error instanceof store_1.TripNotFoundError)
|
|
502
|
-
return "no existing trip record found; new trip creation does not require trip_replace_preview.";
|
|
503
|
-
return `replace preview failed: ${error instanceof Error ? error.message : /* v8 ignore next -- non-Error throw is unreachable from validateTripRecord/parseJsonArg */ String(error)}
|
|
520
|
+
return (0, tools_base_1.withCode)("no existing trip record found; new trip creation does not require trip_replace_preview.", "no-existing-trip");
|
|
521
|
+
return (0, tools_base_1.withCode)(`replace preview failed: ${error instanceof Error ? error.message : /* v8 ignore next -- non-Error throw is unreachable from validateTripRecord/parseJsonArg */ String(error)}`, "replace-preview-failed");
|
|
504
522
|
}
|
|
505
523
|
},
|
|
506
524
|
summaryKeys: [],
|
|
525
|
+
riskProfile: { mutates: "none", risk: "low", reason: "previews a whole-trip replacement; it keeps a short-lived token in memory and writes no trip record" },
|
|
526
|
+
ax: { id: "tool:trip_replace_preview", group: "turn-travel", when: "Pick this before trip_upsert overwrites a trip that already exists, to see the diff and get the token that write needs.", effect: "read", errors: [
|
|
527
|
+
TRIP_PRIVATE_ERROR,
|
|
528
|
+
{ code: "no-existing-trip", means: "No trip with this tripId exists yet, so there is nothing to compare against.", fix: "Call trip_upsert directly to create the trip; a new trip needs no previewToken." },
|
|
529
|
+
{ code: "replace-preview-failed", means: "record isn't valid TripRecord JSON; the text names the field.", fix: "Fix that field in the record, then preview again." },
|
|
530
|
+
] },
|
|
507
531
|
},
|
|
508
532
|
{
|
|
509
533
|
tool: {
|
|
@@ -524,7 +548,7 @@ exports.tripToolDefinitions = [
|
|
|
524
548
|
},
|
|
525
549
|
handler: async (args, ctx) => {
|
|
526
550
|
if (!trustAllowsTripAccess(ctx))
|
|
527
|
-
return "trip ledger is private; this tool is only available in trusted contexts.";
|
|
551
|
+
return (0, tools_base_1.withCode)("trip ledger is private; this tool is only available in trusted contexts.", "trip-ledger-private");
|
|
528
552
|
try {
|
|
529
553
|
const parsed = parseJsonArg(args.record, "record");
|
|
530
554
|
const trip = validateTripRecord(parsed);
|
|
@@ -542,7 +566,7 @@ exports.tripToolDefinitions = [
|
|
|
542
566
|
}
|
|
543
567
|
const writeReason = typeof args.writeReason === "string" ? args.writeReason.trim() : "";
|
|
544
568
|
if (replacesExisting && writeReason.length === 0) {
|
|
545
|
-
return "writeReason is required when replacing an existing trip record.";
|
|
569
|
+
return (0, tools_base_1.withCode)("writeReason is required when replacing an existing trip record.", "write-reason-required");
|
|
546
570
|
}
|
|
547
571
|
if (replacesExisting && currentTrip) {
|
|
548
572
|
const digest = replaceTripPreviewDigest({ agentName, currentTrip, replacementTrip: trip });
|
|
@@ -571,11 +595,17 @@ exports.tripToolDefinitions = [
|
|
|
571
595
|
return `trip upserted: ${trip.tripId} (${trip.legs.length} leg(s), status=${trip.status})`;
|
|
572
596
|
}
|
|
573
597
|
catch (error) {
|
|
574
|
-
return `upsert failed: ${error instanceof Error ? error.message : /* v8 ignore next -- non-Error throw is unreachable from validateTripRecord/parseJsonArg */ String(error)}
|
|
598
|
+
return (0, tools_base_1.withCode)(`upsert failed: ${error instanceof Error ? error.message : /* v8 ignore next -- non-Error throw is unreachable from validateTripRecord/parseJsonArg */ String(error)}`, "upsert-failed");
|
|
575
599
|
}
|
|
576
600
|
},
|
|
577
601
|
summaryKeys: [],
|
|
578
602
|
riskProfile: { mutates: "durable_state_write", risk: "high", reason: "creates or replaces trip records" },
|
|
603
|
+
ax: { id: "tool:trip_upsert", group: "turn-travel", when: "Pick this to save a whole new trip, or to overwrite one after trip_replace_preview; to change one leg, use trip_update_leg.", effect: "write", errors: [
|
|
604
|
+
TRIP_PRIVATE_ERROR,
|
|
605
|
+
{ code: "write-reason-required", means: "A trip with this tripId exists, and replacing it needs a writeReason.", fix: "Add a one-line writeReason saying why the whole record is right, with the previewToken from trip_replace_preview." },
|
|
606
|
+
...PREVIEW_TOKEN_ERRORS,
|
|
607
|
+
{ code: "upsert-failed", means: "record isn't valid TripRecord JSON, or the ledger couldn't save it; the text says which.", fix: "Fix the field the text names and call trip_upsert again with the full record." },
|
|
608
|
+
] },
|
|
579
609
|
},
|
|
580
610
|
{
|
|
581
611
|
tool: {
|
|
@@ -596,19 +626,19 @@ exports.tripToolDefinitions = [
|
|
|
596
626
|
},
|
|
597
627
|
handler: async (args, ctx) => {
|
|
598
628
|
if (!trustAllowsTripAccess(ctx))
|
|
599
|
-
return "trip ledger is private; this tool is only available in trusted contexts.";
|
|
629
|
+
return (0, tools_base_1.withCode)("trip ledger is private; this tool is only available in trusted contexts.", "trip-ledger-private");
|
|
600
630
|
const tripId = args.tripId;
|
|
601
631
|
const legId = args.legId;
|
|
602
632
|
if (typeof tripId !== "string" || tripId.length === 0)
|
|
603
|
-
return "tripId is required.";
|
|
633
|
+
return (0, tools_base_1.withCode)("tripId is required.", "missing-argument");
|
|
604
634
|
if (typeof legId !== "string" || legId.length === 0)
|
|
605
|
-
return "legId is required.";
|
|
635
|
+
return (0, tools_base_1.withCode)("legId is required.", "missing-argument");
|
|
606
636
|
try {
|
|
607
637
|
const evidence = validateTripEvidence(parseJsonArg(args.evidence, "evidence"));
|
|
608
638
|
const trip = (0, store_1.readTripRecord)((0, identity_1.getAgentName)(), tripId);
|
|
609
639
|
const legIndex = trip.legs.findIndex((leg) => leg.legId === legId);
|
|
610
640
|
if (legIndex === -1)
|
|
611
|
-
return `leg ${legId} not found in trip ${tripId}
|
|
641
|
+
return (0, tools_base_1.withCode)(`leg ${legId} not found in trip ${tripId}.`, "leg-not-found");
|
|
612
642
|
const leg = trip.legs[legIndex];
|
|
613
643
|
const updatedLeg = {
|
|
614
644
|
...leg,
|
|
@@ -631,12 +661,16 @@ exports.tripToolDefinitions = [
|
|
|
631
661
|
}
|
|
632
662
|
catch (error) {
|
|
633
663
|
if (error instanceof store_1.TripNotFoundError)
|
|
634
|
-
return error.message;
|
|
635
|
-
return `attach failed: ${error instanceof Error ? error.message : /* v8 ignore next -- non-Error throw is unreachable from validateTripEvidence/parseJsonArg/store */ String(error)}
|
|
664
|
+
return (0, tools_base_1.withCode)(error.message, "trip-not-found");
|
|
665
|
+
return (0, tools_base_1.withCode)(`attach failed: ${error instanceof Error ? error.message : /* v8 ignore next -- non-Error throw is unreachable from validateTripEvidence/parseJsonArg/store */ String(error)}`, "attach-failed");
|
|
636
666
|
}
|
|
637
667
|
},
|
|
638
668
|
summaryKeys: ["tripId", "legId"],
|
|
639
669
|
riskProfile: { mutates: "durable_state_write", risk: "high", reason: "appends trip evidence" },
|
|
670
|
+
ax: { id: "tool:trip_attach_evidence", group: "turn-travel", when: "Pick this when one email proves a fact about a leg already on a trip, to add that proof without rewriting the trip.", effect: "write", errors: [
|
|
671
|
+
TRIP_PRIVATE_ERROR, MISSING_ARGUMENT_ERROR, TRIP_NOT_FOUND_ERROR, LEG_NOT_FOUND_ERROR,
|
|
672
|
+
{ code: "attach-failed", means: "evidence isn't valid TripEvidence JSON, or the ledger couldn't save it; the text says which.", fix: "Send evidence with messageId, reason, recordedAt and discoveryMethod, then call again." },
|
|
673
|
+
] },
|
|
640
674
|
},
|
|
641
675
|
{
|
|
642
676
|
tool: {
|
|
@@ -657,39 +691,44 @@ exports.tripToolDefinitions = [
|
|
|
657
691
|
},
|
|
658
692
|
handler: async (args, ctx) => {
|
|
659
693
|
if (!trustAllowsTripAccess(ctx))
|
|
660
|
-
return "trip ledger is private; this tool is only available in trusted contexts.";
|
|
694
|
+
return (0, tools_base_1.withCode)("trip ledger is private; this tool is only available in trusted contexts.", "trip-ledger-private");
|
|
661
695
|
const tripId = args.tripId;
|
|
662
696
|
const legId = args.legId;
|
|
663
697
|
if (typeof tripId !== "string" || tripId.length === 0)
|
|
664
|
-
return "tripId is required.";
|
|
698
|
+
return (0, tools_base_1.withCode)("tripId is required.", "missing-argument");
|
|
665
699
|
if (typeof legId !== "string" || legId.length === 0)
|
|
666
|
-
return "legId is required.";
|
|
700
|
+
return (0, tools_base_1.withCode)("legId is required.", "missing-argument");
|
|
667
701
|
try {
|
|
668
702
|
const updates = parseJsonArg(args.updates, "updates");
|
|
669
703
|
if (!isRecord(updates))
|
|
670
|
-
return "updates must be a JSON object.";
|
|
704
|
+
return (0, tools_base_1.withCode)("updates must be a JSON object.", "updates-invalid");
|
|
671
705
|
if ("legId" in updates)
|
|
672
|
-
return "updates cannot change legId; create a new leg instead.";
|
|
706
|
+
return (0, tools_base_1.withCode)("updates cannot change legId; create a new leg instead.", "updates-invalid");
|
|
673
707
|
if ("kind" in updates)
|
|
674
|
-
return "updates cannot change kind; create a new leg instead.";
|
|
708
|
+
return (0, tools_base_1.withCode)("updates cannot change kind; create a new leg instead.", "updates-invalid");
|
|
675
709
|
if (Object.keys(updates).length === 0)
|
|
676
|
-
return "updates cannot be empty — pass at least one field.";
|
|
710
|
+
return (0, tools_base_1.withCode)("updates cannot be empty — pass at least one field.", "updates-invalid");
|
|
677
711
|
const agentName = (0, identity_1.getAgentName)();
|
|
678
712
|
const trip = (0, store_1.readTripRecord)(agentName, tripId);
|
|
679
713
|
const leg = trip.legs.find((candidate) => candidate.legId === legId);
|
|
680
714
|
if (!leg)
|
|
681
|
-
return `leg ${legId} not found in trip ${tripId}
|
|
715
|
+
return (0, tools_base_1.withCode)(`leg ${legId} not found in trip ${tripId}.`, "leg-not-found");
|
|
682
716
|
const digest = updateLegPreviewDigest({ agentName, trip, leg, updates });
|
|
683
717
|
const token = rememberPreview({ kind: "update_leg", agentName, tripId, legId, digest });
|
|
684
718
|
return renderUpdateLegPreview({ trip, leg, updates, token });
|
|
685
719
|
}
|
|
686
720
|
catch (error) {
|
|
687
721
|
if (error instanceof store_1.TripNotFoundError)
|
|
688
|
-
return error.message;
|
|
689
|
-
return `update preview failed: ${error instanceof Error ? error.message : /* v8 ignore next -- non-Error throw is unreachable from parseJsonArg/store */ String(error)}
|
|
722
|
+
return (0, tools_base_1.withCode)(error.message, "trip-not-found");
|
|
723
|
+
return (0, tools_base_1.withCode)(`update preview failed: ${error instanceof Error ? error.message : /* v8 ignore next -- non-Error throw is unreachable from parseJsonArg/store */ String(error)}`, "update-preview-failed");
|
|
690
724
|
}
|
|
691
725
|
},
|
|
692
726
|
summaryKeys: ["tripId", "legId"],
|
|
727
|
+
riskProfile: { mutates: "none", risk: "low", reason: "previews a leg update; it keeps a short-lived token in memory and writes no trip record" },
|
|
728
|
+
ax: { id: "tool:trip_update_leg_preview", group: "turn-travel", when: "Pick this before trip_update_leg to see each field's old and new value, and to get the token that update needs.", effect: "read", errors: [
|
|
729
|
+
TRIP_PRIVATE_ERROR, MISSING_ARGUMENT_ERROR, TRIP_NOT_FOUND_ERROR, LEG_NOT_FOUND_ERROR, UPDATES_INVALID_ERROR,
|
|
730
|
+
{ code: "update-preview-failed", means: "updates isn't valid JSON, or the ledger couldn't be read; the text says which.", fix: "Send updates as a JSON object string, then preview again." },
|
|
731
|
+
] },
|
|
693
732
|
},
|
|
694
733
|
{
|
|
695
734
|
tool: {
|
|
@@ -713,34 +752,34 @@ exports.tripToolDefinitions = [
|
|
|
713
752
|
},
|
|
714
753
|
handler: async (args, ctx) => {
|
|
715
754
|
if (!trustAllowsTripAccess(ctx))
|
|
716
|
-
return "trip ledger is private; this tool is only available in trusted contexts.";
|
|
755
|
+
return (0, tools_base_1.withCode)("trip ledger is private; this tool is only available in trusted contexts.", "trip-ledger-private");
|
|
717
756
|
const tripId = args.tripId;
|
|
718
757
|
const legId = args.legId;
|
|
719
758
|
const updatedAt = args.updatedAt;
|
|
720
759
|
const updateReason = typeof args.updateReason === "string" ? args.updateReason.trim() : "";
|
|
721
760
|
if (typeof tripId !== "string" || tripId.length === 0)
|
|
722
|
-
return "tripId is required.";
|
|
761
|
+
return (0, tools_base_1.withCode)("tripId is required.", "missing-argument");
|
|
723
762
|
if (typeof legId !== "string" || legId.length === 0)
|
|
724
|
-
return "legId is required.";
|
|
763
|
+
return (0, tools_base_1.withCode)("legId is required.", "missing-argument");
|
|
725
764
|
if (typeof updatedAt !== "string" || updatedAt.length === 0)
|
|
726
|
-
return "updatedAt is required.";
|
|
765
|
+
return (0, tools_base_1.withCode)("updatedAt is required.", "missing-argument");
|
|
727
766
|
if (updateReason.length === 0)
|
|
728
|
-
return "updateReason is required.";
|
|
767
|
+
return (0, tools_base_1.withCode)("updateReason is required.", "missing-argument");
|
|
729
768
|
try {
|
|
730
769
|
const updates = parseJsonArg(args.updates, "updates");
|
|
731
770
|
if (!isRecord(updates))
|
|
732
|
-
return "updates must be a JSON object.";
|
|
771
|
+
return (0, tools_base_1.withCode)("updates must be a JSON object.", "updates-invalid");
|
|
733
772
|
// Reject identity-changing fields — those would silently break referential integrity.
|
|
734
773
|
if ("legId" in updates)
|
|
735
|
-
return "updates cannot change legId; create a new leg instead.";
|
|
774
|
+
return (0, tools_base_1.withCode)("updates cannot change legId; create a new leg instead.", "updates-invalid");
|
|
736
775
|
if ("kind" in updates)
|
|
737
|
-
return "updates cannot change kind; create a new leg instead.";
|
|
776
|
+
return (0, tools_base_1.withCode)("updates cannot change kind; create a new leg instead.", "updates-invalid");
|
|
738
777
|
if (Object.keys(updates).length === 0)
|
|
739
|
-
return "updates cannot be empty — pass at least one field.";
|
|
778
|
+
return (0, tools_base_1.withCode)("updates cannot be empty — pass at least one field.", "updates-invalid");
|
|
740
779
|
const trip = (0, store_1.readTripRecord)((0, identity_1.getAgentName)(), tripId);
|
|
741
780
|
const legIndex = trip.legs.findIndex((leg) => leg.legId === legId);
|
|
742
781
|
if (legIndex === -1)
|
|
743
|
-
return `leg ${legId} not found in trip ${tripId}
|
|
782
|
+
return (0, tools_base_1.withCode)(`leg ${legId} not found in trip ${tripId}.`, "leg-not-found");
|
|
744
783
|
const leg = trip.legs[legIndex];
|
|
745
784
|
const agentName = (0, identity_1.getAgentName)();
|
|
746
785
|
const digest = updateLegPreviewDigest({ agentName, trip, leg, updates });
|
|
@@ -780,12 +819,16 @@ exports.tripToolDefinitions = [
|
|
|
780
819
|
}
|
|
781
820
|
catch (error) {
|
|
782
821
|
if (error instanceof store_1.TripNotFoundError)
|
|
783
|
-
return error.message;
|
|
784
|
-
return `update failed: ${error instanceof Error ? error.message : /* v8 ignore next -- non-Error throw is unreachable from parseJsonArg/store */ String(error)}
|
|
822
|
+
return (0, tools_base_1.withCode)(error.message, "trip-not-found");
|
|
823
|
+
return (0, tools_base_1.withCode)(`update failed: ${error instanceof Error ? error.message : /* v8 ignore next -- non-Error throw is unreachable from parseJsonArg/store */ String(error)}`, "update-failed");
|
|
785
824
|
}
|
|
786
825
|
},
|
|
787
826
|
summaryKeys: ["tripId", "legId"],
|
|
788
827
|
riskProfile: { mutates: "durable_state_write", risk: "high", reason: "updates trip leg fields" },
|
|
828
|
+
ax: { id: "tool:trip_update_leg", group: "turn-travel", when: "Pick this to change a few fields of one leg, such as a new time or seat, once trip_update_leg_preview showed the change.", effect: "write", errors: [
|
|
829
|
+
TRIP_PRIVATE_ERROR, MISSING_ARGUMENT_ERROR, TRIP_NOT_FOUND_ERROR, LEG_NOT_FOUND_ERROR, UPDATES_INVALID_ERROR, ...PREVIEW_TOKEN_ERRORS,
|
|
830
|
+
{ code: "update-failed", means: "updates isn't valid JSON, or the ledger couldn't save the leg; the text says which.", fix: "Send updates as a JSON object string, preview it again, and retry with the new token." },
|
|
831
|
+
] },
|
|
789
832
|
},
|
|
790
833
|
{
|
|
791
834
|
tool: {
|
|
@@ -805,30 +848,35 @@ exports.tripToolDefinitions = [
|
|
|
805
848
|
},
|
|
806
849
|
handler: async (args, ctx) => {
|
|
807
850
|
if (!trustAllowsTripAccess(ctx))
|
|
808
|
-
return "trip ledger is private; this tool is only available in trusted contexts.";
|
|
851
|
+
return (0, tools_base_1.withCode)("trip ledger is private; this tool is only available in trusted contexts.", "trip-ledger-private");
|
|
809
852
|
const tripId = args.tripId;
|
|
810
853
|
const legId = args.legId;
|
|
811
854
|
if (typeof tripId !== "string" || tripId.length === 0)
|
|
812
|
-
return "tripId is required.";
|
|
855
|
+
return (0, tools_base_1.withCode)("tripId is required.", "missing-argument");
|
|
813
856
|
if (typeof legId !== "string" || legId.length === 0)
|
|
814
|
-
return "legId is required.";
|
|
857
|
+
return (0, tools_base_1.withCode)("legId is required.", "missing-argument");
|
|
815
858
|
try {
|
|
816
859
|
const agentName = (0, identity_1.getAgentName)();
|
|
817
860
|
const trip = (0, store_1.readTripRecord)(agentName, tripId);
|
|
818
861
|
const leg = trip.legs.find((candidate) => candidate.legId === legId);
|
|
819
862
|
if (!leg)
|
|
820
|
-
return `leg ${legId} not found in trip ${tripId}
|
|
863
|
+
return (0, tools_base_1.withCode)(`leg ${legId} not found in trip ${tripId}.`, "leg-not-found");
|
|
821
864
|
const digest = removeLegPreviewDigest({ agentName, trip, leg });
|
|
822
865
|
const token = rememberPreview({ kind: "remove_leg", agentName, tripId, legId, digest });
|
|
823
866
|
return renderRemoveLegPreview({ trip, leg, token });
|
|
824
867
|
}
|
|
825
868
|
catch (error) {
|
|
826
869
|
if (error instanceof store_1.TripNotFoundError)
|
|
827
|
-
return error.message;
|
|
828
|
-
return `remove preview failed: ${error instanceof Error ? error.message : String(error)}
|
|
870
|
+
return (0, tools_base_1.withCode)(error.message, "trip-not-found");
|
|
871
|
+
return (0, tools_base_1.withCode)(`remove preview failed: ${error instanceof Error ? error.message : String(error)}`, "remove-preview-failed");
|
|
829
872
|
}
|
|
830
873
|
},
|
|
831
874
|
summaryKeys: ["tripId", "legId"],
|
|
875
|
+
riskProfile: { mutates: "none", risk: "low", reason: "previews a leg removal; it keeps a short-lived token in memory and writes no trip record" },
|
|
876
|
+
ax: { id: "tool:trip_remove_leg_preview", group: "turn-travel", when: "Pick this before trip_remove_leg to see exactly which leg and evidence would go, and to get the token it needs.", effect: "read", errors: [
|
|
877
|
+
TRIP_PRIVATE_ERROR, MISSING_ARGUMENT_ERROR, TRIP_NOT_FOUND_ERROR, LEG_NOT_FOUND_ERROR,
|
|
878
|
+
{ code: "remove-preview-failed", means: "The ledger couldn't be read; the text says why.", fix: "Call trip_status to check the ledger is there, then preview again." },
|
|
879
|
+
] },
|
|
832
880
|
},
|
|
833
881
|
{
|
|
834
882
|
tool: {
|
|
@@ -851,24 +899,24 @@ exports.tripToolDefinitions = [
|
|
|
851
899
|
},
|
|
852
900
|
handler: async (args, ctx) => {
|
|
853
901
|
if (!trustAllowsTripAccess(ctx))
|
|
854
|
-
return "trip ledger is private; this tool is only available in trusted contexts.";
|
|
902
|
+
return (0, tools_base_1.withCode)("trip ledger is private; this tool is only available in trusted contexts.", "trip-ledger-private");
|
|
855
903
|
const tripId = args.tripId;
|
|
856
904
|
const legId = args.legId;
|
|
857
905
|
const updatedAt = args.updatedAt;
|
|
858
906
|
const reason = typeof args.reason === "string" ? args.reason.trim() : "";
|
|
859
907
|
if (typeof tripId !== "string" || tripId.length === 0)
|
|
860
|
-
return "tripId is required.";
|
|
908
|
+
return (0, tools_base_1.withCode)("tripId is required.", "missing-argument");
|
|
861
909
|
if (typeof legId !== "string" || legId.length === 0)
|
|
862
|
-
return "legId is required.";
|
|
910
|
+
return (0, tools_base_1.withCode)("legId is required.", "missing-argument");
|
|
863
911
|
if (typeof updatedAt !== "string" || updatedAt.length === 0)
|
|
864
|
-
return "updatedAt is required.";
|
|
912
|
+
return (0, tools_base_1.withCode)("updatedAt is required.", "missing-argument");
|
|
865
913
|
if (reason.length === 0)
|
|
866
|
-
return "reason is required.";
|
|
914
|
+
return (0, tools_base_1.withCode)("reason is required.", "missing-argument");
|
|
867
915
|
try {
|
|
868
916
|
const trip = (0, store_1.readTripRecord)((0, identity_1.getAgentName)(), tripId);
|
|
869
917
|
const legIndex = trip.legs.findIndex((leg) => leg.legId === legId);
|
|
870
918
|
if (legIndex === -1)
|
|
871
|
-
return `leg ${legId} not found in trip ${tripId}
|
|
919
|
+
return (0, tools_base_1.withCode)(`leg ${legId} not found in trip ${tripId}.`, "leg-not-found");
|
|
872
920
|
const droppedLeg = trip.legs[legIndex];
|
|
873
921
|
const agentName = (0, identity_1.getAgentName)();
|
|
874
922
|
const digest = removeLegPreviewDigest({ agentName, trip, leg: droppedLeg });
|
|
@@ -907,12 +955,16 @@ exports.tripToolDefinitions = [
|
|
|
907
955
|
} /* v8 ignore start -- error-classification branches: TripNotFoundError vs unexpected store failure; the latter is covered by trip-store unit tests rather than tool-level fixtures @preserve */
|
|
908
956
|
catch (error) {
|
|
909
957
|
if (error instanceof store_1.TripNotFoundError)
|
|
910
|
-
return error.message;
|
|
911
|
-
return `remove failed: ${error instanceof Error ? error.message : String(error)}
|
|
958
|
+
return (0, tools_base_1.withCode)(error.message, "trip-not-found");
|
|
959
|
+
return (0, tools_base_1.withCode)(`remove failed: ${error instanceof Error ? error.message : String(error)}`, "remove-failed");
|
|
912
960
|
} /* v8 ignore stop */
|
|
913
961
|
},
|
|
914
962
|
summaryKeys: ["tripId", "legId", "reason"],
|
|
915
963
|
riskProfile: { mutates: "durable_state_write", risk: "high", reason: "removes trip legs" },
|
|
964
|
+
ax: { id: "tool:trip_remove_leg", group: "turn-travel", when: "Pick this to delete one leg added by mistake or whose booking is cancelled, after trip_remove_leg_preview; its evidence goes too.", effect: "write", destructive: true, errors: [
|
|
965
|
+
TRIP_PRIVATE_ERROR, MISSING_ARGUMENT_ERROR, TRIP_NOT_FOUND_ERROR, LEG_NOT_FOUND_ERROR, ...PREVIEW_TOKEN_ERRORS,
|
|
966
|
+
{ code: "remove-failed", means: "The ledger couldn't save the trip without the leg; the text says why.", fix: "Read the trip with trip_get to see whether the leg is still there before trying again." },
|
|
967
|
+
] },
|
|
916
968
|
},
|
|
917
969
|
{
|
|
918
970
|
tool: {
|
|
@@ -931,7 +983,7 @@ exports.tripToolDefinitions = [
|
|
|
931
983
|
},
|
|
932
984
|
handler: async (args, ctx) => {
|
|
933
985
|
if (!trustAllowsTripAccess(ctx))
|
|
934
|
-
return "trip ledger is private; this tool is only available in trusted contexts.";
|
|
986
|
+
return (0, tools_base_1.withCode)("trip ledger is private; this tool is only available in trusted contexts.", "trip-ledger-private");
|
|
935
987
|
const includeUndated = args.includeUndated === "true";
|
|
936
988
|
const tripId = typeof args.tripId === "string" ? args.tripId.trim() : "";
|
|
937
989
|
try {
|
|
@@ -944,11 +996,16 @@ exports.tripToolDefinitions = [
|
|
|
944
996
|
}
|
|
945
997
|
catch (error) {
|
|
946
998
|
if (error instanceof store_1.TripNotFoundError)
|
|
947
|
-
return error.message;
|
|
999
|
+
return (0, tools_base_1.withCode)(error.message, "trip-not-found");
|
|
948
1000
|
throw error;
|
|
949
1001
|
}
|
|
950
1002
|
},
|
|
951
1003
|
summaryKeys: ["tripId"],
|
|
1004
|
+
riskProfile: { mutates: "none", risk: "low", reason: "renders trip legs as a calendar" },
|
|
1005
|
+
ax: { id: "tool:trip_calendar", group: "turn-travel", when: "Pick this to answer what's booked when, gaps between stays, or what changed, from the ledger rather than old notes.", effect: "read", idempotent: true, errors: [
|
|
1006
|
+
TRIP_PRIVATE_ERROR,
|
|
1007
|
+
{ ...TRIP_NOT_FOUND_ERROR, fix: "Leave tripId out to see every trip, or call trip_status for the ids that exist." },
|
|
1008
|
+
] },
|
|
952
1009
|
},
|
|
953
1010
|
{
|
|
954
1011
|
tool: {
|
|
@@ -968,15 +1025,17 @@ exports.tripToolDefinitions = [
|
|
|
968
1025
|
},
|
|
969
1026
|
handler: async (args, ctx) => {
|
|
970
1027
|
if (!trustAllowsTripAccess(ctx))
|
|
971
|
-
return "trip ledger is private; this tool is only available in trusted contexts.";
|
|
1028
|
+
return (0, tools_base_1.withCode)("trip ledger is private; this tool is only available in trusted contexts.", "trip-ledger-private");
|
|
972
1029
|
const name = args.name;
|
|
973
1030
|
const createdAt = args.createdAt;
|
|
974
1031
|
if (typeof name !== "string" || name.length === 0)
|
|
975
|
-
return "name is required.";
|
|
1032
|
+
return (0, tools_base_1.withCode)("name is required.", "missing-argument");
|
|
976
1033
|
if (typeof createdAt !== "string" || createdAt.length === 0)
|
|
977
|
-
return "createdAt is required.";
|
|
1034
|
+
return (0, tools_base_1.withCode)("createdAt is required.", "missing-argument");
|
|
978
1035
|
return (0, core_1.newTripId)((0, identity_1.getAgentName)(), name, createdAt);
|
|
979
1036
|
},
|
|
980
1037
|
summaryKeys: ["name"],
|
|
1038
|
+
riskProfile: { mutates: "none", risk: "low", reason: "computes a trip id" },
|
|
1039
|
+
ax: { id: "tool:trip_new_id", group: "turn-travel", when: "Pick this to get the tripId for a brand-new trip before building its record for trip_upsert; the same inputs give the same id.", effect: "read", idempotent: true, errors: [TRIP_PRIVATE_ERROR, MISSING_ARGUMENT_ERROR] },
|
|
981
1040
|
},
|
|
982
1041
|
];
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1318",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1318",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@ouro.bot/friends"
|
|
12
12
|
],
|