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,94 @@
1
+ import { DomainEntity } from 'domain-objects';
2
+ import type { z } from 'zod';
3
+ import type { BrainRepl } from './BrainRepl';
4
+ import type { Role, RoleSkillSchema } from './Role';
5
+ /**
6
+ * .what = extracts skill input type from a RoleSkillSchema
7
+ * .why = enables type inference for skill arguments
8
+ */
9
+ export type SkillInput<TSchema extends RoleSkillSchema> = z.infer<TSchema['input']>;
10
+ /**
11
+ * .what = extracts skill output type from a RoleSkillSchema
12
+ * .why = enables type inference for skill return values
13
+ */
14
+ export type SkillOutput<TSchema extends RoleSkillSchema> = z.infer<TSchema['output']>;
15
+ /**
16
+ * .what = type for actor.act() method
17
+ * .why = enables type-safe rigid skill invocation
18
+ */
19
+ export type ActorActOp<TRole extends Role> = <TSkillSlug extends keyof NonNullable<TRole['skills']['rigid']>>(input: {
20
+ brain?: {
21
+ repo: string;
22
+ slug: string;
23
+ } | BrainRepl;
24
+ skill: {
25
+ [K in TSkillSlug]: SkillInput<NonNullable<TRole['skills']['rigid']>[K]>;
26
+ };
27
+ }) => Promise<SkillOutput<NonNullable<TRole['skills']['rigid']>[TSkillSlug]>>;
28
+ /**
29
+ * .what = type for actor.run() method
30
+ * .why = enables type-safe solid skill invocation
31
+ */
32
+ export type ActorRunOp<TRole extends Role> = <TSkillSlug extends keyof NonNullable<TRole['skills']['solid']>>(input: {
33
+ skill: {
34
+ [K in TSkillSlug]: SkillInput<NonNullable<TRole['skills']['solid']>[K]>;
35
+ };
36
+ }) => Promise<SkillOutput<NonNullable<TRole['skills']['solid']>[TSkillSlug]>>;
37
+ /**
38
+ * .what = type for actor.ask() method
39
+ * .why = enables fluid conversation with brain
40
+ */
41
+ export type ActorAskOp = (input: {
42
+ prompt: string;
43
+ }) => Promise<{
44
+ response: string;
45
+ }>;
46
+ /**
47
+ * .what = a role assumed by a brain, ready for invocation
48
+ * .why =
49
+ * - enables sdk users to import and invoke actors directly
50
+ * - composes role (skills + briefs) with brain allowlist
51
+ * - provides type-safe .act(), .run(), .ask() methods
52
+ *
53
+ * .note = Actor = BrainRepl + Role composition
54
+ * - first brain in allowlist is the default
55
+ * - .act() invokes rigid skills (deterministic harness, brain operations)
56
+ * - .run() invokes solid skills (deterministic, no brain)
57
+ * - .ask() starts fluid conversation with default brain
58
+ */
59
+ export interface Actor<TRole extends Role = Role> {
60
+ /**
61
+ * .what = the role this actor assumes
62
+ */
63
+ role: TRole;
64
+ /**
65
+ * .what = the brains this actor is allowed to use
66
+ * .note = first brain is the default
67
+ */
68
+ brains: BrainRepl[];
69
+ /**
70
+ * .what = invokes a rigid skill with brain
71
+ * .why = deterministic harness with probabilistic brain operations
72
+ */
73
+ act: ActorActOp<TRole>;
74
+ /**
75
+ * .what = invokes a solid skill via spawn
76
+ * .why = deterministic shell execution, no brain
77
+ */
78
+ run: ActorRunOp<TRole>;
79
+ /**
80
+ * .what = starts a fluid conversation with the default brain
81
+ * .why = open-ended exploration, brain decides path
82
+ */
83
+ ask: ActorAskOp;
84
+ }
85
+ export declare class Actor<TRole extends Role = Role> extends DomainEntity<Actor<TRole>> implements Actor<TRole> {
86
+ static unique: readonly ["role.slug"];
87
+ /**
88
+ * .what = creates an Actor with preserved literal skill types from TRole
89
+ * .why = enables type-safe .act(), .run(), .ask() invocation
90
+ *
91
+ * .note = use Actor.typed() instead of raw object cast for proper type preservation
92
+ */
93
+ static typed<TRole extends Role>(input: Actor<TRole>): Actor<TRole>;
94
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Actor = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class Actor extends domain_objects_1.DomainEntity {
6
+ /**
7
+ * .what = creates an Actor with preserved literal skill types from TRole
8
+ * .why = enables type-safe .act(), .run(), .ask() invocation
9
+ *
10
+ * .note = use Actor.typed() instead of raw object cast for proper type preservation
11
+ */
12
+ static typed(input) {
13
+ return new Actor(input);
14
+ }
15
+ }
16
+ exports.Actor = Actor;
17
+ Actor.unique = ['role.slug'];
18
+ //# sourceMappingURL=Actor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Actor.js","sourceRoot":"","sources":["../../src/domain.objects/Actor.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAmG9C,MAAa,KACX,SAAQ,6BAA0B;IAKlC;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAqB,KAAmB;QACzD,OAAO,IAAI,KAAK,CAAQ,KAAK,CAAC,CAAC;IACjC,CAAC;;AAdH,sBAeC;AAXe,YAAM,GAAG,CAAC,WAAW,CAAU,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { DomainLiteral } from 'domain-objects';
2
+ import type { RoleSkillSchema } from './Role';
3
+ import type { RoleSkillExecutable } from './RoleSkillExecutable';
4
+ /**
5
+ * .what = a role skill that has been resolved and can be acted upon
6
+ * .why =
7
+ * - unified return type for skill resolution
8
+ * - explicit domain object for skill invocation
9
+ * - actors use this to invoke skills via .act() and .run()
10
+ *
11
+ * .note = executable is required; ActorRoleSkill is only constructable
12
+ * when a skill executable has been found
13
+ */
14
+ export interface ActorRoleSkill {
15
+ /**
16
+ * .what = the skill's slug identifier
17
+ */
18
+ slug: string;
19
+ /**
20
+ * .what = the thought route for this skill
21
+ * .note = solid = deterministic, rigid = brain-augmented
22
+ */
23
+ route: 'solid' | 'rigid';
24
+ /**
25
+ * .what = where this skill was resolved from
26
+ * .note = role.skills takes precedence over .agent/ discovery
27
+ */
28
+ source: 'role.skills' | '.agent/';
29
+ /**
30
+ * .what = the zod schema for input/output validation
31
+ * .note = required; skills must have schemas to be executable via actor contracts
32
+ */
33
+ schema: RoleSkillSchema;
34
+ /**
35
+ * .what = the executable file for this skill
36
+ * .note = required; skill cannot be acted upon without an executable
37
+ */
38
+ executable: RoleSkillExecutable;
39
+ }
40
+ export declare class ActorRoleSkill extends DomainLiteral<ActorRoleSkill> implements ActorRoleSkill {
41
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActorRoleSkill = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class ActorRoleSkill extends domain_objects_1.DomainLiteral {
6
+ }
7
+ exports.ActorRoleSkill = ActorRoleSkill;
8
+ //# sourceMappingURL=ActorRoleSkill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActorRoleSkill.js","sourceRoot":"","sources":["../../src/domain.objects/ActorRoleSkill.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AA6C/C,MAAa,cACX,SAAQ,8BAA6B;CACT;AAF9B,wCAE8B"}
@@ -0,0 +1,54 @@
1
+ import { DomainEntity } from 'domain-objects';
2
+ import type { Artifact } from 'rhachet-artifact';
3
+ import type { GitFile } from 'rhachet-artifact-git';
4
+ import type { Empty } from 'type-fns';
5
+ import type { z } from 'zod';
6
+ import type { BrainAtomPlugs } from './BrainAtomPlugs';
7
+ /**
8
+ * .what = an LLM inference endpoint capable of creative language imagination
9
+ * .why =
10
+ * - enables registration of pluggable LLM atoms (e.g., claude, gpt, llama)
11
+ * - provides a standardized contract for single-turn or multi-turn inference
12
+ * - enables dynamic swapping of models at runtime
13
+ */
14
+ export interface BrainAtom {
15
+ /**
16
+ * .what = identifier for the plugin package that provides this atom
17
+ * .example = "anthropic", "openai", "ollama"
18
+ */
19
+ repo: string;
20
+ /**
21
+ * .what = unique identifier for this specific atom within the repo
22
+ * .example = "claude-opus-4.5", "gpt-4o", "llama-3-70b"
23
+ */
24
+ slug: string;
25
+ /**
26
+ * .what = human-readable description of this atom's capabilities
27
+ * .why = helps developers understand what this atom is best suited for
28
+ */
29
+ description: string;
30
+ /**
31
+ * .what = the ask operation contract (renamed from imagine)
32
+ * .why = standardizes how all atoms are invoked, regardless of provider
33
+ *
34
+ * .note = plugin is responsible for handling role.briefs appropriately.
35
+ * this design maximizes leverage of each brain's unique capabilities:
36
+ * - context window optimization (e.g., claude's 200k vs gpt's 128k)
37
+ * - provider-specific caching (e.g., anthropic prompt caching)
38
+ * - finetuned behaviors (e.g., system prompt placement, formatting)
39
+ * - native JSON schema enforcement for structured outputs
40
+ */
41
+ ask: <TOutput>(input: {
42
+ plugs?: BrainAtomPlugs;
43
+ role: {
44
+ briefs?: Artifact<typeof GitFile>[];
45
+ };
46
+ prompt: string;
47
+ schema: {
48
+ output: z.Schema<TOutput>;
49
+ };
50
+ }, context?: Empty) => Promise<TOutput>;
51
+ }
52
+ export declare class BrainAtom extends DomainEntity<BrainAtom> implements BrainAtom {
53
+ static unique: readonly ["repo", "slug"];
54
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrainAtom = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class BrainAtom extends domain_objects_1.DomainEntity {
6
+ }
7
+ exports.BrainAtom = BrainAtom;
8
+ BrainAtom.unique = ['repo', 'slug'];
9
+ //# sourceMappingURL=BrainAtom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrainAtom.js","sourceRoot":"","sources":["../../src/domain.objects/BrainAtom.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAuD9C,MAAa,SAAU,SAAQ,6BAAuB;;AAAtD,8BAEC;AADe,gBAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { DomainLiteral } from 'domain-objects';
2
+ /**
3
+ * .what = configuration plugs for BrainAtom instances
4
+ * .why = enables extensible configuration for single-turn inference
5
+ * without coupling to specific SDK implementations
6
+ *
7
+ * .note = placeholder interface; actual configuration TBD
8
+ */
9
+ export interface BrainAtomPlugs {
10
+ /**
11
+ * .what = structured output configuration
12
+ * .why = enables native JSON schema enforcement for reduced token waste
13
+ */
14
+ output?: never;
15
+ }
16
+ export declare class BrainAtomPlugs extends DomainLiteral<BrainAtomPlugs> implements BrainAtomPlugs {
17
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrainAtomPlugs = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class BrainAtomPlugs extends domain_objects_1.DomainLiteral {
6
+ }
7
+ exports.BrainAtomPlugs = BrainAtomPlugs;
8
+ //# sourceMappingURL=BrainAtomPlugs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrainAtomPlugs.js","sourceRoot":"","sources":["../../src/domain.objects/BrainAtomPlugs.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAiB/C,MAAa,cACX,SAAQ,8BAA6B;CACT;AAF9B,wCAE8B"}
@@ -0,0 +1,74 @@
1
+ import { DomainEntity } from 'domain-objects';
2
+ import type { Artifact } from 'rhachet-artifact';
3
+ import type { GitFile } from 'rhachet-artifact-git';
4
+ import type { Empty } from 'type-fns';
5
+ import type { z } from 'zod';
6
+ import type { BrainReplPlugs } from './BrainReplPlugs';
7
+ /**
8
+ * .what = a brain.atom operating behind a REPL (read-execute-print-loop)
9
+ * .why =
10
+ * - enables registration of pluggable agentic repls (e.g., claude-code, codex)
11
+ * - provides a standardized contract for agentic tool-using inference
12
+ * - enables dynamic swapping of agentic systems at runtime
13
+ *
14
+ * .note = repls differ from atoms in that they execute iterative agentic loops
15
+ * with tool use, rather than single-turn inference
16
+ */
17
+ export interface BrainRepl {
18
+ /**
19
+ * .what = identifier for the plugin package that provides this repl
20
+ * .example = "anthropic", "openai"
21
+ */
22
+ repo: string;
23
+ /**
24
+ * .what = unique identifier for this specific repl within the repo
25
+ * .example = "claude-code", "codex"
26
+ */
27
+ slug: string;
28
+ /**
29
+ * .what = human-readable description of this repl's capabilities
30
+ * .why = helps developers understand what this repl is best suited for
31
+ */
32
+ description: string;
33
+ /**
34
+ * .what = readonly analysis operation (research, queries, code review)
35
+ * .why = provides safe, non-mutating agent interactions
36
+ * with only read access to filesystem and tools
37
+ *
38
+ * .sdk.mapping =
39
+ * - claude-agent-sdk: disallowedTools=["Edit","Write","Bash","NotebookEdit"]
40
+ * - codex-sdk: --sandbox read-only
41
+ */
42
+ ask: <TOutput>(input: {
43
+ plugs?: BrainReplPlugs;
44
+ role: {
45
+ briefs?: Artifact<typeof GitFile>[];
46
+ };
47
+ prompt: string;
48
+ schema: {
49
+ output: z.Schema<TOutput>;
50
+ };
51
+ }, context?: Empty) => Promise<TOutput>;
52
+ /**
53
+ * .what = read+write action operation (code changes, file edits)
54
+ * .why = provides full agentic capabilities with write access
55
+ * for tasks that require modifying the codebase
56
+ *
57
+ * .sdk.mapping =
58
+ * - claude-agent-sdk: allowedTools=["Read","Edit","Write","Bash","Glob","Grep"]
59
+ * - codex-sdk: --sandbox workspace-write
60
+ */
61
+ act: <TOutput>(input: {
62
+ plugs?: BrainReplPlugs;
63
+ role: {
64
+ briefs?: Artifact<typeof GitFile>[];
65
+ };
66
+ prompt: string;
67
+ schema: {
68
+ output: z.Schema<TOutput>;
69
+ };
70
+ }, context?: Empty) => Promise<TOutput>;
71
+ }
72
+ export declare class BrainRepl extends DomainEntity<BrainRepl> implements BrainRepl {
73
+ static unique: readonly ["repo", "slug"];
74
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrainRepl = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class BrainRepl extends domain_objects_1.DomainEntity {
6
+ }
7
+ exports.BrainRepl = BrainRepl;
8
+ BrainRepl.unique = ['repo', 'slug'];
9
+ //# sourceMappingURL=BrainRepl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrainRepl.js","sourceRoot":"","sources":["../../src/domain.objects/BrainRepl.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AA2E9C,MAAa,SAAU,SAAQ,6BAAuB;;AAAtD,8BAEC;AADe,gBAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { DomainLiteral } from 'domain-objects';
2
+ /**
3
+ * .what = configuration plugs for BrainRepl instances
4
+ * .why = enables extensible tooling, memory management, and access control
5
+ * for agentic workloads without coupling to specific SDK implementations
6
+ */
7
+ export interface BrainReplPlugs {
8
+ /**
9
+ * .what = additional tool providers beyond built-in tools
10
+ * .why = enables domain-specific tooling (databases, browsers, APIs)
11
+ * via MCP servers or custom tool definitions
12
+ *
13
+ * .example = playwright browser, postgres database, custom APIs
14
+ */
15
+ toolboxes?: never;
16
+ /**
17
+ * .what = memory and context management strategy
18
+ * .why = enables custom context compression, session persistence,
19
+ * and artifact management for long-running workflows
20
+ *
21
+ * .example = session resume, context compaction hooks
22
+ */
23
+ memory?: never;
24
+ /**
25
+ * .what = permission guard and access control
26
+ * .why = enables custom authorization logic, audit logging,
27
+ * and tool-level access policies beyond SDK defaults
28
+ *
29
+ * .example = canUseTool callbacks, preToolUse hooks
30
+ */
31
+ access?: never;
32
+ }
33
+ export declare class BrainReplPlugs extends DomainLiteral<BrainReplPlugs> implements BrainReplPlugs {
34
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrainReplPlugs = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class BrainReplPlugs extends domain_objects_1.DomainLiteral {
6
+ }
7
+ exports.BrainReplPlugs = BrainReplPlugs;
8
+ //# sourceMappingURL=BrainReplPlugs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrainReplPlugs.js","sourceRoot":"","sources":["../../src/domain.objects/BrainReplPlugs.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAsC/C,MAAa,cACX,SAAQ,8BAA6B;CACT;AAF9B,wCAE8B"}
@@ -0,0 +1,73 @@
1
+ import { DomainLiteral, type RefByUnique } from 'domain-objects';
2
+ import type { Artifact } from 'rhachet-artifact';
3
+ import type { GitFile } from 'rhachet-artifact-git';
4
+ import type { z } from 'zod';
5
+ import type { BrainAtom } from './BrainAtom';
6
+ import type { BrainAtomPlugs } from './BrainAtomPlugs';
7
+ import type { BrainRepl } from './BrainRepl';
8
+ import type { BrainReplPlugs } from './BrainReplPlugs';
9
+ /**
10
+ * .what = runtime context providing unified access to brain atoms and repls
11
+ * .why =
12
+ * - provides a clean interface for invoking brains by reference
13
+ * - handles lookup, role embedding, and delegation transparently
14
+ * - enables dynamic brain swapping without caller changes
15
+ */
16
+ export interface ContextBrain {
17
+ /**
18
+ * .what = interface for invoking brain atoms and repls
19
+ */
20
+ brain: {
21
+ atom: {
22
+ /**
23
+ * .what = lookup and invoke a brain atom for single-turn inference
24
+ * .why = provides ergonomic access to atoms with automatic lookup
25
+ */
26
+ ask: <TOutput>(input: {
27
+ brain: RefByUnique<typeof BrainAtom>;
28
+ plugs?: BrainAtomPlugs;
29
+ role: {
30
+ briefs?: Artifact<typeof GitFile>[];
31
+ };
32
+ prompt: string;
33
+ schema: {
34
+ output: z.Schema<TOutput>;
35
+ };
36
+ }) => Promise<TOutput>;
37
+ };
38
+ repl: {
39
+ /**
40
+ * .what = lookup and invoke a brain repl for readonly analysis
41
+ * .why = provides safe agentic analysis without file modifications
42
+ */
43
+ ask: <TOutput>(input: {
44
+ brain: RefByUnique<typeof BrainRepl>;
45
+ plugs?: BrainReplPlugs;
46
+ role: {
47
+ briefs?: Artifact<typeof GitFile>[];
48
+ };
49
+ prompt: string;
50
+ schema: {
51
+ output: z.Schema<TOutput>;
52
+ };
53
+ }) => Promise<TOutput>;
54
+ /**
55
+ * .what = lookup and invoke a brain repl for read+write actions
56
+ * .why = provides full agentic capabilities with file modifications
57
+ */
58
+ act: <TOutput>(input: {
59
+ brain: RefByUnique<typeof BrainRepl>;
60
+ plugs?: BrainReplPlugs;
61
+ role: {
62
+ briefs?: Artifact<typeof GitFile>[];
63
+ };
64
+ prompt: string;
65
+ schema: {
66
+ output: z.Schema<TOutput>;
67
+ };
68
+ }) => Promise<TOutput>;
69
+ };
70
+ };
71
+ }
72
+ export declare class ContextBrain extends DomainLiteral<ContextBrain> implements ContextBrain {
73
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContextBrain = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class ContextBrain extends domain_objects_1.DomainLiteral {
6
+ }
7
+ exports.ContextBrain = ContextBrain;
8
+ //# sourceMappingURL=ContextBrain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextBrain.js","sourceRoot":"","sources":["../../src/domain.objects/ContextBrain.ts"],"names":[],"mappings":";;;AAAA,mDAAiE;AA+DjE,MAAa,YACX,SAAQ,8BAA2B;CACT;AAF5B,oCAE4B"}
@@ -1,5 +1,31 @@
1
+ import type { z } from 'zod';
1
2
  import type { InvokeOpts } from '.';
2
- export interface InvokeHooks {
3
+ import type { Role, RoleSkillRegistry } from './Role';
4
+ /**
5
+ * .what = extracts input type for a single skill from a skill registry
6
+ * .why = enables type inference for skill inputs in hooks
7
+ */
8
+ type SkillInputFromRegistry<TRegistry extends RoleSkillRegistry, TSkill extends keyof TRegistry> = z.infer<TRegistry[TSkill]['input']>;
9
+ /**
10
+ * .what = union type of all skill inputs from a registry
11
+ * .why = enables onInvokeActInput to accept any valid skill input
12
+ */
13
+ type AnySkillInputFromRegistry<TRegistry extends RoleSkillRegistry> = {
14
+ [K in keyof TRegistry]: {
15
+ skill: K;
16
+ input: SkillInputFromRegistry<TRegistry, K>;
17
+ };
18
+ }[keyof TRegistry];
19
+ /**
20
+ * .what = hooks for customizing invoke behavior
21
+ * .why = enables input transformation before skill execution
22
+ *
23
+ * .note = generic TRole enables type-safe onInvokeActInput when Role.typed() is used
24
+ */
25
+ export interface InvokeHooks<TRole extends Role = Role> {
26
+ /**
27
+ * .what = transforms ask input before execution
28
+ */
3
29
  onInvokeAskInput: Array<(input: InvokeOpts<{
4
30
  ask: string;
5
31
  config: string;
@@ -7,4 +33,15 @@ export interface InvokeHooks {
7
33
  ask: string;
8
34
  config: string;
9
35
  }>>;
36
+ /**
37
+ * .what = transforms act input before skill execution
38
+ * .why = enables input manipulation (e.g., adding defaults, validation)
39
+ *
40
+ * .note = strongly typed when TRole preserves literal skill names via Role.typed()
41
+ */
42
+ onInvokeActInput?: TRole['skills']['rigid'] extends RoleSkillRegistry ? (input: AnySkillInputFromRegistry<NonNullable<TRole['skills']['rigid']>>) => AnySkillInputFromRegistry<NonNullable<TRole['skills']['rigid']>>['input'] : (input: {
43
+ skill: string;
44
+ input: Record<string, unknown>;
45
+ }) => Record<string, unknown>;
10
46
  }
47
+ export {};
@@ -1,13 +1,33 @@
1
1
  import { DomainEntity } from 'domain-objects';
2
+ import type { z } from 'zod';
2
3
  import type { RoleSkill } from './RoleSkill';
3
4
  import type { RoleTrait } from './RoleTrait';
5
+ /**
6
+ * .what = type definition for a skill's schema (input/output zod schemas)
7
+ * .why = enables type-safe skill invocation via .act() and .run()
8
+ */
9
+ export interface RoleSkillSchema {
10
+ input: z.ZodSchema;
11
+ output: z.ZodSchema;
12
+ }
13
+ /**
14
+ * .what = type for a record of skills with literal keys preserved
15
+ * .why = enables type inference of skill names via keyof
16
+ */
17
+ export type RoleSkillRegistry = {
18
+ readonly [slug: string]: RoleSkillSchema;
19
+ };
4
20
  /**
5
21
  * .what = defines a role that can have traits, know skills, and be instantiated across thread.context
6
22
  * .why =
7
23
  * - enables registration of usable roles (e.g., 'mechanic', 'designer', 'architect', 'ecologist')
8
24
  * - enables instantiation of thread.contexts
25
+ *
26
+ * .note = generic type parameters preserve literal skill names for type-safe invocation
27
+ * - TSolid: the solid skills record type (e.g., { 'wordcount': { input, output } })
28
+ * - TRigid: the rigid skills record type (e.g., { 'review': { input, output } })
9
29
  */
10
- export interface Role {
30
+ export interface Role<TSolid extends RoleSkillRegistry = RoleSkillRegistry, TRigid extends RoleSkillRegistry = RoleSkillRegistry> {
11
31
  /**
12
32
  * .what = a unique, readable identifier
13
33
  * .example = "mechanic"
@@ -40,12 +60,26 @@ export interface Role {
40
60
  * .what = the skills known by the role
41
61
  * .why = declares what the role can do
42
62
  * .how =
63
+ * - solid: typed skills for deterministic execution (no brain)
64
+ * - enables type-safe .run() invocation
65
+ * - rigid: typed skills for deterministic harness with brain operations
66
+ * - enables type-safe .act() invocation
43
67
  * - dirs: directory-based skills (e.g., .sh scripts) for linking/booting
44
68
  * - single { uri: string }: symlinks this dir as the full skills dir
45
69
  * - array { uri: string }[]: symlinks each dir within the skills dir
46
70
  * - refs: programmatic RoleSkill references for execution
47
71
  */
48
72
  skills: {
73
+ /**
74
+ * .what = solid skills (deterministic, no brain)
75
+ * .why = type-safe .run() invocation
76
+ */
77
+ solid?: TSolid;
78
+ /**
79
+ * .what = rigid skills (deterministic harness, brain operations)
80
+ * .why = type-safe .act() invocation
81
+ */
82
+ rigid?: TRigid;
49
83
  dirs: {
50
84
  uri: string;
51
85
  } | {
@@ -89,6 +123,13 @@ export interface Role {
89
123
  }[];
90
124
  };
91
125
  }
92
- export declare class Role extends DomainEntity<Role> implements Role {
126
+ export declare class Role<TSolid extends RoleSkillRegistry = RoleSkillRegistry, TRigid extends RoleSkillRegistry = RoleSkillRegistry> extends DomainEntity<Role<TSolid, TRigid>> implements Role<TSolid, TRigid> {
93
127
  static unique: readonly ["slug"];
128
+ /**
129
+ * .what = creates a Role with preserved literal skill names
130
+ * .why = enables type-safe skill invocation via genActor
131
+ *
132
+ * .note = use Role.typed() instead of new Role() to preserve literal types
133
+ */
134
+ static typed<TSolid extends RoleSkillRegistry, TRigid extends RoleSkillRegistry>(input: Role<TSolid, TRigid>): Role<TSolid, TRigid>;
94
135
  }
@@ -3,6 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Role = void 0;
4
4
  const domain_objects_1 = require("domain-objects");
5
5
  class Role extends domain_objects_1.DomainEntity {
6
+ /**
7
+ * .what = creates a Role with preserved literal skill names
8
+ * .why = enables type-safe skill invocation via genActor
9
+ *
10
+ * .note = use Role.typed() instead of new Role() to preserve literal types
11
+ */
12
+ static typed(input) {
13
+ return new Role(input);
14
+ }
6
15
  }
7
16
  exports.Role = Role;
8
17
  Role.unique = ['slug'];
@@ -1 +1 @@
1
- {"version":3,"file":"Role.js","sourceRoot":"","sources":["../../src/domain.objects/Role.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAoF9C,MAAa,IAAK,SAAQ,6BAAkB;;AAA5C,oBAEC;AADe,WAAM,GAAG,CAAC,MAAM,CAAU,CAAC"}
1
+ {"version":3,"file":"Role.js","sourceRoot":"","sources":["../../src/domain.objects/Role.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AA2H9C,MAAa,IAIX,SAAQ,6BAAkC;IAK1C;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAGjB,KAA2B;QAC3B,OAAO,IAAI,IAAI,CAAiB,KAAK,CAAC,CAAC;IACzC,CAAC;;AApBH,oBAqBC;AAde,WAAM,GAAG,CAAC,MAAM,CAAU,CAAC"}
@@ -9,6 +9,11 @@ export * from './StitchStep';
9
9
  export * from './StitchTrail';
10
10
  export * from './Thread';
11
11
  export * from './Threads';
12
+ export * from './Actor';
13
+ export * from './ActorRoleSkill';
14
+ export * from './BrainAtom';
15
+ export * from './BrainRepl';
16
+ export * from './ContextBrain';
12
17
  export * from './InvokeHooks';
13
18
  export * from './InvokeOpts';
14
19
  export * from './Role';