@ouro.bot/cli 0.1.0-alpha.1317 → 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 CHANGED
@@ -1,6 +1,12 @@
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
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1317",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1317",
2
+ "runtimeVersion": "0.1.0-alpha.1318",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -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.1317</Repository>
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>
@@ -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
  ];
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1317",
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.1317",
9
+ "version": "0.1.0-alpha.1318",
10
10
  "bundleDependencies": [
11
11
  "@ouro.bot/friends"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1317",
3
+ "version": "0.1.0-alpha.1318",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },