rhachet 1.17.0 → 1.19.0

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 (110) hide show
  1. package/dist/_topublish/rhachet-brain-anthropic/src/atoms/genBrainAtom.d.ts +19 -0
  2. package/dist/_topublish/rhachet-brain-anthropic/src/atoms/genBrainAtom.js +95 -0
  3. package/dist/_topublish/rhachet-brain-anthropic/src/atoms/genBrainAtom.js.map +1 -0
  4. package/dist/_topublish/rhachet-brain-anthropic/src/index.d.ts +14 -0
  5. package/dist/_topublish/rhachet-brain-anthropic/src/index.js +27 -0
  6. package/dist/_topublish/rhachet-brain-anthropic/src/index.js.map +1 -0
  7. package/dist/_topublish/rhachet-brain-anthropic/src/repls/genBrainRepl.d.ts +19 -0
  8. package/dist/_topublish/rhachet-brain-anthropic/src/repls/genBrainRepl.js +137 -0
  9. package/dist/_topublish/rhachet-brain-anthropic/src/repls/genBrainRepl.js.map +1 -0
  10. package/dist/_topublish/rhachet-brain-openai/src/atoms/genBrainAtom.d.ts +19 -0
  11. package/dist/_topublish/rhachet-brain-openai/src/atoms/genBrainAtom.js +86 -0
  12. package/dist/_topublish/rhachet-brain-openai/src/atoms/genBrainAtom.js.map +1 -0
  13. package/dist/_topublish/rhachet-brain-openai/src/index.d.ts +14 -0
  14. package/dist/_topublish/rhachet-brain-openai/src/index.js +27 -0
  15. package/dist/_topublish/rhachet-brain-openai/src/index.js.map +1 -0
  16. package/dist/_topublish/rhachet-brain-openai/src/repls/genBrainRepl.d.ts +19 -0
  17. package/dist/_topublish/rhachet-brain-openai/src/repls/genBrainRepl.js +99 -0
  18. package/dist/_topublish/rhachet-brain-openai/src/repls/genBrainRepl.js.map +1 -0
  19. package/dist/contract/cli/invoke.js +14 -2
  20. package/dist/contract/cli/invoke.js.map +1 -1
  21. package/dist/contract/cli/invokeAct.d.ts +14 -0
  22. package/dist/contract/cli/invokeAct.js +92 -0
  23. package/dist/contract/cli/invokeAct.js.map +1 -0
  24. package/dist/contract/cli/invokeAsk.d.ts +4 -1
  25. package/dist/contract/cli/invokeAsk.js +84 -21
  26. package/dist/contract/cli/invokeAsk.js.map +1 -1
  27. package/dist/contract/cli/invokeRun.d.ts +6 -2
  28. package/dist/contract/cli/invokeRun.js +111 -18
  29. package/dist/contract/cli/invokeRun.js.map +1 -1
  30. package/dist/contract/sdk.d.ts +3 -0
  31. package/dist/contract/sdk.js +7 -1
  32. package/dist/contract/sdk.js.map +1 -1
  33. package/dist/domain.objects/Actor.d.ts +94 -0
  34. package/dist/domain.objects/Actor.js +18 -0
  35. package/dist/domain.objects/Actor.js.map +1 -0
  36. package/dist/domain.objects/ActorRoleSkill.d.ts +41 -0
  37. package/dist/domain.objects/ActorRoleSkill.js +8 -0
  38. package/dist/domain.objects/ActorRoleSkill.js.map +1 -0
  39. package/dist/domain.objects/BrainAtom.d.ts +54 -0
  40. package/dist/domain.objects/BrainAtom.js +9 -0
  41. package/dist/domain.objects/BrainAtom.js.map +1 -0
  42. package/dist/domain.objects/BrainAtomPlugs.d.ts +17 -0
  43. package/dist/domain.objects/BrainAtomPlugs.js +8 -0
  44. package/dist/domain.objects/BrainAtomPlugs.js.map +1 -0
  45. package/dist/domain.objects/BrainRepl.d.ts +74 -0
  46. package/dist/domain.objects/BrainRepl.js +9 -0
  47. package/dist/domain.objects/BrainRepl.js.map +1 -0
  48. package/dist/domain.objects/BrainReplPlugs.d.ts +34 -0
  49. package/dist/domain.objects/BrainReplPlugs.js +8 -0
  50. package/dist/domain.objects/BrainReplPlugs.js.map +1 -0
  51. package/dist/domain.objects/ContextBrain.d.ts +73 -0
  52. package/dist/domain.objects/ContextBrain.js +8 -0
  53. package/dist/domain.objects/ContextBrain.js.map +1 -0
  54. package/dist/domain.objects/InvokeHooks.d.ts +38 -1
  55. package/dist/domain.objects/Role.d.ts +43 -2
  56. package/dist/domain.objects/Role.js +9 -0
  57. package/dist/domain.objects/Role.js.map +1 -1
  58. package/dist/domain.objects/index.d.ts +5 -0
  59. package/dist/domain.objects/index.js +5 -0
  60. package/dist/domain.objects/index.js.map +1 -1
  61. package/dist/domain.operations/actor/actorAct.d.ts +15 -0
  62. package/dist/domain.operations/actor/actorAct.js +30 -0
  63. package/dist/domain.operations/actor/actorAct.js.map +1 -0
  64. package/dist/domain.operations/actor/actorAsk.d.ts +15 -0
  65. package/dist/domain.operations/actor/actorAsk.js +32 -0
  66. package/dist/domain.operations/actor/actorAsk.js.map +1 -0
  67. package/dist/domain.operations/actor/actorRun.d.ts +11 -0
  68. package/dist/domain.operations/actor/actorRun.js +25 -0
  69. package/dist/domain.operations/actor/actorRun.js.map +1 -0
  70. package/dist/domain.operations/actor/findActorBrainInAllowlist.d.ts +16 -0
  71. package/dist/domain.operations/actor/findActorBrainInAllowlist.js +33 -0
  72. package/dist/domain.operations/actor/findActorBrainInAllowlist.js.map +1 -0
  73. package/dist/domain.operations/actor/findActorRoleSkillBySlug.d.ts +13 -0
  74. package/dist/domain.operations/actor/findActorRoleSkillBySlug.js +68 -0
  75. package/dist/domain.operations/actor/findActorRoleSkillBySlug.js.map +1 -0
  76. package/dist/domain.operations/actor/genActor.d.ts +18 -0
  77. package/dist/domain.operations/actor/genActor.js +98 -0
  78. package/dist/domain.operations/actor/genActor.js.map +1 -0
  79. package/dist/domain.operations/brainAtom/askViaBrainAtom.d.ts +22 -0
  80. package/dist/domain.operations/brainAtom/askViaBrainAtom.js +19 -0
  81. package/dist/domain.operations/brainAtom/askViaBrainAtom.js.map +1 -0
  82. package/dist/domain.operations/brainRepl/actViaBrainRepl.d.ts +26 -0
  83. package/dist/domain.operations/brainRepl/actViaBrainRepl.js +23 -0
  84. package/dist/domain.operations/brainRepl/actViaBrainRepl.js.map +1 -0
  85. package/dist/domain.operations/brainRepl/askViaBrainRepl.d.ts +26 -0
  86. package/dist/domain.operations/brainRepl/askViaBrainRepl.js +23 -0
  87. package/dist/domain.operations/brainRepl/askViaBrainRepl.js.map +1 -0
  88. package/dist/domain.operations/briefs/castBriefsToPrompt.d.ts +13 -0
  89. package/dist/domain.operations/briefs/castBriefsToPrompt.js +21 -0
  90. package/dist/domain.operations/briefs/castBriefsToPrompt.js.map +1 -0
  91. package/dist/domain.operations/context/findBrainAtomByRef.d.ts +10 -0
  92. package/dist/domain.operations/context/findBrainAtomByRef.js +23 -0
  93. package/dist/domain.operations/context/findBrainAtomByRef.js.map +1 -0
  94. package/dist/domain.operations/context/findBrainReplByRef.d.ts +10 -0
  95. package/dist/domain.operations/context/findBrainReplByRef.js +23 -0
  96. package/dist/domain.operations/context/findBrainReplByRef.js.map +1 -0
  97. package/dist/domain.operations/context/genContextBrain.d.ts +14 -0
  98. package/dist/domain.operations/context/genContextBrain.js +51 -0
  99. package/dist/domain.operations/context/genContextBrain.js.map +1 -0
  100. package/dist/domain.operations/invoke/executeSkill.d.ts +3 -1
  101. package/dist/domain.operations/invoke/executeSkill.js +16 -3
  102. package/dist/domain.operations/invoke/executeSkill.js.map +1 -1
  103. package/dist/domain.operations/invoke/getBrainReplsByOpts.d.ts +14 -0
  104. package/dist/domain.operations/invoke/getBrainReplsByOpts.js +43 -0
  105. package/dist/domain.operations/invoke/getBrainReplsByOpts.js.map +1 -0
  106. package/dist/domain.operations/schema/castZodToJsonSchema.d.ts +14 -0
  107. package/dist/domain.operations/schema/castZodToJsonSchema.js +23 -0
  108. package/dist/domain.operations/schema/castZodToJsonSchema.js.map +1 -0
  109. package/package.json +7 -2
  110. package/readme.md +175 -34
