@a5c-ai/babysitter-sdk 0.0.188-staging.e72bed21 → 0.0.188-staging.ee1aa82e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/cli/commands/harnessPhase1.d.ts.map +1 -1
  2. package/dist/cli/commands/harnessPhase1.js +7 -90
  3. package/dist/cli/commands/harnessPhase2.d.ts.map +1 -1
  4. package/dist/cli/commands/harnessPhase2.js +32 -11
  5. package/dist/cli/commands/instructions.d.ts.map +1 -1
  6. package/dist/cli/commands/instructions.js +30 -1
  7. package/dist/cli/commands/sessionWhoami.d.ts.map +1 -1
  8. package/dist/cli/commands/sessionWhoami.js +17 -6
  9. package/dist/cli/main.d.ts.map +1 -1
  10. package/dist/cli/main.js +41 -6
  11. package/dist/config/defaults.d.ts +9 -0
  12. package/dist/config/defaults.d.ts.map +1 -1
  13. package/dist/config/defaults.js +42 -12
  14. package/dist/config/index.d.ts +1 -1
  15. package/dist/config/index.d.ts.map +1 -1
  16. package/dist/config/index.js +2 -1
  17. package/dist/governance/authority.d.ts +68 -0
  18. package/dist/governance/authority.d.ts.map +1 -0
  19. package/dist/governance/authority.js +136 -0
  20. package/dist/governance/categories.d.ts +58 -0
  21. package/dist/governance/categories.d.ts.map +1 -0
  22. package/dist/governance/categories.js +120 -0
  23. package/dist/governance/index.d.ts +8 -0
  24. package/dist/governance/index.d.ts.map +1 -1
  25. package/dist/governance/index.js +47 -1
  26. package/dist/governance/mandate.d.ts +83 -0
  27. package/dist/governance/mandate.d.ts.map +1 -0
  28. package/dist/governance/mandate.js +180 -0
  29. package/dist/governance/permissionEvents.d.ts +51 -0
  30. package/dist/governance/permissionEvents.d.ts.map +1 -0
  31. package/dist/governance/permissionEvents.js +52 -0
  32. package/dist/governance/permissionPropagation.d.ts +18 -0
  33. package/dist/governance/permissionPropagation.d.ts.map +1 -0
  34. package/dist/governance/permissionPropagation.js +58 -0
  35. package/dist/governance/postureBridge.d.ts +17 -0
  36. package/dist/governance/postureBridge.d.ts.map +1 -0
  37. package/dist/governance/postureBridge.js +117 -0
  38. package/dist/governance/sandboxBridge.d.ts +49 -0
  39. package/dist/governance/sandboxBridge.d.ts.map +1 -0
  40. package/dist/governance/sandboxBridge.js +77 -0
  41. package/dist/governance/sandboxPolicy.d.ts +51 -0
  42. package/dist/governance/sandboxPolicy.d.ts.map +1 -0
  43. package/dist/governance/sandboxPolicy.js +177 -0
  44. package/dist/harness/claudeCode.d.ts +3 -3
  45. package/dist/harness/claudeCode.d.ts.map +1 -1
  46. package/dist/harness/claudeCode.js +35 -45
  47. package/dist/harness/codex.d.ts.map +1 -1
  48. package/dist/harness/codex.js +14 -31
  49. package/dist/harness/cursor.d.ts +8 -3
  50. package/dist/harness/cursor.d.ts.map +1 -1
  51. package/dist/harness/cursor.js +15 -11
  52. package/dist/harness/customAdapter.d.ts.map +1 -1
  53. package/dist/harness/customAdapter.js +6 -8
  54. package/dist/harness/discovery.js +1 -1
  55. package/dist/harness/geminiCli.d.ts +1 -1
  56. package/dist/harness/geminiCli.d.ts.map +1 -1
  57. package/dist/harness/geminiCli.js +16 -27
  58. package/dist/harness/githubCopilot.d.ts +7 -4
  59. package/dist/harness/githubCopilot.d.ts.map +1 -1
  60. package/dist/harness/githubCopilot.js +21 -35
  61. package/dist/harness/internal.d.ts.map +1 -1
  62. package/dist/harness/internal.js +2 -10
  63. package/dist/harness/ohMyPi.d.ts.map +1 -1
  64. package/dist/harness/ohMyPi.js +3 -22
  65. package/dist/harness/openclaw.d.ts.map +1 -1
  66. package/dist/harness/openclaw.js +1 -3
  67. package/dist/harness/opencode.d.ts.map +1 -1
  68. package/dist/harness/opencode.js +1 -3
  69. package/dist/harness/pi.d.ts.map +1 -1
  70. package/dist/harness/pi.js +3 -22
  71. package/dist/prompts/capabilityProcessMap.d.ts +33 -0
  72. package/dist/prompts/capabilityProcessMap.d.ts.map +1 -0
  73. package/dist/prompts/capabilityProcessMap.js +105 -0
  74. package/dist/prompts/compose.d.ts.map +1 -1
  75. package/dist/prompts/compose.js +6 -0
  76. package/dist/prompts/context.d.ts.map +1 -1
  77. package/dist/prompts/context.js +14 -10
  78. package/dist/prompts/contextDetect.d.ts +64 -0
  79. package/dist/prompts/contextDetect.d.ts.map +1 -0
  80. package/dist/prompts/contextDetect.js +122 -0
  81. package/dist/prompts/index.d.ts +5 -1
  82. package/dist/prompts/index.d.ts.map +1 -1
  83. package/dist/prompts/index.js +13 -2
  84. package/dist/prompts/parts/criticalRules.js +1 -1
  85. package/dist/prompts/parts/index.d.ts +2 -0
  86. package/dist/prompts/parts/index.d.ts.map +1 -1
  87. package/dist/prompts/parts/index.js +5 -1
  88. package/dist/prompts/parts/priorityLadder.d.ts +7 -0
  89. package/dist/prompts/parts/priorityLadder.d.ts.map +1 -0
  90. package/dist/prompts/parts/priorityLadder.js +13 -0
  91. package/dist/prompts/parts/rootCauseGuardrail.d.ts +7 -0
  92. package/dist/prompts/parts/rootCauseGuardrail.d.ts.map +1 -0
  93. package/dist/prompts/parts/rootCauseGuardrail.js +13 -0
  94. package/dist/prompts/parts/runCreation.js +1 -1
  95. package/dist/prompts/strata.d.ts.map +1 -1
  96. package/dist/prompts/strata.js +2 -0
  97. package/dist/prompts/templates/coding-philosophy.md +3 -0
  98. package/dist/prompts/templates/priority-ladder.md +13 -0
  99. package/dist/prompts/templates/root-cause-guardrail.md +14 -0
  100. package/dist/prompts/templates/tool-preferences.md +2 -0
  101. package/dist/prompts/types.d.ts +4 -1
  102. package/dist/prompts/types.d.ts.map +1 -1
  103. package/dist/runtime/intrinsics/task.d.ts.map +1 -1
  104. package/dist/runtime/intrinsics/task.js +63 -16
  105. package/dist/session/discovery.d.ts +22 -0
  106. package/dist/session/discovery.d.ts.map +1 -0
  107. package/dist/session/discovery.js +40 -0
  108. package/dist/session/index.d.ts +1 -0
  109. package/dist/session/index.d.ts.map +1 -1
  110. package/dist/session/index.js +6 -2
  111. package/dist/storage/journal.d.ts.map +1 -1
  112. package/dist/storage/journal.js +9 -3
  113. package/dist/utils/sessionMarker.d.ts +16 -0
  114. package/dist/utils/sessionMarker.d.ts.map +1 -0
  115. package/dist/{harness → utils}/sessionMarker.js +92 -50
  116. package/package.json +2 -1
  117. package/dist/harness/sessionMarker.d.ts +0 -39
  118. package/dist/harness/sessionMarker.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"harnessPhase1.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/harnessPhase1.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAa1C,OAAO,EAIL,KAAK,2BAA2B,EAEhC,KAAK,iBAAiB,EAGtB,KAAK,oBAAoB,IAAI,0BAA0B,EAyBxD,MAAM,gBAAgB,CAAC;AAkBxB,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,kDAAkD;AAClD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/D;AA0HD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAyB/D;AA85BD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAmDzE;AAED,wBAAgB,sCAAsC,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CAU/F;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgBrE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,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AAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,EAAE,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,aAAa,EAAE,0BAA0B,CAAC;IAC1C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,gBAAgB,EAAE,UAAU,CAAC;CAClD,GAAG,OAAO,CAAC,MAAM,CAAC,CAsjBlB"}
