rhachet-brains-anthropic 0.0.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.
- package/LICENSE +21 -0
- package/dist/contract/sdk/index.d.ts +13 -0
- package/dist/contract/sdk/index.js +36 -0
- package/dist/contract/sdk/index.js.map +1 -0
- package/dist/domain.operations/atoms/genBrainAtom.d.ts +19 -0
- package/dist/domain.operations/atoms/genBrainAtom.js +97 -0
- package/dist/domain.operations/atoms/genBrainAtom.js.map +1 -0
- package/dist/domain.operations/repls/genBrainRepl.d.ts +19 -0
- package/dist/domain.operations/repls/genBrainRepl.js +133 -0
- package/dist/domain.operations/repls/genBrainRepl.js.map +1 -0
- package/dist/infra/schema/asJsonSchema.d.ts +8 -0
- package/dist/infra/schema/asJsonSchema.js +17 -0
- package/dist/infra/schema/asJsonSchema.js.map +1 -0
- package/license.md +21 -0
- package/package.json +104 -0
- package/readme.md +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Uladzimir Kasacheuski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BrainAtom, BrainRepl } from 'rhachet';
|
|
2
|
+
/**
|
|
3
|
+
* .what = returns all brain atoms provided by anthropic
|
|
4
|
+
* .why = enables consumers to register anthropic atoms with genContextBrain
|
|
5
|
+
*/
|
|
6
|
+
export declare const getBrainAtomsByAnthropic: () => BrainAtom[];
|
|
7
|
+
/**
|
|
8
|
+
* .what = returns all brain repls provided by anthropic
|
|
9
|
+
* .why = enables consumers to register anthropic repls with genContextBrain
|
|
10
|
+
*/
|
|
11
|
+
export declare const getBrainReplsByAnthropic: () => BrainRepl[];
|
|
12
|
+
export { genBrainAtom } from '../../domain.operations/atoms/genBrainAtom';
|
|
13
|
+
export { genBrainRepl } from '../../domain.operations/repls/genBrainRepl';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.genBrainRepl = exports.genBrainAtom = exports.getBrainReplsByAnthropic = exports.getBrainAtomsByAnthropic = void 0;
|
|
4
|
+
const genBrainAtom_1 = require("../../domain.operations/atoms/genBrainAtom");
|
|
5
|
+
const genBrainRepl_1 = require("../../domain.operations/repls/genBrainRepl");
|
|
6
|
+
/**
|
|
7
|
+
* .what = returns all brain atoms provided by anthropic
|
|
8
|
+
* .why = enables consumers to register anthropic atoms with genContextBrain
|
|
9
|
+
*/
|
|
10
|
+
const getBrainAtomsByAnthropic = () => {
|
|
11
|
+
return [
|
|
12
|
+
(0, genBrainAtom_1.genBrainAtom)({ slug: 'claude/haiku' }),
|
|
13
|
+
(0, genBrainAtom_1.genBrainAtom)({ slug: 'claude/sonnet' }),
|
|
14
|
+
(0, genBrainAtom_1.genBrainAtom)({ slug: 'claude/opus' }),
|
|
15
|
+
];
|
|
16
|
+
};
|
|
17
|
+
exports.getBrainAtomsByAnthropic = getBrainAtomsByAnthropic;
|
|
18
|
+
/**
|
|
19
|
+
* .what = returns all brain repls provided by anthropic
|
|
20
|
+
* .why = enables consumers to register anthropic repls with genContextBrain
|
|
21
|
+
*/
|
|
22
|
+
const getBrainReplsByAnthropic = () => {
|
|
23
|
+
return [
|
|
24
|
+
(0, genBrainRepl_1.genBrainRepl)({ slug: 'claude/code' }),
|
|
25
|
+
(0, genBrainRepl_1.genBrainRepl)({ slug: 'claude/code/haiku' }),
|
|
26
|
+
(0, genBrainRepl_1.genBrainRepl)({ slug: 'claude/code/sonnet' }),
|
|
27
|
+
(0, genBrainRepl_1.genBrainRepl)({ slug: 'claude/code/opus' }),
|
|
28
|
+
];
|
|
29
|
+
};
|
|
30
|
+
exports.getBrainReplsByAnthropic = getBrainReplsByAnthropic;
|
|
31
|
+
// re-export factories for direct access
|
|
32
|
+
var genBrainAtom_2 = require("../../domain.operations/atoms/genBrainAtom");
|
|
33
|
+
Object.defineProperty(exports, "genBrainAtom", { enumerable: true, get: function () { return genBrainAtom_2.genBrainAtom; } });
|
|
34
|
+
var genBrainRepl_2 = require("../../domain.operations/repls/genBrainRepl");
|
|
35
|
+
Object.defineProperty(exports, "genBrainRepl", { enumerable: true, get: function () { return genBrainRepl_2.genBrainRepl; } });
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/sdk/index.ts"],"names":[],"mappings":";;;AAEA,6EAA0E;AAC1E,6EAA0E;AAE1E;;;GAGG;AACI,MAAM,wBAAwB,GAAG,GAAgB,EAAE;IACxD,OAAO;QACL,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;QACtC,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;QACvC,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;KACtC,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,wBAAwB,4BAMnC;AAEF;;;GAGG;AACI,MAAM,wBAAwB,GAAG,GAAgB,EAAE;IACxD,OAAO;QACL,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;QACrC,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC;QAC3C,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC;QAC5C,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;KAC3C,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,wBAAwB,4BAOnC;AAEF,wCAAwC;AACxC,2EAA0E;AAAjE,4GAAA,YAAY,OAAA;AACrB,2EAA0E;AAAjE,4GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BrainAtom } from 'rhachet';
|
|
2
|
+
/**
|
|
3
|
+
* .what = supported claude atom slugs
|
|
4
|
+
* .why = enables type-safe slug specification with model variants
|
|
5
|
+
*/
|
|
6
|
+
type ClaudeAtomSlug = 'claude/haiku' | 'claude/haiku/v3.5' | 'claude/haiku/v4.5' | 'claude/sonnet' | 'claude/sonnet/v4' | 'claude/sonnet/v4.5' | 'claude/opus' | 'claude/opus/v4' | 'claude/opus/v4.5';
|
|
7
|
+
/**
|
|
8
|
+
* .what = factory to generate claude brain atom instances
|
|
9
|
+
* .why = enables model variant selection via slug (e.g., haiku for speed, opus for quality)
|
|
10
|
+
*
|
|
11
|
+
* .example
|
|
12
|
+
* genBrainAtom({ slug: 'claude/haiku' }) // fast + cheap
|
|
13
|
+
* genBrainAtom({ slug: 'claude/sonnet' }) // balanced
|
|
14
|
+
* genBrainAtom({ slug: 'claude/opus/v4.5' }) // highest quality
|
|
15
|
+
*/
|
|
16
|
+
export declare const genBrainAtom: (input: {
|
|
17
|
+
slug: ClaudeAtomSlug;
|
|
18
|
+
}) => BrainAtom;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.genBrainAtom = void 0;
|
|
7
|
+
const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
|
|
8
|
+
const zod_1 = require("@anthropic-ai/sdk/helpers/beta/zod");
|
|
9
|
+
const rhachet_1 = require("rhachet");
|
|
10
|
+
/**
|
|
11
|
+
* .what = model configuration by slug
|
|
12
|
+
* .why = maps slugs to API model names and descriptions
|
|
13
|
+
*/
|
|
14
|
+
const CONFIG_BY_SLUG = {
|
|
15
|
+
'claude/haiku': {
|
|
16
|
+
model: 'claude-haiku-4-5-20251001',
|
|
17
|
+
description: 'claude haiku 4.5 - fastest and most cost-effective',
|
|
18
|
+
},
|
|
19
|
+
'claude/haiku/v3.5': {
|
|
20
|
+
model: 'claude-3-5-haiku-20241022',
|
|
21
|
+
description: 'claude haiku 3.5 - fast and cost-effective',
|
|
22
|
+
},
|
|
23
|
+
'claude/haiku/v4.5': {
|
|
24
|
+
model: 'claude-haiku-4-5-20251001',
|
|
25
|
+
description: 'claude haiku 4.5 - fastest and most cost-effective',
|
|
26
|
+
},
|
|
27
|
+
'claude/sonnet': {
|
|
28
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
29
|
+
description: 'claude sonnet 4.5 - balanced performance and capability',
|
|
30
|
+
},
|
|
31
|
+
'claude/sonnet/v4': {
|
|
32
|
+
model: 'claude-sonnet-4-20250514',
|
|
33
|
+
description: 'claude sonnet 4 - balanced performance and capability',
|
|
34
|
+
},
|
|
35
|
+
'claude/sonnet/v4.5': {
|
|
36
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
37
|
+
description: 'claude sonnet 4.5 - balanced performance and capability',
|
|
38
|
+
},
|
|
39
|
+
'claude/opus': {
|
|
40
|
+
model: 'claude-opus-4-5-20251101',
|
|
41
|
+
description: 'claude opus 4.5 - most capable for complex reasoning',
|
|
42
|
+
},
|
|
43
|
+
'claude/opus/v4': {
|
|
44
|
+
model: 'claude-opus-4-20250514',
|
|
45
|
+
description: 'claude opus 4 - highly capable for complex reasoning',
|
|
46
|
+
},
|
|
47
|
+
'claude/opus/v4.5': {
|
|
48
|
+
model: 'claude-opus-4-5-20251101',
|
|
49
|
+
description: 'claude opus 4.5 - most capable for complex reasoning',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* .what = factory to generate claude brain atom instances
|
|
54
|
+
* .why = enables model variant selection via slug (e.g., haiku for speed, opus for quality)
|
|
55
|
+
*
|
|
56
|
+
* .example
|
|
57
|
+
* genBrainAtom({ slug: 'claude/haiku' }) // fast + cheap
|
|
58
|
+
* genBrainAtom({ slug: 'claude/sonnet' }) // balanced
|
|
59
|
+
* genBrainAtom({ slug: 'claude/opus/v4.5' }) // highest quality
|
|
60
|
+
*/
|
|
61
|
+
const genBrainAtom = (input) => {
|
|
62
|
+
const config = CONFIG_BY_SLUG[input.slug];
|
|
63
|
+
return new rhachet_1.BrainAtom({
|
|
64
|
+
repo: 'anthropic',
|
|
65
|
+
slug: input.slug,
|
|
66
|
+
description: config.description,
|
|
67
|
+
/**
|
|
68
|
+
* .what = stateless inference (no tool use)
|
|
69
|
+
* .why = provides direct model access for reasoning tasks
|
|
70
|
+
*/
|
|
71
|
+
ask: async (askInput, context) => {
|
|
72
|
+
// compose system prompt from briefs
|
|
73
|
+
const systemPrompt = askInput.role.briefs
|
|
74
|
+
? await (0, rhachet_1.castBriefsToPrompt)({ briefs: askInput.role.briefs })
|
|
75
|
+
: undefined;
|
|
76
|
+
// get anthropic client from context or create new one
|
|
77
|
+
const anthropic = context?.anthropic ??
|
|
78
|
+
new sdk_1.default({ apiKey: process.env.ANTHROPIC_API_KEY });
|
|
79
|
+
// call anthropic api with native structured output (constrained decoding)
|
|
80
|
+
const response = await anthropic.beta.messages.create({
|
|
81
|
+
model: config.model,
|
|
82
|
+
max_tokens: 16384,
|
|
83
|
+
betas: ['structured-outputs-2025-11-13'],
|
|
84
|
+
system: systemPrompt,
|
|
85
|
+
messages: [{ role: 'user', content: askInput.prompt }],
|
|
86
|
+
output_format: (0, zod_1.betaZodOutputFormat)(askInput.schema.output),
|
|
87
|
+
});
|
|
88
|
+
// extract structured output from response text
|
|
89
|
+
const textBlock = response.content.find((block) => block.type === 'text');
|
|
90
|
+
const output = textBlock?.text ? JSON.parse(textBlock.text) : {};
|
|
91
|
+
// validate via schema
|
|
92
|
+
return askInput.schema.output.parse(output);
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
exports.genBrainAtom = genBrainAtom;
|
|
97
|
+
//# sourceMappingURL=genBrainAtom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genBrainAtom.js","sourceRoot":"","sources":["../../../src/domain.operations/atoms/genBrainAtom.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA0C;AAC1C,4DAAyE;AACzE,qCAAwD;AAqBxD;;;GAGG;AACH,MAAM,cAAc,GAGhB;IACF,cAAc,EAAE;QACd,KAAK,EAAE,2BAA2B;QAClC,WAAW,EAAE,oDAAoD;KAClE;IACD,mBAAmB,EAAE;QACnB,KAAK,EAAE,2BAA2B;QAClC,WAAW,EAAE,4CAA4C;KAC1D;IACD,mBAAmB,EAAE;QACnB,KAAK,EAAE,2BAA2B;QAClC,WAAW,EAAE,oDAAoD;KAClE;IACD,eAAe,EAAE;QACf,KAAK,EAAE,4BAA4B;QACnC,WAA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AE,MAAM,CAAC,KAAK;gBACnB,UAAU,EAAE,KAAK;gBACjB,KAAK,EAAE,CAAC,+BAA+B,CAAC;gBACxC,MAAM,EAAE,YAAY;gBACpB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;gBACtD,aAAa,EAAE,IAAA,yBAAmB,EAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;aAC3D,CAAC,CAAC;YAEH,+CAA+C;YAC/C,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CACrC,CAAC,KAAK,EAAgC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAC/D,CAAC;YACF,MAAM,MAAM,GAAG,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAEjE,sBAAsB;YACtB,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAlDW,QAAA,YAAY,gBAkDvB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BrainRepl } from 'rhachet';
|
|
2
|
+
/**
|
|
3
|
+
* .what = supported claude code repl slugs
|
|
4
|
+
* .why = enables type-safe slug specification with model variants
|
|
5
|
+
*/
|
|
6
|
+
type ClaudeCodeSlug = 'claude/code' | 'claude/code/haiku' | 'claude/code/haiku/v4.5' | 'claude/code/sonnet' | 'claude/code/sonnet/v4' | 'claude/code/sonnet/v4.5' | 'claude/code/opus' | 'claude/code/opus/v4.5';
|
|
7
|
+
/**
|
|
8
|
+
* .what = factory to generate claude code brain repl instances
|
|
9
|
+
* .why = enables model variant selection via slug (e.g., haiku for speed, opus for quality)
|
|
10
|
+
*
|
|
11
|
+
* .example
|
|
12
|
+
* genBrainRepl({ slug: 'claude/code' }) // default model
|
|
13
|
+
* genBrainRepl({ slug: 'claude/code/haiku' }) // fast + cheap
|
|
14
|
+
* genBrainRepl({ slug: 'claude/code/opus/v4.5' }) // highest quality
|
|
15
|
+
*/
|
|
16
|
+
export declare const genBrainRepl: (input: {
|
|
17
|
+
slug: ClaudeCodeSlug;
|
|
18
|
+
}) => BrainRepl;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.genBrainRepl = void 0;
|
|
4
|
+
const claude_agent_sdk_1 = require("@anthropic-ai/claude-agent-sdk");
|
|
5
|
+
const rhachet_1 = require("rhachet");
|
|
6
|
+
const asJsonSchema_1 = require("../../infra/schema/asJsonSchema");
|
|
7
|
+
/**
|
|
8
|
+
* .what = maps slug to anthropic model identifier
|
|
9
|
+
* .why = translates friendly slugs to API model names
|
|
10
|
+
*/
|
|
11
|
+
const MODEL_BY_SLUG = {
|
|
12
|
+
'claude/code': undefined, // use SDK default
|
|
13
|
+
'claude/code/haiku': 'claude-haiku-4-5-20251001',
|
|
14
|
+
'claude/code/haiku/v4.5': 'claude-haiku-4-5-20251001',
|
|
15
|
+
'claude/code/sonnet': 'claude-sonnet-4-5-20250929',
|
|
16
|
+
'claude/code/sonnet/v4': 'claude-sonnet-4-20250514',
|
|
17
|
+
'claude/code/sonnet/v4.5': 'claude-sonnet-4-5-20250929',
|
|
18
|
+
'claude/code/opus': 'claude-opus-4-20250514',
|
|
19
|
+
'claude/code/opus/v4.5': 'claude-opus-4-5-20251101',
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* .what = tools disallowed for readonly ask operations
|
|
23
|
+
* .why = prevents mutations during research/analysis tasks
|
|
24
|
+
*/
|
|
25
|
+
const TOOLS_DISALLOWED_FOR_ASK = [
|
|
26
|
+
'Edit',
|
|
27
|
+
'Write',
|
|
28
|
+
'Bash',
|
|
29
|
+
'NotebookEdit',
|
|
30
|
+
];
|
|
31
|
+
/**
|
|
32
|
+
* .what = tools allowed for read+write act operations
|
|
33
|
+
* .why = enables full agentic capabilities for code changes
|
|
34
|
+
*/
|
|
35
|
+
const TOOLS_ALLOWED_FOR_ACT = [
|
|
36
|
+
'Read',
|
|
37
|
+
'Edit',
|
|
38
|
+
'Write',
|
|
39
|
+
'Bash',
|
|
40
|
+
'Glob',
|
|
41
|
+
'Grep',
|
|
42
|
+
'Task',
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* .what = extracts final result from claude-agent-sdk query async generator
|
|
46
|
+
* .why = query() returns an async iterator, need to consume to get result
|
|
47
|
+
*
|
|
48
|
+
* .note = when outputFormat is used, result may be in structured_output field
|
|
49
|
+
*/
|
|
50
|
+
const extractResultFromQuery = async (queryIterator) => {
|
|
51
|
+
let result;
|
|
52
|
+
let structuredOutput;
|
|
53
|
+
for await (const message of queryIterator) {
|
|
54
|
+
// check for result message with success subtype
|
|
55
|
+
if (message.type === 'result' && message.subtype === 'success') {
|
|
56
|
+
result = message.result;
|
|
57
|
+
structuredOutput = message.structured_output;
|
|
58
|
+
}
|
|
59
|
+
// throw on error subtypes
|
|
60
|
+
if (message.type === 'result' && message.subtype !== 'success') {
|
|
61
|
+
throw new Error(`claude-agent-sdk query failed: ${message.subtype}, errors: ${message.errors?.join(', ') ?? 'unknown'}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// prefer structured_output when available (used with outputFormat)
|
|
65
|
+
if (structuredOutput !== undefined)
|
|
66
|
+
return structuredOutput;
|
|
67
|
+
// fall back to parsing result as JSON
|
|
68
|
+
if (result !== undefined)
|
|
69
|
+
return JSON.parse(result);
|
|
70
|
+
throw new Error('no result message received from claude-agent-sdk');
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* .what = invokes claude-agent-sdk query with specified mode
|
|
74
|
+
* .why = dedupes shared logic between ask (readonly) and act (read+write)
|
|
75
|
+
*/
|
|
76
|
+
const invokeQuery = async (input) => {
|
|
77
|
+
// compose system prompt from briefs
|
|
78
|
+
const systemPrompt = input.role.briefs
|
|
79
|
+
? await (0, rhachet_1.castBriefsToPrompt)({ briefs: input.role.briefs })
|
|
80
|
+
: undefined;
|
|
81
|
+
// convert zod schema to json schema for native structured output
|
|
82
|
+
const jsonSchema = (0, asJsonSchema_1.asJsonSchema)({ schema: input.schema.output });
|
|
83
|
+
// build tool constraints based on mode
|
|
84
|
+
const toolConstraints = input.mode === 'ask'
|
|
85
|
+
? { disallowedTools: [...TOOLS_DISALLOWED_FOR_ASK] }
|
|
86
|
+
: { allowedTools: [...TOOLS_ALLOWED_FOR_ACT] };
|
|
87
|
+
// invoke claude-agent-sdk query
|
|
88
|
+
const queryIterator = (0, claude_agent_sdk_1.query)({
|
|
89
|
+
prompt: input.prompt,
|
|
90
|
+
options: {
|
|
91
|
+
systemPrompt,
|
|
92
|
+
model: input.model,
|
|
93
|
+
...toolConstraints,
|
|
94
|
+
outputFormat: {
|
|
95
|
+
type: 'json_schema',
|
|
96
|
+
schema: jsonSchema,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
// extract final result from async iterator
|
|
101
|
+
const result = await extractResultFromQuery(queryIterator);
|
|
102
|
+
// parse output via schema for runtime validation
|
|
103
|
+
return input.schema.output.parse(result);
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* .what = factory to generate claude code brain repl instances
|
|
107
|
+
* .why = enables model variant selection via slug (e.g., haiku for speed, opus for quality)
|
|
108
|
+
*
|
|
109
|
+
* .example
|
|
110
|
+
* genBrainRepl({ slug: 'claude/code' }) // default model
|
|
111
|
+
* genBrainRepl({ slug: 'claude/code/haiku' }) // fast + cheap
|
|
112
|
+
* genBrainRepl({ slug: 'claude/code/opus/v4.5' }) // highest quality
|
|
113
|
+
*/
|
|
114
|
+
const genBrainRepl = (input) => {
|
|
115
|
+
const model = MODEL_BY_SLUG[input.slug];
|
|
116
|
+
return new rhachet_1.BrainRepl({
|
|
117
|
+
repo: 'anthropic',
|
|
118
|
+
slug: input.slug,
|
|
119
|
+
description: `claude code (${input.slug}) - agentic coding assistant with tool use`,
|
|
120
|
+
/**
|
|
121
|
+
* .what = readonly analysis (research, queries, code review)
|
|
122
|
+
* .why = provides safe, non-mutating agent interactions
|
|
123
|
+
*/
|
|
124
|
+
ask: async (askInput, _context) => invokeQuery({ mode: 'ask', model, ...askInput }),
|
|
125
|
+
/**
|
|
126
|
+
* .what = read+write actions (code changes, file edits)
|
|
127
|
+
* .why = provides full agentic capabilities with write access
|
|
128
|
+
*/
|
|
129
|
+
act: async (actInput, _context) => invokeQuery({ mode: 'act', model, ...actInput }),
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
exports.genBrainRepl = genBrainRepl;
|
|
133
|
+
//# sourceMappingURL=genBrainRepl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genBrainRepl.js","sourceRoot":"","sources":["../../../src/domain.operations/repls/genBrainRepl.ts"],"names":[],"mappings":";;;AAAA,qEAAuD;AACvD,qCAAwD;AAMxD,kEAA+D;AAgB/D;;;GAGG;AACH,MAAM,aAAa,GAA+C;IAChE,aAAa,EAAE,SAAS,EAAE,kBAAkB;IAC5C,mBAAmB,EAAE,2BAA2B;IAChD,wBAAwB,EAAE,2BAA2B;IACrD,oBAAoB,EAAE,4BAA4B;IAClD,uBAAuB,EAAE,0BAA0B;IACnD,yBAAyB,EAAE,4BAA4B;IACvD,kBAAkB,EAAE,wBAAwB;IAC5C,uBAAuB,EAAE,0BAA0B;CACpD,CAAC;AAEF;;;GAGG;AACH,MAAM,wBAAwB,GAAG;IAC/B,MAAM;IACN,OAAO;IACP,MAAM;IACN,cAAc;CACN,CAAC;AAEX;;;GAGG;AACH,MAAM,qBAAqB,GAAG;IAC5B,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;C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AE,KAAK,EACR,QAIC,EACD,QAAgB,EACE,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;KACxE,CAAC,CAAC;AACL,CAAC,CAAC;AAlCW,QAAA,YAAY,gBAkCvB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* .what = converts zod schema to JSON schema for claude-agent-sdk
|
|
4
|
+
* .why = claude-agent-sdk doesn't expect $schema property; strip it for compatibility
|
|
5
|
+
*/
|
|
6
|
+
export declare const asJsonSchema: (input: {
|
|
7
|
+
schema: z.ZodSchema;
|
|
8
|
+
}) => Record<string, unknown>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asJsonSchema = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = converts zod schema to JSON schema for claude-agent-sdk
|
|
6
|
+
* .why = claude-agent-sdk doesn't expect $schema property; strip it for compatibility
|
|
7
|
+
*/
|
|
8
|
+
const asJsonSchema = (input) => {
|
|
9
|
+
// convert zod schema to json schema
|
|
10
|
+
const { z } = require('zod');
|
|
11
|
+
const jsonSchemaRaw = z.toJSONSchema(input.schema);
|
|
12
|
+
// remove $schema property as claude-agent-sdk doesn't expect it
|
|
13
|
+
const { $schema: _, ...jsonSchema } = jsonSchemaRaw;
|
|
14
|
+
return jsonSchema;
|
|
15
|
+
};
|
|
16
|
+
exports.asJsonSchema = asJsonSchema;
|
|
17
|
+
//# sourceMappingURL=asJsonSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asJsonSchema.js","sourceRoot":"","sources":["../../../src/infra/schema/asJsonSchema.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACI,MAAM,YAAY,GAAG,CAAC,KAE5B,EAA2B,EAAE;IAC5B,oCAAoC;IACpC,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,MAAM,aAAa,GAAG,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEnD,gEAAgE;IAChE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,aAGrC,CAAC;IAEF,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAdW,QAAA,YAAY,gBAcvB"}
|
package/license.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 ehmpathy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rhachet-brains-anthropic",
|
|
3
|
+
"author": "ehmpathy",
|
|
4
|
+
"description": "rhachet brain.atom and brain.repl adapter for openai",
|
|
5
|
+
"version": "0.0.0",
|
|
6
|
+
"repository": "ehmpathy/rhachet-brains-anthropic",
|
|
7
|
+
"homepage": "https://github.com/ehmpathy/rhachet-brains-anthropic",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"rhachet",
|
|
10
|
+
"brain",
|
|
11
|
+
"anthropic",
|
|
12
|
+
"claude",
|
|
13
|
+
"claude-code",
|
|
14
|
+
"ai"
|
|
15
|
+
],
|
|
16
|
+
"bugs": "https://github.com/ehmpathy/rhachet-brains-anthropic/issues",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=8.0.0"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"/dist"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@anthropic-ai/claude-agent-sdk": "0.1.76",
|
|
27
|
+
"@anthropic-ai/sdk": "0.71.2",
|
|
28
|
+
"domain-objects": "0.31.9",
|
|
29
|
+
"helpful-errors": "1.5.3",
|
|
30
|
+
"openai": "5.8.2",
|
|
31
|
+
"rhachet-artifact": "1.0.1",
|
|
32
|
+
"rhachet-artifact-git": "1.1.5",
|
|
33
|
+
"type-fns": "1.21.0",
|
|
34
|
+
"wrapper-fns": "1.1.7",
|
|
35
|
+
"zod": "4.3.4"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@biomejs/biome": "2.3.8",
|
|
39
|
+
"@commitlint/cli": "19.5.0",
|
|
40
|
+
"@commitlint/config-conventional": "19.5.0",
|
|
41
|
+
"@swc/core": "1.15.3",
|
|
42
|
+
"@swc/jest": "0.2.39",
|
|
43
|
+
"@tsconfig/node20": "20.1.5",
|
|
44
|
+
"@tsconfig/strictest": "2.0.5",
|
|
45
|
+
"@types/jest": "30.0.0",
|
|
46
|
+
"@types/node": "22.15.21",
|
|
47
|
+
"cz-conventional-changelog": "3.3.0",
|
|
48
|
+
"declapract": "0.13.14",
|
|
49
|
+
"declapract-typescript-ehmpathy": "0.47.16",
|
|
50
|
+
"declastruct": "1.7.3",
|
|
51
|
+
"declastruct-github": "1.3.0",
|
|
52
|
+
"depcheck": "1.4.3",
|
|
53
|
+
"esbuild-register": "3.6.0",
|
|
54
|
+
"husky": "8.0.3",
|
|
55
|
+
"jest": "30.2.0",
|
|
56
|
+
"rhachet": "1.21.4",
|
|
57
|
+
"rhachet-roles-bhrain": "0.5.9",
|
|
58
|
+
"rhachet-roles-bhuild": "0.6.3",
|
|
59
|
+
"rhachet-roles-ehmpathy": "1.17.15",
|
|
60
|
+
"test-fns": "1.5.0",
|
|
61
|
+
"tsc-alias": "1.8.10",
|
|
62
|
+
"tsx": "4.20.6",
|
|
63
|
+
"typescript": "5.4.5",
|
|
64
|
+
"yalc": "1.0.0-pre.53"
|
|
65
|
+
},
|
|
66
|
+
"config": {
|
|
67
|
+
"commitizen": {
|
|
68
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"scripts": {
|
|
72
|
+
"build:ts": "tsc -p ./tsconfig.build.json",
|
|
73
|
+
"commit:with-cli": "npx cz",
|
|
74
|
+
"fix:format:biome": "biome check --write",
|
|
75
|
+
"fix:format": "npm run fix:format:biome",
|
|
76
|
+
"fix:lint": "biome check --write",
|
|
77
|
+
"fix": "npm run fix:format && npm run fix:lint",
|
|
78
|
+
"build:clean:bun": "rm -f ./bin/*.bc",
|
|
79
|
+
"build:clean:tsc": "(chmod -R u+w dist 2>/dev/null || true) && rm -rf dist/",
|
|
80
|
+
"build:clean": "npm run build:clean:tsc && npm run build:clean:bun",
|
|
81
|
+
"build:compile:tsc": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
|
|
82
|
+
"build:compile": "npm run build:compile:tsc && npm run build:compile:bun --if-present",
|
|
83
|
+
"build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
|
|
84
|
+
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
|
|
85
|
+
"test:types": "tsc -p ./tsconfig.json --noEmit",
|
|
86
|
+
"test:format:biome": "biome format",
|
|
87
|
+
"test:format": "npm run test:format:biome",
|
|
88
|
+
"test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
|
|
89
|
+
"test:lint:biome": "biome check --diagnostic-level=error",
|
|
90
|
+
"test:lint:biome:all": "biome check",
|
|
91
|
+
"test:lint": "npm run test:lint:biome && npm run test:lint:deps",
|
|
92
|
+
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
93
|
+
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
94
|
+
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
95
|
+
"test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
|
|
96
|
+
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
97
|
+
"prepush": "npm run test && npm run build",
|
|
98
|
+
"prepublish": "npm run build",
|
|
99
|
+
"preversion": "npm run prepush",
|
|
100
|
+
"postversion": "git push origin HEAD --tags --no-verify",
|
|
101
|
+
"prepare:husky": "husky install && chmod ug+x .husky/*",
|
|
102
|
+
"prepare:rhachet": "rhachet init --mode upsert && 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"
|
|
103
|
+
}
|
|
104
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# rhachet-brains-anthropic
|
|
2
|
+
|
|
3
|
+
rhachet brain.atom and brain.repl adapter for anthropic
|
|
4
|
+
|
|
5
|
+
## install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install rhachet-brains-anthropic
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { genBrainAtom, genBrainRepl } from 'rhachet-brains-anthropic';
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
|
|
17
|
+
// create a brain atom for direct model inference
|
|
18
|
+
const brainAtom = genBrainAtom({ slug: 'claude/sonnet' });
|
|
19
|
+
|
|
20
|
+
// simple string output
|
|
21
|
+
const response = await brainAtom.ask({
|
|
22
|
+
role: { briefs: [] },
|
|
23
|
+
prompt: 'explain this code',
|
|
24
|
+
schema: { output: z.string() },
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// structured object output
|
|
28
|
+
const result = await brainAtom.ask({
|
|
29
|
+
role: { briefs: [] },
|
|
30
|
+
prompt: 'analyze this code',
|
|
31
|
+
schema: { output: z.object({ summary: z.string(), issues: z.array(z.string()) }) },
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// create a brain repl for agentic tasks
|
|
35
|
+
const brainRepl = genBrainRepl({ slug: 'claude/code' });
|
|
36
|
+
|
|
37
|
+
// use ask() for read-only operations
|
|
38
|
+
const analysis = await brainRepl.ask({
|
|
39
|
+
role: { briefs: [] },
|
|
40
|
+
prompt: 'analyze this codebase',
|
|
41
|
+
schema: { output: z.object({ content: z.string() }) },
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// use act() for read+write operations
|
|
45
|
+
const refactor = await brainRepl.act({
|
|
46
|
+
role: { briefs: [] },
|
|
47
|
+
prompt: 'refactor this module',
|
|
48
|
+
schema: { output: z.object({ content: z.string() }) },
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## available brains
|
|
53
|
+
|
|
54
|
+
### atoms (via genBrainAtom)
|
|
55
|
+
|
|
56
|
+
stateless inference without tool use. uses anthropic api with structured outputs.
|
|
57
|
+
|
|
58
|
+
| slug | model | description |
|
|
59
|
+
| -------------------- | -------------------------- | ----------------------------------- |
|
|
60
|
+
| `claude/haiku` | claude-haiku-4-5-20251001 | fastest and most cost-effective |
|
|
61
|
+
| `claude/haiku/v3.5` | claude-3-5-haiku-20241022 | fast and cost-effective |
|
|
62
|
+
| `claude/haiku/v4.5` | claude-haiku-4-5-20251001 | fastest and most cost-effective |
|
|
63
|
+
| `claude/sonnet` | claude-sonnet-4-5-20250929 | balanced performance and capability |
|
|
64
|
+
| `claude/sonnet/v4` | claude-sonnet-4-20250514 | balanced performance and capability |
|
|
65
|
+
| `claude/sonnet/v4.5` | claude-sonnet-4-5-20250929 | balanced performance and capability |
|
|
66
|
+
| `claude/opus` | claude-opus-4-5-20251101 | most capable for complex tasks |
|
|
67
|
+
| `claude/opus/v4` | claude-opus-4-20250514 | highly capable for complex tasks |
|
|
68
|
+
| `claude/opus/v4.5` | claude-opus-4-5-20251101 | most capable for complex tasks |
|
|
69
|
+
|
|
70
|
+
### repls (via genBrainRepl)
|
|
71
|
+
|
|
72
|
+
agentic code assistant with tool use via claude-agent-sdk.
|
|
73
|
+
|
|
74
|
+
| slug | model | description |
|
|
75
|
+
| ------------------------- | -------------------------- | ----------------------------------- |
|
|
76
|
+
| `claude/code` | sdk default | uses claude-agent-sdk default model |
|
|
77
|
+
| `claude/code/haiku` | claude-haiku-4-5-20251001 | fast and cost-effective agent |
|
|
78
|
+
| `claude/code/haiku/v4.5` | claude-haiku-4-5-20251001 | fast and cost-effective agent |
|
|
79
|
+
| `claude/code/sonnet` | claude-sonnet-4-5-20250929 | balanced agentic capability |
|
|
80
|
+
| `claude/code/sonnet/v4` | claude-sonnet-4-20250514 | balanced agentic capability |
|
|
81
|
+
| `claude/code/sonnet/v4.5` | claude-sonnet-4-5-20250929 | balanced agentic capability |
|
|
82
|
+
| `claude/code/opus` | claude-opus-4-20250514 | high capability agent |
|
|
83
|
+
| `claude/code/opus/v4.5` | claude-opus-4-5-20251101 | most capable agent |
|
|
84
|
+
|
|
85
|
+
## sources
|
|
86
|
+
|
|
87
|
+
- [anthropic api documentation](https://docs.anthropic.com/en/api/)
|
|
88
|
+
- [claude-agent-sdk documentation](https://docs.anthropic.com/en/docs/claude-agent-sdk)
|