@@ -0,0 +1,10 @@
1
+ import type { RefByUnique } from 'domain-objects';
2
+ import type { BrainAtom } from '../../domain.objects/BrainAtom';
3
+ /**
4
+ * .what = finds a brain atom by its unique reference
5
+ * .why = enables lookup of registered atoms by { repo, slug }
6
+ */
7
+ export declare const findBrainAtomByRef: (input: {
8
+ atoms: BrainAtom[];
9
+ ref: RefByUnique<typeof BrainAtom>;
10
+ }) => BrainAtom;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findBrainAtomByRef = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ /**
6
+ * .what = finds a brain atom by its unique reference
7
+ * .why = enables lookup of registered atoms by { repo, slug }
8
+ */
9
+ const findBrainAtomByRef = (input) => {
10
+ // fail fast if no atoms available
11
+ if (input.atoms.length === 0)
12
+ throw new helpful_errors_1.BadRequestError('no atoms available in context', {
13
+ ref: input.ref,
14
+ });
15
+ // lookup atom by ref
16
+ const atomFound = input.atoms.find((a) => a.repo === input.ref.repo && a.slug === input.ref.slug);
17
+ // fail if not found
18
+ if (!atomFound)
19
+ throw new helpful_errors_1.BadRequestError('brain atom not found', { ref: input.ref });
20
+ return atomFound;
21
+ };
22
+ exports.findBrainAtomByRef = findBrainAtomByRef;
23
+ //# sourceMappingURL=findBrainAtomByRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findBrainAtomByRef.js","sourceRoot":"","sources":["../../../src/domain.operations/context/findBrainAtomByRef.ts"],"names":[],"mappings":";;;AACA,mDAAiD;AAIjD;;;GAGG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAGlC,EAAa,EAAE;IACd,kCAAkC;IAClC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM,IAAI,gCAAe,CAAC,+BAA+B,EAAE;YACzD,GAAG,EAAE,KAAK,CAAC,GAAG;SACf,CAAC,CAAC;IAEL,qBAAqB;IACrB,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAChC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,GAAG,CAAC,IAAI,CAC9D,CAAC;IAEF,oBAAoB;IACpB,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,gCAAe,CAAC,sBAAsB,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAExE,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AApBW,QAAA,kBAAkB,sBAoB7B"}
@@ -0,0 +1,10 @@
1
+ import type { RefByUnique } from 'domain-objects';
2
+ import type { BrainRepl } from '../../domain.objects/BrainRepl';
3
+ /**
4
+ * .what = finds a brain repl by its unique reference
5
+ * .why = enables lookup of registered repls by { repo, slug }
6
+ */
7
+ export declare const findBrainReplByRef: (input: {
8
+ repls: BrainRepl[];
9
+ ref: RefByUnique<typeof BrainRepl>;
10
+ }) => BrainRepl;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findBrainReplByRef = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ /**
6
+ * .what = finds a brain repl by its unique reference
7
+ * .why = enables lookup of registered repls by { repo, slug }
8
+ */
9
+ const findBrainReplByRef = (input) => {
10
+ // fail fast if no repls available
11
+ if (input.repls.length === 0)
12
+ throw new helpful_errors_1.BadRequestError('no repls available in context', {
13
+ ref: input.ref,
14
+ });
15
+ // lookup repl by ref
16
+ const replFound = input.repls.find((r) => r.repo === input.ref.repo && r.slug === input.ref.slug);
17
+ // fail if not found
18
+ if (!replFound)
19
+ throw new helpful_errors_1.BadRequestError('brain repl not found', { ref: input.ref });
20
+ return replFound;
21
+ };
22
+ exports.findBrainReplByRef = findBrainReplByRef;
23
+ //# sourceMappingURL=findBrainReplByRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findBrainReplByRef.js","sourceRoot":"","sources":["../../../src/domain.operations/context/findBrainReplByRef.ts"],"names":[],"mappings":";;;AACA,mDAAiD;AAIjD;;;GAGG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAGlC,EAAa,EAAE;IACd,kCAAkC;IAClC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM,IAAI,gCAAe,CAAC,+BAA+B,EAAE;YACzD,GAAG,EAAE,KAAK,CAAC,GAAG;SACf,CAAC,CAAC;IAEL,qBAAqB;IACrB,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAChC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,GAAG,CAAC,IAAI,CAC9D,CAAC;IAEF,oBAAoB;IACpB,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,gCAAe,CAAC,sBAAsB,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAExE,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AApBW,QAAA,kBAAkB,sBAoB7B"}
@@ -0,0 +1,14 @@
1
+ import type { BrainAtom } from '../../domain.objects/BrainAtom';
2
+ import type { BrainRepl } from '../../domain.objects/BrainRepl';
3
+ import type { ContextBrain } from '../../domain.objects/ContextBrain';
4
+ /**
5
+ * .what = factory to create a brain context from plugin-provided atoms and repls
6
+ * .why =
7
+ * - provides a clean entry point for context creation
8
+ * - validates no duplicate { repo, slug } identifiers
9
+ * - composes the context with lookup and delegation logic
10
+ */
11
+ export declare const genContextBrain: (input: {
12
+ atoms?: BrainAtom[];
13
+ repls?: BrainRepl[];
14
+ }) => ContextBrain;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.genContextBrain = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ const findBrainAtomByRef_1 = require("./findBrainAtomByRef");
6
+ const findBrainReplByRef_1 = require("./findBrainReplByRef");
7
+ /**
8
+ * .what = factory to create a brain context from plugin-provided atoms and repls
9
+ * .why =
10
+ * - provides a clean entry point for context creation
11
+ * - validates no duplicate { repo, slug } identifiers
12
+ * - composes the context with lookup and delegation logic
13
+ */
14
+ const genContextBrain = (input) => {
15
+ // default to empty arrays
16
+ const atoms = input.atoms ?? [];
17
+ const repls = input.repls ?? [];
18
+ // validate no duplicate atoms
19
+ const atomKeys = atoms.map((a) => `${a.repo}:${a.slug}`);
20
+ const duplicateAtom = atomKeys.find((k, i) => atomKeys.indexOf(k) !== i);
21
+ if (duplicateAtom)
22
+ throw new helpful_errors_1.BadRequestError('duplicate atom identifier', { duplicateAtom });
23
+ // validate no duplicate repls
24
+ const replKeys = repls.map((r) => `${r.repo}:${r.slug}`);
25
+ const duplicateRepl = replKeys.find((k, i) => replKeys.indexOf(k) !== i);
26
+ if (duplicateRepl)
27
+ throw new helpful_errors_1.BadRequestError('duplicate repl identifier', { duplicateRepl });
28
+ // return context with lookup and delegation
29
+ return {
30
+ brain: {
31
+ atom: {
32
+ ask: async (askInput) => {
33
+ const atom = (0, findBrainAtomByRef_1.findBrainAtomByRef)({ atoms, ref: askInput.brain });
34
+ return atom.ask(askInput, {});
35
+ },
36
+ },
37
+ repl: {
38
+ ask: async (askInput) => {
39
+ const repl = (0, findBrainReplByRef_1.findBrainReplByRef)({ repls, ref: askInput.brain });
40
+ return repl.ask(askInput, {});
41
+ },
42
+ act: async (actInput) => {
43
+ const repl = (0, findBrainReplByRef_1.findBrainReplByRef)({ repls, ref: actInput.brain });
44
+ return repl.act(actInput, {});
45
+ },
46
+ },
47
+ },
48
+ };
49
+ };
50
+ exports.genContextBrain = genContextBrain;
51
+ //# sourceMappingURL=genContextBrain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genContextBrain.js","sourceRoot":"","sources":["../../../src/domain.operations/context/genContextBrain.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAMjD,6DAA0D;AAC1D,6DAA0D;AAE1D;;;;;;GAMG;AACI,MAAM,eAAe,GAAG,CAAC,KAG/B,EAAgB,EAAE;IACjB,0BAA0B;IAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;IAEhC,8BAA8B;IAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACzD,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACzE,IAAI,aAAa;QACf,MAAM,IAAI,gCAAe,CAAC,2BAA2B,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAE5E,8BAA8B;IAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACzD,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACzE,IAAI,aAAa;QACf,MAAM,IAAI,gCAAe,CAAC,2BAA2B,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAE5E,4CAA4C;IAC5C,OAAO;QACL,KAAK,EAAE;YACL,IAAI,EAAE;gBACJ,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;oBACtB,MAAM,IAAI,GAAG,IAAA,uCAAkB,EAAC,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;oBAChE,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAQ,CAAC;gBACvC,CAAC;aACF;YACD,IAAI,EAAE;gBACJ,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;oBACtB,MAAM,IAAI,GAAG,IAAA,uCAAkB,EAAC,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;oBAChE,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAQ,CAAC;gBACvC,CAAC;gBACD,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;oBACtB,MAAM,IAAI,GAAG,IAAA,uCAAkB,EAAC,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;oBAChE,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAQ,CAAC;gBACvC,CAAC;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAzCW,QAAA,eAAe,mBAyC1B"}
@@ -2,8 +2,10 @@ import type { RoleSkillExecutable } from '../../domain.objects/RoleSkillExecutab
2
2
  /**
3
3
  * .what = executes a skill script with passthrough args
4
4
  * .why = runs the discovered skill with full arg passthrough
5
+ *
6
+ * .note = captures stdout and parses JSON output when available
5
7
  */