@@ -817,100 +817,17 @@ async function resolvePhase1ProcessLibraryRoot(scope = "binding") {
817
817
  active,
818
818
  };
819
819
  }
820
- function parseRipgrepMatchLine(line, root) {
821
- const match = line.match(/^(.*):([0-9]+):(.*)$/);
822
- if (!match) {
823
- return null;
824
- }
825
- const absolutePath = path.resolve(match[1] ?? "");
826
- if (!isPathWithinRoot(root, absolutePath)) {
827
- return null;
828
- }
829
- return {
830
- path: path.relative(root, absolutePath) || path.basename(absolutePath),
831
- line: Number(match[2] ?? "0"),
832
- excerpt: (match[3] ?? "").trim(),
833
- };
834
- }
835
- async function searchProcessLibrary(query, scope = "binding", limit = harnessUtils_1.PROCESS_LIBRARY_SEARCH_DEFAULT_LIMIT) {
820
+ async function searchProcessLibrary(query, scope = "binding") {
836
821
  const trimmedQuery = query.trim();
837
- if (!trimmedQuery) {
838
- throw new harnessUtils_1.BabysitterRuntimeError("ProcessLibrarySearchQueryMissing", "Process-library search query must not be empty.", { category: harnessUtils_1.ErrorCategory.Validation });
839
- }
840
- const normalizedLimit = Math.max(1, Math.min(limit, 40));
841
822
  const { root } = await resolvePhase1ProcessLibraryRoot(scope);
842
- const matches = [];
843
- const seen = new Set();
844
- const contentResult = await execShellEffect("rg", [
845
- "-n",
846
- "--no-heading",
847
- "--color",
848
- "never",
849
- "--max-count",
850
- "2",
851
- "--max-filesize",
852
- "256K",
853
- "-S",
854
- trimmedQuery,
855
- root,
856
- ], root);
857
- if (contentResult.exitCode === 0 || contentResult.exitCode === 1) {
858
- for (const line of contentResult.stdout.split(/\r?\n/)) {
859
- if (!line.trim()) {
860
- continue;
861
- }
862
- const parsed = parseRipgrepMatchLine(line, root);
863
- if (!parsed) {
864
- continue;
865
- }
866
- const key = `content:${parsed.path}:${parsed.line}`;
867
- if (seen.has(key)) {
868
- continue;
869
- }
870
- seen.add(key);
871
- matches.push({
872
- kind: "content",
873
- path: parsed.path,
874
- line: parsed.line,
875
- excerpt: parsed.excerpt,
876
- });
877
- if (matches.length >= normalizedLimit) {
878
- break;
879
- }
880
- }
881
- }
882
- if (matches.length < normalizedLimit) {
883
- const filesResult = await execShellEffect("rg", ["--files", root], root);
884
- if (filesResult.exitCode === 0 || filesResult.exitCode === 1) {
885
- const loweredQuery = trimmedQuery.toLowerCase();
886
- for (const entry of filesResult.stdout.split(/\r?\n/)) {
887
- const relativePath = entry.trim();
888
- if (!relativePath) {
889
- continue;
890
- }
891
- if (!relativePath.toLowerCase().includes(loweredQuery)) {
892
- continue;
893
- }
894
- const key = `path:${relativePath}`;
895
- if (seen.has(key)) {
896
- continue;
897
- }
898
- seen.add(key);
899
- matches.push({
900
- kind: "path",
901
- path: relativePath,
902
- });
903
- if (matches.length >= normalizedLimit) {
904
- break;
905
- }
906
- }
907
- }
908
- }
823
+ const libraryRoot = path.join(root, "library");
909
824
  return {
910
825
  scope,
911
826
  root,
827
+ libraryRoot,
912
828
  query: trimmedQuery,
913
- matches,
829
+ matches: [],
830
+ instructions: `To search the process library, please use your run_shell_command tool to run 'rg' (ripgrep) inside the library directory: ${libraryRoot.replace(/\\/g, '\\\\')}. For example: run_shell_command({ command: "rg 'your-pattern'", dir_path: "${libraryRoot.replace(/\\/g, '\\\\')}" })`,
914
831
  };
915
832
  }
916
833
  async function readProcessLibraryFile(relativePath, scope = "binding") {
@@ -1431,7 +1348,7 @@ async function runProcessDefinitionPhase(args) {
1431
1348
  {
1432
1349
  name: "babysitter_search_process_library",
1433
1350
  label: "Search Process Library",
1434
- description: "Search the active shared process library by content and path before authoring a process.",
1351
+ description: "Retrieve the active shared process library root path and instructions on how to search it. Use this before authoring a process.",
1435
1352
  parameters: typebox_1.Type.Object({
1436
1353
  query: typebox_1.Type.String(),
1437
1354
  scope: typebox_1.Type.Optional(typebox_1.Type.Union([
@@ -1443,7 +1360,7 @@ async function runProcessDefinitionPhase(args) {
1443
1360
  }),
1444
1361
  execute: async (_toolCallId, params) => {
1445
1362
  writeVerboseData("phase1 tool babysitter_search_process_library request", params);
1446
- const result = await searchProcessLibrary(params.query, params.scope ?? "binding", params.limit);
1363
+ const result = await searchProcessLibrary(params.query, params.scope ?? "binding");
1447
1364
  writeVerboseData("phase1 tool babysitter_search_process_library result", result, 2000);
1448
1365
  return (0, harnessUtils_1.formatToolResult)(result, "Process-library search completed.");
1449
1366
  },
@@ -1 +1 @@
1
- {"version":3,"file":"harnessPhase2.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/harnessPhase2.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAoB1C,OAAO,EAOL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAI3B,KAAK,oBAAoB,IAAI,0BAA0B,EACvD,KAAK,YAAY,EAkCjB,eAAe,EAIhB,MAAM,gBAAgB,CAAC;AAQxB;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAiH9C,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IACP,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MA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;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,EAAE,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,sBAAsB,EAAE,CAAC;IACrC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,aAAa,EAAE,0BAA0B,CAAC;IAC1C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,gBAAgB,EAAE,UAAU,CAAC;CAClD,GAAG,OAAO,CAAC,MAAM,CAAC,CAqwDlB"}
@@ -183,6 +183,24 @@ function subscribeVerbosePiEvents(session, label, opts) {
183
183
  return null;
184
184
  }
185
185
  }
186
+ function resolveHarnessSessionIdForBinding(args, adapter, orchestrationSession) {
187
+ if ((0, harnessUtils_1.isInternalHarness)(args.selectedHarnessName) &&
188
+ orchestrationSession?.sessionId) {
189
+ process.env.PI_SESSION_ID = process.env.PI_SESSION_ID || orchestrationSession.sessionId;
190
+ process.env.OMP_SESSION_ID = process.env.OMP_SESSION_ID || orchestrationSession.sessionId;
191
+ }
192
+ const resolved = adapter.resolveSessionId({});
193
+ if (resolved) {
194
+ return resolved;
195
+ }
196
+ if (args.selectedHarnessName === "codex") {
197
+ return process.env.CODEX_THREAD_ID || process.env.CODEX_SESSION_ID;
198
+ }
199
+ if ((0, harnessUtils_1.isInternalHarness)(args.selectedHarnessName)) {
200
+ return orchestrationSession?.sessionId;
201
+ }
202
+ return undefined;
203
+ }
186
204
  // ── Effect Resolution ────────────────────────────────────────────────
187
205
  async function resolveEffect(action, harnessName, options, piSession, discovered, rl, json, askUserQuestionHandler) {
188
206
  const kind = action.kind;
@@ -642,16 +660,18 @@ async function runOrchestrationPhase(args) {
642
660
  if (!adapter) {
643
661
  throw new harnessUtils_1.BabysitterRuntimeError("HarnessAdapterMissing", `No harness adapter is registered for ${args.selectedHarnessName}.`, { category: harnessUtils_1.ErrorCategory.Configuration });
644
662
  }
645
- const sessionId = adapter.resolveSessionId({}) || process.env.CODEX_THREAD_ID || process.env.CODEX_SESSION_ID;
663
+ const sessionId = resolveHarnessSessionIdForBinding(args, adapter);
646
664
  if (!sessionId) {
647
665
  throw new harnessUtils_1.BabysitterRuntimeError("MissingHarnessSessionId", `Cannot resolve a session ID for harness ${args.selectedHarnessName}.`, { category: harnessUtils_1.ErrorCategory.Configuration });
648
666
  }
667
+ const pluginRoot = adapter.resolvePluginRoot({});
668
+ const stateDir = adapter.resolveStateDir({ pluginRoot });
649
669
  state.sessionBound = await adapter.bindSession({
650
670
  sessionId,
651
671
  runId: state.runId,
652
672
  runDir: state.runDir,
653
- pluginRoot: adapter.resolvePluginRoot({}),
654
- stateDir: path.resolve(args.workspace ?? process.cwd(), ".a5c"),
673
+ pluginRoot,
674
+ stateDir,
655
675
  runsDir: args.runsDir,
656
676
  maxIterations: args.maxIterations,
657
677
  prompt: args.prompt ?? "",
@@ -1029,21 +1049,18 @@ async function runOrchestrationPhase(args) {
1029
1049
  if (!adapter) {
1030
1050
  throw new harnessUtils_1.BabysitterRuntimeError("HarnessAdapterMissing", `No harness adapter is registered for ${args.selectedHarnessName}.`, { category: harnessUtils_1.ErrorCategory.Configuration });
1031
1051
  }
1032
- if ((0, harnessUtils_1.isInternalHarness)(args.selectedHarnessName) &&
1033
- orchestrationSession?.sessionId) {
1034
- process.env.PI_SESSION_ID = process.env.PI_SESSION_ID || orchestrationSession.sessionId;
1035
- process.env.OMP_SESSION_ID = process.env.OMP_SESSION_ID || orchestrationSession.sessionId;
1036
- }
1037
- const sessionId = adapter.resolveSessionId({}) || orchestrationSession?.sessionId;
1052
+ const sessionId = resolveHarnessSessionIdForBinding(args, adapter, orchestrationSession);
1038
1053
  if (!sessionId) {
1039
1054
  throw new harnessUtils_1.BabysitterRuntimeError("MissingHarnessSessionId", `Cannot resolve a session ID for harness ${args.selectedHarnessName}.`, { category: harnessUtils_1.ErrorCategory.Configuration });
1040
1055
  }
1056
+ const pluginRoot = adapter.resolvePluginRoot({});
1057
+ const stateDir = adapter.resolveStateDir({ pluginRoot });
1041
1058
  state.sessionBound = await adapter.bindSession({
1042
1059
  sessionId,
1043
1060
  runId: state.runId,
1044
1061
  runDir: state.runDir,
1045
- pluginRoot: adapter.resolvePluginRoot({}),
1046
- stateDir: path.resolve(args.workspace ?? process.cwd(), ".a5c"),
1062
+ pluginRoot,
1063
+ stateDir,
1047
1064
  runsDir: args.runsDir,
1048
1065
  maxIterations: args.maxIterations,
1049
1066
  prompt: args.prompt ?? "",
@@ -1646,6 +1663,10 @@ async function runOrchestrationPhase(args) {
1646
1663
  if (!orchestrationStateAdvanced(progressSnapshot)) {
1647
1664
  throw new harnessUtils_1.BabysitterRuntimeError("OrchestrationAgentFailed", result.output, { category: harnessUtils_1.ErrorCategory.External });
1648
1665
  }
1666
+ if (state.lastIterationResult?.status === "process-error") {
1667
+ writeVerbose(`[phase2 recovery] continuing after a late orchestration prompt failure because babysitter_run_iterate already returned a recoverable process-error: ${result.output}`);
1668
+ return;
1669
+ }
1649
1670
  if (!(0, harnessUtils_1.isIgnorablePiPromptFailure)(result.output)) {
1650
1671
  throw new harnessUtils_1.BabysitterRuntimeError("OrchestrationAgentFailed", result.output, { category: harnessUtils_1.ErrorCategory.External });
1651
1672
  }
@@ -1 +1 @@
1
- {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAsBH,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,eAAe,GAAG,gBAAgB,GAAG,aAAa,GAAG,qBAAqB,CAAC;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AA+JD;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,MAAM,CAAC,CA6FjB"}
1
+ {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA0BH,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,eAAe,GAAG,gBAAgB,GAAG,aAAa,GAAG,qBAAqB,CAAC;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AA+JD;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,MAAM,CAAC,CA2HjB"}
@@ -195,6 +195,12 @@ async function handleInstructionsCommand(args) {
195
195
  if (!hooksActive) {
196
196
  hookOverride.hookDriven = false;
197
197
  }
198
+ // Detect execution context (CI, trigger, branch, actor) and derive
199
+ // capability flags so the babysit skill can select context-appropriate
200
+ // library processes when dispatching (e.g. GitHub collaboration,
201
+ // scheduled reporting, local-dev relaxations).
202
+ const executionContext = (0, prompts_1.detectExecutionContext)();
203
+ const capabilityFlags = (0, prompts_1.deriveCapabilityFlags)(executionContext);
198
204
  const ctx = factory({
199
205
  interactive: args.interactive,
200
206
  ...libraryInfo,
@@ -218,6 +224,9 @@ async function handleInstructionsCommand(args) {
218
224
  promptType: composer.promptType,
219
225
  hookDriven: ctx.hookDriven,
220
226
  hooksDetected: hooksActive,
227
+ executionContext,
228
+ capabilityFlags,
229
+ suggestedProcesses: (0, prompts_1.processPathsForCapabilities)(capabilityFlags),
221
230
  content,
222
231
  partsIncluded: composer.partsIncluded,
223
232
  }, null, 2));
@@ -229,7 +238,27 @@ async function handleInstructionsCommand(args) {
229
238
  // clarifies the JSON output. The text output is self-explanatory
230
239
  // from the generated instructions.
231
240
  }
232
- console.log(content);
241
+ const activeCapabilities = Object.entries(capabilityFlags)
242
+ .filter(([, v]) => v === true)
243
+ .map(([k]) => k);
244
+ const contextHeader = [
245
+ '## Execution Context',
246
+ '',
247
+ `- CI: \`${executionContext.ci}\``,
248
+ `- Trigger: \`${executionContext.trigger}\``,
249
+ executionContext.branch.ref ? `- Branch: \`${executionContext.branch.ref}\`` : undefined,
250
+ executionContext.repo ? `- Repo: \`${executionContext.repo.owner}/${executionContext.repo.name}\`` : undefined,
251
+ executionContext.actor ? `- Actor: \`${executionContext.actor.login}\`${executionContext.actor.isBot ? ' (bot)' : ''}` : undefined,
252
+ '',
253
+ `Active context capabilities: ${activeCapabilities.length > 0 ? activeCapabilities.map(c => `\`${c}\``).join(', ') : '_(none)_'}`,
254
+ '',
255
+ 'When selecting library processes to dispatch, prefer those whose triggers match the active capabilities above.',
256
+ '',
257
+ '---',
258
+ '',
259
+ ].filter((l) => l !== undefined).join('\n');
260
+ const processGuide = (0, prompts_1.renderCapabilityProcessGuide)(capabilityFlags);
261
+ console.log(contextHeader + processGuide + content);
233
262
  }
234
263
  return 0;
235
264
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sessionWhoami.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/sessionWhoami.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;IAC1E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B;AA6ED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG,mBAAmB,CAI7E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAgBnE"}
1
+ {"version":3,"file":"sessionWhoami.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/sessionWhoami.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgBH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;IAC1E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B;AAsFD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG,mBAAmB,CAI7E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAgBnE"}
@@ -8,9 +8,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.runSessionWhoami = runSessionWhoami;
9
9
  exports.handleSessionWhoami = handleSessionWhoami;
10
10
  const claudeCode_1 = require("../../harness/claudeCode");
11
- const sessionMarker_1 = require("../../harness/sessionMarker");
11
+ const sessionMarker_1 = require("../../utils/sessionMarker");
12
12
  const processLiveness_1 = require("../../utils/processLiveness");
13
13
  const harness_1 = require("../../harness");
14
+ const discovery_1 = require("../../session/discovery");
14
15
  function resolveClaudeCode() {
15
16
  const details = (0, claudeCode_1.resolveSessionIdDetailed)();
16
17
  const markerPath = details.ancestorPid !== null
@@ -54,19 +55,29 @@ function resolveGenericHarness(harness) {
54
55
  const ancestorAlive = ancestorPid !== null ? (0, processLiveness_1.isProcessAlive)(ancestorPid) : null;
55
56
  const markerSessionId = (0, sessionMarker_1.readSessionMarker)(harness);
56
57
  const markerPath = ancestorPid !== null ? (0, sessionMarker_1.getSessionMarkerPath)(harness, ancestorPid) : null;
58
+ const harnessEnvSessionId = (discovery_1.HARNESS_ENV_VARS[harness] || [])
59
+ .map((key) => process.env[key])
60
+ .find((value) => Boolean(value));
61
+ const babysitterEnvSessionId = process.env.BABYSITTER_SESSION_ID;
57
62
  let resolvedFrom = "none";
58
63
  let finalSessionId = sessionId ?? markerSessionId;
59
- if (markerSessionId && (!sessionId || sessionId === markerSessionId)) {
60
- resolvedFrom = "pid-marker";
61
- finalSessionId = markerSessionId;
64
+ if (sessionId && harnessEnvSessionId && sessionId === harnessEnvSessionId) {
65
+ resolvedFrom = "env-var";
66
+ finalSessionId = sessionId;
62
67
  }
63
- else if (sessionId && process.env.BABYSITTER_SESSION_ID === sessionId) {
68
+ else if (sessionId && babysitterEnvSessionId && sessionId === babysitterEnvSessionId) {
64
69
  resolvedFrom = "env-var";
70
+ finalSessionId = sessionId;
71
+ }
72
+ else if (markerSessionId && (!sessionId || sessionId === markerSessionId)) {
73
+ resolvedFrom = "pid-marker";
74
+ finalSessionId = markerSessionId;
65
75
  }
66
76
  else if (sessionId) {
67
77
  resolvedFrom = "env-var";
78
+ finalSessionId = sessionId;
68
79
  }
69
- const envVar = process.env.BABYSITTER_SESSION_ID;
80
+ const envVar = babysitterEnvSessionId;
70
81
  const envVarPresent = Boolean(envVar);
71
82
  let envVarMatches;
72
83
  if (!envVarPresent)
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAoB,MAAM,oBAAoB,CAAC;AAw6B/G;;;;;;;;;GASG;AACH,iBAAS,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA8BlE;AAOD,2EAA2E;AAC3E,QAAA,MAAM,sBAAsB,sCAAgC,CAAC;AAy1D7D,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,sBAAsB,IAAI,uBAAuB,EAAE,CAAC;AAE9F,wBAAgB,mBAAmB;eAEf,MAAM,EAAE,GAA2B,OAAO,CAAC,MAAM,CAAC;kBAswBpD,MAAM;EAIvB"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAoB,MAAM,oBAAoB,CAAC;AAw6B/G;;;;;;;;;GASG;AACH,iBAAS,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA8BlE;AAOD,2EAA2E;AAC3E,QAAA,MAAM,sBAAsB,sCAAgC,CAAC;AAy4D7D,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,sBAAsB,IAAI,uBAAuB,EAAE,CAAC;AAE9F,wBAAgB,mBAAmB;eAEf,MAAM,EAAE,GAA2B,OAAO,CAAC,MAAM,CAAC;kBAswBpD,MAAM;EAIvB"}
package/dist/cli/main.js CHANGED
@@ -1740,10 +1740,16 @@ async function handleTaskPost(parsed) {
1740
1740
  };
1741
1741
  }
1742
1742
  const invocationKey = parsed.invocationKey ?? record.invocationKey;
1743
+ const normalizedShellFailure = parsed.taskStatus === "error" && record.kind === "shell";
1744
+ const committedStatus = normalizedShellFailure ? "ok" : parsed.taskStatus;
1745
+ const committedValue = normalizedShellFailure
1746
+ ? coerceShellFailureResult(errorPayload, stdout, stderr)
1747
+ : value;
1743
1748
  const plan = {
1744
1749
  runDir: toRunRelativePosix(runDir, runDir) ?? runDir,
1745
1750
  effectId: parsed.effectId,
1746
- status: parsed.taskStatus,
1751
+ status: committedStatus,
1752
+ normalizedShellFailure,
1747
1753
  valueProvided: parsed.valuePath || parsed.valueInline ? true : false,
1748
1754
  errorProvided: parsed.errorPath ? true : false,
1749
1755
  stdoutRef: parsed.stdoutRef ?? null,
@@ -1765,10 +1771,10 @@ async function handleTaskPost(parsed) {
1765
1771
  runDir,
1766
1772
  effectId: parsed.effectId,
1767
1773
  invocationKey,
1768
- result: parsed.taskStatus === "ok"
1774
+ result: committedStatus === "ok"
1769
1775
  ? {
1770
1776
  status: "ok",
1771
- value,
1777
+ value: committedValue,
1772
1778
  stdout,
1773
1779
  stderr,
1774
1780
  stdoutRef: parsed.stdoutRef,
@@ -1794,7 +1800,8 @@ async function handleTaskPost(parsed) {
1794
1800
  const resultRef = normalizeArtifactRef(runDir, committed.resultRef) ?? null;
1795
1801
  if (parsed.json) {
1796
1802
  console.log(JSON.stringify({
1797
- status: parsed.taskStatus,
1803
+ status: committedStatus,
1804
+ normalizedShellFailure,
1798
1805
  committed,
1799
1806
  stdoutRef,
1800
1807
  stderrRef,
@@ -1802,7 +1809,9 @@ async function handleTaskPost(parsed) {
1802
1809
  }));
1803
1810
  }
1804
1811
  else {
1805
- const parts = [`[task:post] status=${parsed.taskStatus}`];
1812
+ const parts = [`[task:post] status=${committedStatus}`];
1813
+ if (normalizedShellFailure)
1814
+ parts.push("normalizedShellFailure=true");
1806
1815
  if (stdoutRef)
1807
1816
  parts.push(`stdoutRef=${stdoutRef}`);
1808
1817
  if (stderrRef)
@@ -1811,7 +1820,33 @@ async function handleTaskPost(parsed) {
1811
1820
  parts.push(`resultRef=${resultRef}`);
1812
1821
  console.log(parts.join(" "));
1813
1822
  }
1814
- return parsed.taskStatus === "ok" ? 0 : 1;
1823
+ return committedStatus === "ok" ? 0 : 1;
1824
+ }
1825
+ function coerceShellFailureResult(errorPayload, stdout, stderr) {
1826
+ const payloadData = isJsonRecord(errorPayload)
1827
+ ? (isJsonRecord(errorPayload.data) ? errorPayload.data : errorPayload)
1828
+ : undefined;
1829
+ const exitCode = readNumericField(payloadData, "exitCode") ?? 1;
1830
+ const normalizedStdout = stdout ?? readStringField(payloadData, "stdout") ?? "";
1831
+ const normalizedStderr = stderr ?? readStringField(payloadData, "stderr") ?? "";
1832
+ const errorMessage = readStringField(payloadData, "error")
1833
+ ?? readStringField(payloadData, "message")
1834
+ ?? `Shell command exited with code ${exitCode}`;
1835
+ return {
1836
+ success: false,
1837
+ exitCode,
1838
+ stdout: normalizedStdout,
1839
+ stderr: normalizedStderr,
1840
+ error: errorMessage,
1841
+ };
1842
+ }
1843
+ function readStringField(value, key) {
1844
+ const candidate = value?.[key];
1845
+ return typeof candidate === "string" ? candidate : undefined;
1846
+ }
1847
+ function readNumericField(value, key) {
1848
+ const candidate = value?.[key];
1849
+ return typeof candidate === "number" && Number.isFinite(candidate) ? candidate : undefined;
1815
1850
  }
1816
1851
  async function handleTaskCancel(parsed) {
1817
1852
  if (!parsed.runDirArg || !parsed.effectId) {
@@ -111,6 +111,15 @@ export declare const CONFIG_ENV_VARS: {
111
111
  * They can be overridden via environment variables or explicit config.
112
112
  */
113
113
  export declare const DEFAULTS: Readonly<BabysitterConfig>;
114
+ /**
115
+ * Normalizes a session-state directory path.
116
+ *
117
+ * The canonical session-state location is `<global-root>/state`. Older
118
+ * callers sometimes pass `<global-root>` itself (for example `~/.a5c`).
119
+ * Normalize that legacy/root-style input to the real session-state directory
120
+ * so hooks can still find `<sessionId>.md`.
121
+ */
122
+ export declare function normalizeSessionStateDir(stateDir?: string): string;
114
123
  /**
115
124
  * Returns the global babysitter state directory (~/.a5c/state/).
116
125
  *
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAC;IAEnB;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;CASlB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAwEtC,CAAC;AAEX;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAQ1C;AAED;;;;;;;;G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H,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;CASlB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAwEtC,CAAC;AAeX;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAYlE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAiBxC;AAiDD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAqCjF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,sBAAsB,CA2E/E;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAAC,gBAAgB,CAAC,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAEjE"}
@@ -41,6 +41,7 @@ var __importStar = (this && this.__importStar) || (function () {
41
41
  })();
42
42
  Object.defineProperty(exports, "__esModule", { value: true });
43
43
  exports.DEFAULTS = exports.CONFIG_ENV_VARS = void 0;
44
+ exports.normalizeSessionStateDir = normalizeSessionStateDir;
44
45
  exports.getGlobalStateDir = getGlobalStateDir;
45
46
  exports.getGlobalLogDir = getGlobalLogDir;
46
47
  exports.getConfig = getConfig;
@@ -130,6 +131,36 @@ exports.DEFAULTS = {
130
131
  */
131
132
  largeResultPreviewLimit: 1024 * 1024,
132
133
  };
134
+ function getConfiguredGlobalStateRoot() {
135
+ return process.env.BABYSITTER_GLOBAL_STATE_DIR?.trim()
136
+ ? path.resolve(process.env.BABYSITTER_GLOBAL_STATE_DIR)
137
+ : path.join(os.homedir(), ".a5c");
138
+ }
139
+ function normalizeComparablePath(value) {
140
+ const normalized = path.normalize(path.resolve(value));
141
+ return process.platform === "win32"
142
+ ? normalized.toLowerCase()
143
+ : normalized;
144
+ }
145
+ /**
146
+ * Normalizes a session-state directory path.
147
+ *
148
+ * The canonical session-state location is `<global-root>/state`. Older
149
+ * callers sometimes pass `<global-root>` itself (for example `~/.a5c`).
150
+ * Normalize that legacy/root-style input to the real session-state directory
151
+ * so hooks can still find `<sessionId>.md`.
152
+ */
153
+ function normalizeSessionStateDir(stateDir) {
154
+ const globalRoot = getConfiguredGlobalStateRoot();
155
+ if (!stateDir?.trim()) {
156
+ return path.join(globalRoot, "state");
157
+ }
158
+ const resolved = path.resolve(stateDir);
159
+ if (normalizeComparablePath(resolved) === normalizeComparablePath(globalRoot)) {
160
+ return path.join(globalRoot, "state");
161
+ }
162
+ return resolved;
163
+ }
133
164
  /**
134
165
  * Returns the global babysitter state directory (~/.a5c/state/).
135
166
  *
@@ -141,13 +172,7 @@ exports.DEFAULTS = {
141
172
  * Override: set BABYSITTER_STATE_DIR to use a different path.
142
173
  */
143
174
  function getGlobalStateDir() {
144
- if (process.env.BABYSITTER_STATE_DIR) {
145
- return path.resolve(process.env.BABYSITTER_STATE_DIR);
146
- }
147
- const globalRoot = process.env.BABYSITTER_GLOBAL_STATE_DIR?.trim()
148
- ? path.resolve(process.env.BABYSITTER_GLOBAL_STATE_DIR)
149
- : path.join(os.homedir(), ".a5c");
150
- return path.join(globalRoot, "state");
175
+ return normalizeSessionStateDir(process.env.BABYSITTER_STATE_DIR);
151
176
  }
152
177
  /**
153
178
  * Returns the global babysitter log directory (~/.a5c/logs/).
@@ -159,12 +184,17 @@ function getGlobalStateDir() {
159
184
  * Override: set BABYSITTER_LOG_DIR to use a different path.
160
185
  */
161
186
  function getGlobalLogDir() {
162
- if (process.env.BABYSITTER_LOG_DIR) {
163
- return path.resolve(process.env.BABYSITTER_LOG_DIR);
187
+ const override = process.env.BABYSITTER_LOG_DIR?.trim();
188
+ if (override) {
189
+ if (!path.isAbsolute(override)) {
190
+ const rebased = path.join(os.homedir(), ".a5c", "logs");
191
+ // eslint-disable-next-line no-console
192
+ console.warn(`[babysitter] BABYSITTER_LOG_DIR must be an absolute path; got ${JSON.stringify(override)}. Falling back to ${rebased}. Set an absolute path to silence this warning.`);
193
+ return rebased;
194
+ }
195
+ return path.resolve(override);
164
196
  }
165
- const globalRoot = process.env.BABYSITTER_GLOBAL_STATE_DIR?.trim()
166
- ? path.resolve(process.env.BABYSITTER_GLOBAL_STATE_DIR)
167
- : path.join(os.homedir(), ".a5c");
197
+ const globalRoot = getConfiguredGlobalStateRoot();
168
198
  return path.join(globalRoot, "logs");
169
199
  }
170
200
  /**
@@ -21,5 +21,5 @@
21
21
  * }
22
22
  * ```
23
23
  */
24
- export { type LogLevel, type BabysitterConfig, type ConfigValidationResult, DEFAULTS, CONFIG_ENV_VARS, getConfig, getGlobalLogDir, getGlobalStateDir, validateConfig, getDefaults, isValidLogLevel, } from "./defaults";
24
+ export { type LogLevel, type BabysitterConfig, type ConfigValidationResult, DEFAULTS, CONFIG_ENV_VARS, getConfig, getGlobalLogDir, getGlobalStateDir, normalizeSessionStateDir, validateConfig, getDefaults, isValidLogLevel, } from "./defaults";
25
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAG3B,QAAQ,EACR,eAAe,EAGf,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAG3B,QAAQ,EACR,eAAe,EAGf,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,cAAc,EACd,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC"}
@@ -23,7 +23,7 @@
23
23
  * ```
24
24
  */
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.isValidLogLevel = exports.getDefaults = exports.validateConfig = exports.getGlobalStateDir = exports.getGlobalLogDir = exports.getConfig = exports.CONFIG_ENV_VARS = exports.DEFAULTS = void 0;
26
+ exports.isValidLogLevel = exports.getDefaults = exports.validateConfig = exports.normalizeSessionStateDir = exports.getGlobalStateDir = exports.getGlobalLogDir = exports.getConfig = exports.CONFIG_ENV_VARS = exports.DEFAULTS = void 0;
27
27
  var defaults_1 = require("./defaults");
28
28
  // Constants
29
29
  Object.defineProperty(exports, "DEFAULTS", { enumerable: true, get: function () { return defaults_1.DEFAULTS; } });
@@ -32,6 +32,7 @@ Object.defineProperty(exports, "CONFIG_ENV_VARS", { enumerable: true, get: funct
32
32
  Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return defaults_1.getConfig; } });
33
33
  Object.defineProperty(exports, "getGlobalLogDir", { enumerable: true, get: function () { return defaults_1.getGlobalLogDir; } });
34
34
  Object.defineProperty(exports, "getGlobalStateDir", { enumerable: true, get: function () { return defaults_1.getGlobalStateDir; } });
35
+ Object.defineProperty(exports, "normalizeSessionStateDir", { enumerable: true, get: function () { return defaults_1.normalizeSessionStateDir; } });
35
36
  Object.defineProperty(exports, "validateConfig", { enumerable: true, get: function () { return defaults_1.validateConfig; } });
36
37
  Object.defineProperty(exports, "getDefaults", { enumerable: true, get: function () { return defaults_1.getDefaults; } });
37
38
  Object.defineProperty(exports, "isValidLogLevel", { enumerable: true, get: function () { return defaults_1.isValidLogLevel; } });
@@ -0,0 +1,68 @@
1
+ /**
2
+ * GAP-SEC: Authority Chain system.
3
+ *
4
+ * Models delegation chains from human principals through agent principals,
5
+ * with monotonically narrowing scope at each hop.
6
+ */
7
+ import type { MandateScope } from './mandate';
8
+ /** A principal (human or agent) in the authority chain. */
9
+ export interface AuthorityPrincipal {
10
+ kind: 'human' | 'agent';
11
+ id: string;
12
+ displayName: string;
13
+ }
14
+ /** A single grant of authority from one principal to another. */
15
+ export interface AuthorityGrant {
16
+ from: AuthorityPrincipal;
17
+ to: AuthorityPrincipal;
18
+ scope: MandateScope;
19
+ grantedAt: string;
20
+ revokedAt?: string;
21
+ expiresAt?: string;
22
+ }
23
+ /** A link in the authority chain (wrapping a grant). */
24
+ export interface AuthorityChainLink {
25
+ grant: AuthorityGrant;
26
+ index: number;
27
+ }
28
+ /** A full authority chain from root to leaf. */
29
+ export interface AuthorityChain {
30
+ grants: AuthorityGrant[];
31
+ rootPrincipal: AuthorityPrincipal;
32
+ effectiveScope: MandateScope;
33
+ }
34
+ /** Result of chain validation. */
35
+ export interface AuthorityChainValidationResult {
36
+ valid: boolean;
37
+ reason?: string;
38
+ }
39
+ /** Result of tracing authority to a human root. */
40
+ export interface AuthorityTrace {
41
+ humanPrincipal: AuthorityPrincipal;
42
+ hopCount: number;
43
+ principalPath: string[];
44
+ }
45
+ /**
46
+ * Create an authority chain from an ordered list of grants.
47
+ * Computes the effective scope as the intersection of all grant scopes.
48
+ */
49
+ export declare function createAuthorityChain(grants: AuthorityGrant[]): AuthorityChain;
50
+ /**
51
+ * Validate an authority chain. Checks:
52
+ * 1. Root must be a human principal.
53
+ * 2. No revoked links.
54
+ * 3. No expired links.
55
+ * 4. Scopes monotonically narrow (no expansion).
56
+ */
57
+ export declare function validateAuthorityChain(chain: AuthorityChain): AuthorityChainValidationResult;
58
+ /**
59
+ * Attenuate (intersect) two scopes. The result is never wider than either input.
60
+ * Pure function.
61
+ */
62
+ export declare function attenuateScope(parent: MandateScope, child: MandateScope): MandateScope;
63
+ /**
64
+ * Trace authority back to the human root, returning the human principal,
65
+ * hop count, and full principal path.
66
+ */
67
+ export declare function traceAuthorityToHuman(chain: AuthorityChain): AuthorityTrace;
68
+ //# sourceMappingURL=authority.d.ts.map