6
8
  export declare const executeSkill: (input: {
7
9
  skill: RoleSkillExecutable;
8
10
  args: string[];
9
- }) => void;
11
+ }) => unknown;
@@ -5,6 +5,8 @@ const node_child_process_1 = require("node:child_process");
5
5
  /**
6
6
  * .what = executes a skill script with passthrough args
7
7
  * .why = runs the discovered skill with full arg passthrough
8
+ *
9
+ * .note = captures stdout and parses JSON output when available
8
10
  */
9
11
  const executeSkill = (input) => {
10
12
  // build command with args
@@ -16,12 +18,23 @@ const executeSkill = (input) => {
16
18
  return arg;
17
19
  })
18
20
  .join(' ');
19
- // execute with inherited stdio
20
- (0, node_child_process_1.execSync)(command, {
21
+ // execute and capture stdout
22
+ const stdout = (0, node_child_process_1.execSync)(command, {
21
23
  cwd: process.cwd(),
22
- stdio: 'inherit',
23
24
  shell: '/bin/bash',
25
+ encoding: 'utf-8',
24
26
  });
27
+ // parse JSON output if present
28
+ const trimmed = stdout.trim();
29
+ if (!trimmed)
30
+ return undefined;
31
+ try {
32
+ return JSON.parse(trimmed);
33
+ }
34
+ catch {
35
+ // return raw string if not valid JSON
36
+ return trimmed;
37
+ }
25
38
  };
26
39
  exports.executeSkill = executeSkill;
27
40
  //# sourceMappingURL=executeSkill.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"executeSkill.js","sourceRoot":"","sources":["../../../src/domain.operations/invoke/executeSkill.ts"],"names":[],"mappings":";;;AAEA,2DAA8C;AAE9C;;;GAGG;AACI,MAAM,YAAY,GAAG,CAAC,KAG5B,EAAQ,EAAE;IACT,0BAA0B;IAC1B,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;SAC9C,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACX,yBAAyB;QACzB,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,GAAG,GAAG,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,+BAA+B;IAC/B,IAAA,6BAAQ,EAAC,OAAO,EAAE;QAChB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,WAAW;KACnB,CAAC,CAAC;AACL,CAAC,CAAC;AAnBW,QAAA,YAAY,gBAmBvB"}
1
+ {"version":3,"file":"executeSkill.js","sourceRoot":"","sources":["../../../src/domain.operations/invoke/executeSkill.ts"],"names":[],"mappings":";;;AAEA,2DAA8C;AAE9C;;;;;GAKG;AACI,MAAM,YAAY,GAAG,CAAC,KAG5B,EAAW,EAAE;IACZ,0BAA0B;IAC1B,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;SAC9C,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACX,yBAAyB;QACzB,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,GAAG,GAAG,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,6BAA6B;IAC7B,MAAM,MAAM,GAAG,IAAA,6BAAQ,EAAC,OAAO,EAAE;QAC/B,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,KAAK,EAAE,WAAW;QAClB,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC;IAEH,+BAA+B;IAC/B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9B,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAE/B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,sCAAsC;QACtC,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AA9BW,QAAA,YAAY,gBA8BvB"}
@@ -0,0 +1,14 @@
1
+ import type { BrainRepl } from '../../domain.objects';
2
+ import type { InvokeOpts } from '../../domain.objects/InvokeOpts';
3
+ /**
4
+ * .what = get brain repls from the invocation options declared
5
+ * .why = enables CLI commands to resolve brains from config
6
+ * .how =
7
+ * - lookup the config based on the options
8
+ * - grab the brain repls from the config
9
+ */
10
+ export declare const getBrainReplsByOpts: (input: {
11
+ opts: InvokeOpts<{
12
+ config: string;
13
+ }>;
14
+ }) => Promise<BrainRepl[]>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getBrainReplsByOpts = void 0;
27
+ /**
28
+ * .what = get brain repls from the invocation options declared
29
+ * .why = enables CLI commands to resolve brains from config
30
+ * .how =
31
+ * - lookup the config based on the options
32
+ * - grab the brain repls from the config
33
+ */
34
+ const getBrainReplsByOpts = async (input) => {
35
+ // import the config
36
+ const config = await Promise.resolve(`${input.opts.config}`).then(s => __importStar(require(s)));
37
+ // grab the brain repls if available
38
+ if (!config.getBrainRepls)
39
+ return [];
40
+ return await config.getBrainRepls();
41
+ };
42
+ exports.getBrainReplsByOpts = getBrainReplsByOpts;
43
+ //# sourceMappingURL=getBrainReplsByOpts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBrainReplsByOpts.js","sourceRoot":"","sources":["../../../src/domain.operations/invoke/getBrainReplsByOpts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;GAMG;AACI,MAAM,mBAAmB,GAAG,KAAK,EAAE,KAEzC,EAAwB,EAAE;IACzB,oBAAoB;IACpB,MAAM,MAAM,GAAmD,yBAC7D,KAAK,CAAC,IAAI,CAAC,MAAM,uCAClB,CAAC;IAEF,oCAAoC;IACpC,IAAI,CAAC,MAAM,CAAC,aAAa;QAAE,OAAO,EAAE,CAAC;IAErC,OAAO,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC;AACtC,CAAC,CAAC;AAZW,QAAA,mBAAmB,uBAY9B"}
@@ -0,0 +1,14 @@
1
+ import type { z } from 'zod';
2
+ /**
3
+ * .what = convert a zod schema to JSON schema for native SDK enforcement
4
+ * .why = enables native structured output support in SDKs, reducing
5
+ * token waste on validation retries
6
+ *
7
+ * .note = different SDKs require different conversion options:
8
+ * - claude-agent-sdk: { $refStrategy: 'root' }
9
+ * - codex-sdk: { target: 'openAi' }
10
+ */
11
+ export declare const castZodToJsonSchema: (input: {
12
+ schema: z.ZodSchema;
13
+ target: 'claude' | 'openai';
14
+ }) => object;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.castZodToJsonSchema = void 0;
4
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
5
+ /**
6
+ * .what = convert a zod schema to JSON schema for native SDK enforcement
7
+ * .why = enables native structured output support in SDKs, reducing
8
+ * token waste on validation retries
9
+ *
10
+ * .note = different SDKs require different conversion options:
11
+ * - claude-agent-sdk: { $refStrategy: 'root' }
12
+ * - codex-sdk: { target: 'openAi' }
13
+ */
14
+ const castZodToJsonSchema = (input) => {
15
+ // convert based on target SDK
16
+ if (input.target === 'claude') {
17
+ return (0, zod_to_json_schema_1.zodToJsonSchema)(input.schema, { $refStrategy: 'root' });
18
+ }
19
+ // openai target
20
+ return (0, zod_to_json_schema_1.zodToJsonSchema)(input.schema, { target: 'openAi' });
21
+ };
22
+ exports.castZodToJsonSchema = castZodToJsonSchema;
23
+ //# sourceMappingURL=castZodToJsonSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"castZodToJsonSchema.js","sourceRoot":"","sources":["../../../src/domain.operations/schema/castZodToJsonSchema.ts"],"names":[],"mappings":";;;AACA,2DAAqD;AAErD;;;;;;;;GAQG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAGnC,EAAU,EAAE;IACX,8BAA8B;IAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAA,oCAAe,EAAC,KAAK,CAAC,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,gBAAgB;IAChB,OAAO,IAAA,oCAAe,EAAC,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC;AAXW,QAAA,mBAAmB,uBAW9B"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "rhachet",
3
3
  "author": "ehmpathy",
4
4
  "description": "A framework for reliable, thorough thought. Weave threads of thought via stitches.",
5
- "version": "1.17.0",
5
+ "version": "1.19.0",
6
6
  "repository": "ehmpathy/rhachet",
7
7
  "homepage": "https://github.com/ehmpathy/rhachet",
8
8
  "keywords": [
@@ -54,6 +54,8 @@
54
54
  "prepare:rhachet": "rhachet init && rhachet roles link --repo ehmpathy --role mechanic && rhachet roles link --repo bhuild --role behaver && rhachet roles link --repo bhrain --role reviewer && rhachet roles init --role mechanic && rhachet roles init --role behaver"
55
55
  },
56
56
  "dependencies": {
57
+ "@anthropic-ai/claude-agent-sdk": "0.1.76",
58
+ "@anthropic-ai/sdk": "0.71.2",
57
59
  "@ehmpathy/uni-time": "1.9.0",
58
60
  "as-procedure": "1.1.6",
59
61
  "bottleneck": "2.19.5",
@@ -63,12 +65,15 @@
63
65
  "fast-glob": "3.3.3",
64
66
  "flattie": "1.1.1",
65
67
  "helpful-errors": "1.5.3",
68
+ "@openai/codex-sdk": "0.77.0",
66
69
  "openai": "5.8.2",
67
70
  "rhachet-artifact": "1.0.1",
68
71
  "rhachet-artifact-git": "1.1.3",
69
72
  "serde-fns": "1.3.1",
70
73
  "type-fns": "1.21.0",
71
- "uuid-fns": "1.0.1"
74
+ "uuid-fns": "1.0.1",
75
+ "zod": "3.25.76",
76
+ "zod-to-json-schema": "3.25.1"
72
77
  },
73
78
  "devDependencies": {
74
79
  "@biomejs/biome": "2.3.8",
package/readme.md CHANGED
@@ -3,31 +3,73 @@
3
3
  ![test](https://github.com/ehmpathy/rhachet/workflows/test/badge.svg)
4
4
  ![publish](https://github.com/ehmpathy/rhachet/workflows/publish/badge.svg)
5
5
 
6
- Build reusable roles with rhachet: a framework for reliable, composable, and iteratively improvable thought.
6
+ a framework for reliable, composable, and iteratively improvable thought.
7
7
 
8
- > Weave threads 🧵 of thought, stitched 🪡 with a rhachet ⚙️
8
+ > weave threads 🧵 of thought, stitched 🪡 with a rhachet ⚙️
9
9
 
10
- # vision
10
+ # purpose
11
11
 
12
- Build or use digital actors, who work even from your laptop, and work for anyone you choose.
12
+ rhachet makes it simple to leverage thought routes - safely, easily, and effectively.
13
13
 
14
- Distill your skills and roles iteratively, with rhachet. Use them, compose them, share them, open source them. The choice is yours.
14
+ - 🪨 **solid** routes for deterministic automation
15
+ - 🔩 **rigid** routes for augmented workflows
16
+ - 🌊 **fluid** routes for open-ended exploration
15
17
 
16
- - With open source top to bottom, we can raise the floor and prosper collectively.
17
- - With observable routes of thought, we can not only debug, but align.
18
- - With composable thought routes, we can build incremental complexity and automate test coverage just like any code.
18
+ with rhachet, you can:
19
+ - declare thought routes, reusably and maintainably
20
+ - apply thought routes, observably and reliably
21
+ - compose and accumulate reusable thought skill
22
+ - assure slipless progress towards goals, like a ratchet (🎼 click, click, click)
23
+ - enable iterative improvement of skills, like a ratchet (🎼 click, click, click)
19
24
 
20
- Here's to a solarpunk future of abundance 🌞🌴
25
+ # concepts
21
26
 
22
- # purpose
27
+ ## thought routes
28
+
29
+ thought routes describe the determinism profile of an execution path.
30
+
31
+ | route | what | when to use |
32
+ | ----------- | ------------------------------------------------ | ------------------------------------ |
33
+ | 🪨 **solid** | deterministic throughout | scripted automation, data transforms |
34
+ | 🔩 **rigid** | deterministic harness + probabilistic operations | augmented workflows, controlled ai |
35
+ | 🌊 **fluid** | probabilistic throughout | exploration, open-ended problems |
36
+
37
+ the key distinction:
38
+ - 🔩 **rigid**: you know when thought is needed, harness controls
39
+ - 🌊 **fluid**: you don't know when or what thought is needed, brain decides
40
+
41
+ ## brains
42
+
43
+ brains are probabilistic imagination mechanisms that provide creative thought capabilities:
44
+
45
+ | type | what | characteristics |
46
+ | ---- | ---- | --------------- |
47
+ | **brain.atom** | single inference | stateless, one-shot |
48
+ | **brain.repl** | read-eval-print-loop | stateful, multi-turn, tool use |
49
+
50
+ brain.atom is for single-turn operations. brain.repl is for multi-turn operations.
51
+
52
+ ## actors, roles, skills, briefs
53
+
54
+ rhachet organizes thought operators into a composable hierarchy:
55
+
56
+ ```
57
+ actor = brain + role
58
+ role = skills + briefs
59
+ ```
23
60
 
24
- 1. declare thought routes, reusably and maintainably
25
- 2. apply thought routes, observably and reliably
26
- 3. compose and accumulate reusable thought skill
27
- 4. assure slipless progress towards goals, like a ratchet (🎼 click, click, click)
28
- 5. enable iterative improvement of skills, like a ratchet (🎼 click, click, click)
29
- 6. assure guarded budgets of money and time, with route plans, expense approvals, and circuit breakers
30
- 7. observe thought routes and weaves intuitively
61
+ | concept | what | example |
62
+ | --------- | ---------------------------------- | --------------------------------------- |
63
+ | **actor** | a brain assuming a role | mechanic actor (claude + mechanic role) |
64
+ | **role** | a bundle of skills + briefs | mechanic, reviewer, architect |
65
+ | **skill** | an executable capability | review, deliver, init |
66
+ | **brief** | context and knowledge for the role | coding standards, domain patterns |
67
+
68
+ roles are portable - the same role can be assumed by different brains.
69
+
70
+ skills are composable - they can invoke other skills, nest thought routes, and build complexity incrementally.
71
+
72
+ briefs are cumulative - they encode institutional knowledge that improves over time.
31
73
 
32
74
  # install
33
75
 
@@ -37,43 +79,142 @@ npm install rhachet
37
79
 
38
80
  # use
39
81
 
82
+ ## cli
83
+
84
+ rhachet provides cli commands for each thought route:
40
85
 
41
- ## use a prebuilt roles registry
86
+ | command | route | what it does |
87
+ | ----------------- | ------- | ------------------------------------------ |
88
+ | `npx rhachet run` | 🪨 solid | execute a shell skill, no brain |
89
+ | `npx rhachet act` | 🔩 rigid | execute a skill with deterministic harness |
90
+ | `npx rhachet ask` | 🌊 fluid | converse with an actor, brain decides path |
42
91
 
43
- ### setup your config file
92
+ ### setup
44
93
 
45
- looks for `@gitroot/rhachet.use.ts` by default
94
+ rhachet looks for `@gitroot/rhachet.use.ts`:
46
95
 
47
96
  ```ts
48
- // @/rhachet.use.ts
97
+ // rhachet.use.ts
49
98
  import { getRoleRegistry as getBhrainRegistry } from 'rhachet-roles-bhrain';
50
99
  import { getRoleRegistry as getEhmpathyRegistry } from 'rhachet-roles-ehmpathy';
51
100
 
52
101
  export const getRoleRegistries = () => [
53
102
  getBhrainRegistry(),
54
103
  getEhmpathyRegistry(),
55
- // whichever other registries you'd like
56
- ]
104
+ ];
57
105
  ```
58
106
 
59
- ### perform a skill
107
+ ### 🪨 solid: run
60
108
 
61
109
  ```sh
62
- npx rhachet act \
63
- --repo bhrain --role skeptic --skill review \
64
- --ask "are birds real? or are they just government drones 🤔"
110
+ npx rhachet run --skill gh.workflow.logs --workflow test
65
111
  ```
66
112
 
113
+ deterministic execution, no brain involved.
114
+
115
+ ### 🔩 rigid: act
116
+
67
117
  ```sh
68
118
  npx rhachet act \
69
- --repo ehmpathy --role mechanic --skill review \
70
- --input "https://github.com/ehmpathy/simple-in-memory-cache/pull/9" \
71
- --ask "review this pr"
119
+ --role mechanic --skill review \
120
+ --input "https://github.com/org/repo/pull/9"
121
+
122
+ npx rhachet act \
123
+ --role mechanic --skill review \
124
+ --input "https://github.com/org/repo/pull/9" \
125
+ --brain openai/codex
72
126
  ```
73
127
 
128
+ deterministic harness controls flow, brain operations are wrapped and validated.
129
+
130
+ ### 🌊 fluid: ask
131
+
74
132
  ```sh
75
- npx rhachet act \
76
- --repo ehmpathy --role mechanic --skill deliver \
77
- --input "https://github.com/ehmpathy/domain-objects/issues/7" \
78
- --ask "push a pr to solve the issue"
133
+ npx rhachet ask \
134
+ --role skeptic \
135
+ --ask "are birds real?"
136
+ ```
137
+
138
+ brain decides the path, exploration is the goal.
139
+
140
+ ## sdk
141
+
142
+ rhachet provides a type-safe sdk for programmatic actor usage.
143
+
144
+ | method | route | what it does |
145
+ | -------------- | ------- | ------------------------------------------ |
146
+ | `actor.run()` | 🪨 solid | execute a shell skill, no brain |
147
+ | `actor.act()` | 🔩 rigid | execute a skill with deterministic harness |
148
+ | `actor.ask()` | 🌊 fluid | converse with an actor, brain decides path |
149
+
150
+ ### setup
151
+
152
+ generate an actor from a role with an allowlist of brains:
153
+
154
+ ```ts
155
+ import { genActor } from 'rhachet';
156
+ import { genBrainRepl } from 'rhachet-brains-openai';
157
+ import { mechanicRole } from './roles/mechanic';
158
+
159
+ export const mechanic = genActor({
160
+ role: mechanicRole,
161
+ brains: [
162
+ genBrainRepl({ slug: 'openai/codex' }), // default (first in list)
163
+ genBrainRepl({ slug: 'openai/codex/mini' }), // fast + cheap alternative
164
+ ],
165
+ });
79
166
  ```
167
+
168
+ the `brains` allowlist:
169
+ - defines which brains this actor supports
170
+ - first brain is the default (used when no explicit brain is provided)
171
+ - ensures only allowlisted brains can be used
172
+
173
+ ### 🪨 solid: run
174
+
175
+ ```ts
176
+ await mechanic.run({
177
+ skill: { 'gh.workflow.logs': { workflow: 'test' } },
178
+ });
179
+ ```
180
+
181
+ deterministic execution, no brain involved.
182
+
183
+ ### 🔩 rigid: act
184
+
185
+ ```ts
186
+ // uses default brain (first in allowlist)
187
+ await mechanic.act({
188
+ skill: { review: { input: 'https://github.com/org/repo/pull/9' } },
189
+ });
190
+
191
+ // uses explicit brain (must be in allowlist)
192
+ await mechanic.act({
193
+ brain: { repo: 'openai', slug: 'codex/mini' },
194
+ skill: { review: { input: 'https://github.com/org/repo/pull/9' } },
195
+ });
196
+ ```
197
+
198
+ deterministic harness controls flow, brain operations are wrapped and validated.
199
+
200
+ ### 🌊 fluid: ask
201
+
202
+ ```ts
203
+ await mechanic.ask({
204
+ prompt: 'are birds real?',
205
+ });
206
+ ```
207
+
208
+ brain decides the path, exploration is the goal.
209
+
210
+ # vision
211
+
212
+ build or use digital actors, who work even from your laptop, and work for anyone you choose.
213
+
214
+ distill your skills and roles iteratively, with rhachet. use them, compose them, share them, open source them. the choice is yours.
215
+
216
+ - with open source top to bottom, we can raise the floor and prosper collectively.
217
+ - with observable routes of thought, we can not only debug, but align.
218
+ - with composable thought routes, we can build incremental complexity and automate test coverage just like any code.
219
+
220
+ here's to a solarpunk future of abundance 🌞🌴