@monoes/monomindcli 2.9.1 → 2.9.3
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/.claude/helpers/statusline.cjs +45 -0
- package/.claude/helpers/token-tracker.cjs +13 -1
- package/.claude/settings.json +0 -1
- package/.claude/skills/github-toolkit/SKILL.md +60 -0
- package/.claude/skills/mastermind-createorg/SKILL.md +8 -2
- package/.claude/skills/memory-toolkit/SKILL.md +75 -0
- package/.claude/skills/monodesign/scripts/detector/rules/checks.mjs +24 -1
- package/README.md +1 -1
- package/dist/src/agents/registry-builder.d.ts.map +1 -1
- package/dist/src/agents/registry-builder.js +94 -1
- package/dist/src/agents/registry-builder.js.map +1 -1
- package/dist/src/capabilities/cap-documents.js +7 -7
- package/dist/src/capabilities/cap-documents.js.map +1 -1
- package/dist/src/commands/completions.js +2 -2
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/doctor-env-checks.d.ts.map +1 -1
- package/dist/src/commands/doctor-env-checks.js +14 -2
- package/dist/src/commands/doctor-env-checks.js.map +1 -1
- package/dist/src/commands/index.d.ts +27 -41
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +113 -207
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init-wizard.d.ts.map +1 -1
- package/dist/src/commands/init-wizard.js +35 -0
- package/dist/src/commands/init-wizard.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +43 -0
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/neural-optimize.d.ts.map +1 -1
- package/dist/src/commands/neural-optimize.js +12 -8
- package/dist/src/commands/neural-optimize.js.map +1 -1
- package/dist/src/commands/org-observe.js +2 -2
- package/dist/src/commands/org-observe.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +19 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/claudemd-generator.js +2 -2
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +21 -4
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +16 -37
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.d.ts.map +1 -1
- package/dist/src/init/statusline-generator.js +45 -0
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +8 -0
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/init/upgrade.d.ts.map +1 -1
- package/dist/src/init/upgrade.js +3 -9
- package/dist/src/init/upgrade.js.map +1 -1
- package/dist/src/knowledge/document-pipeline.d.ts.map +1 -1
- package/dist/src/knowledge/document-pipeline.js +1 -0
- package/dist/src/knowledge/document-pipeline.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +7 -15
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/memory/bm25-index.d.ts +17 -0
- package/dist/src/memory/bm25-index.d.ts.map +1 -1
- package/dist/src/memory/bm25-index.js +17 -0
- package/dist/src/memory/bm25-index.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts +4 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -1
- package/dist/src/memory/memory-bridge.js +128 -22
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts.map +1 -1
- package/dist/src/memory/memory-initializer.js +0 -50
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/memory-kg.d.ts.map +1 -1
- package/dist/src/memory/memory-kg.js +21 -5
- package/dist/src/memory/memory-kg.js.map +1 -1
- package/dist/src/monovector/diff-classifier.d.ts.map +1 -1
- package/dist/src/monovector/diff-classifier.js +11 -20
- package/dist/src/monovector/diff-classifier.js.map +1 -1
- package/dist/src/orgrt/antigravity-runner.d.ts +9 -0
- package/dist/src/orgrt/antigravity-runner.d.ts.map +1 -0
- package/dist/src/orgrt/antigravity-runner.js +250 -0
- package/dist/src/orgrt/antigravity-runner.js.map +1 -0
- package/dist/src/orgrt/codex-runner.d.ts +9 -0
- package/dist/src/orgrt/codex-runner.d.ts.map +1 -0
- package/dist/src/orgrt/codex-runner.js +216 -0
- package/dist/src/orgrt/codex-runner.js.map +1 -0
- package/dist/src/orgrt/cross-org.d.ts.map +1 -1
- package/dist/src/orgrt/cross-org.js +8 -0
- package/dist/src/orgrt/cross-org.js.map +1 -1
- package/dist/src/orgrt/daemon.d.ts +14 -7
- package/dist/src/orgrt/daemon.d.ts.map +1 -1
- package/dist/src/orgrt/daemon.js +72 -12
- package/dist/src/orgrt/daemon.js.map +1 -1
- package/dist/src/orgrt/fence.d.ts +39 -0
- package/dist/src/orgrt/fence.d.ts.map +1 -0
- package/dist/src/orgrt/fence.js +75 -0
- package/dist/src/orgrt/fence.js.map +1 -0
- package/dist/src/orgrt/kimicode-runner.d.ts.map +1 -1
- package/dist/src/orgrt/kimicode-runner.js +27 -1
- package/dist/src/orgrt/kimicode-runner.js.map +1 -1
- package/dist/src/orgrt/provider.d.ts.map +1 -1
- package/dist/src/orgrt/provider.js +26 -0
- package/dist/src/orgrt/provider.js.map +1 -1
- package/dist/src/orgrt/session.d.ts +11 -1
- package/dist/src/orgrt/session.d.ts.map +1 -1
- package/dist/src/orgrt/session.js +60 -3
- package/dist/src/orgrt/session.js.map +1 -1
- package/dist/src/orgrt/tool-fence.d.ts +7 -2
- package/dist/src/orgrt/tool-fence.d.ts.map +1 -1
- package/dist/src/orgrt/tool-fence.js +18 -2
- package/dist/src/orgrt/tool-fence.js.map +1 -1
- package/dist/src/orgrt/types.d.ts +222 -0
- package/dist/src/orgrt/types.d.ts.map +1 -1
- package/dist/src/orgrt/types.js +34 -3
- package/dist/src/orgrt/types.js.map +1 -1
- package/dist/src/orgrt/vercel-providers.d.ts +29 -0
- package/dist/src/orgrt/vercel-providers.d.ts.map +1 -0
- package/dist/src/orgrt/vercel-providers.js +162 -0
- package/dist/src/orgrt/vercel-providers.js.map +1 -0
- package/dist/src/orgrt/vercel-runner.d.ts +39 -0
- package/dist/src/orgrt/vercel-runner.d.ts.map +1 -0
- package/dist/src/orgrt/vercel-runner.js +121 -0
- package/dist/src/orgrt/vercel-runner.js.map +1 -0
- package/dist/src/orgrt/vercel-session-store.d.ts +12 -0
- package/dist/src/orgrt/vercel-session-store.d.ts.map +1 -0
- package/dist/src/orgrt/vercel-session-store.js +49 -0
- package/dist/src/orgrt/vercel-session-store.js.map +1 -0
- package/dist/src/pricing/model-pricing.d.ts +10 -1
- package/dist/src/pricing/model-pricing.d.ts.map +1 -1
- package/dist/src/pricing/model-pricing.js +18 -1
- package/dist/src/pricing/model-pricing.js.map +1 -1
- package/dist/src/services/crash-reporter.d.ts +6 -5
- package/dist/src/services/crash-reporter.d.ts.map +1 -1
- package/dist/src/services/crash-reporter.js +6 -81
- package/dist/src/services/crash-reporter.js.map +1 -1
- package/dist/src/ui/collector.mjs +16 -82
- package/dist/src/ui/dashboard.html +176 -545
- package/dist/src/ui/data/mastermind-sessions.json +1 -0
- package/dist/src/ui/markdown.js +273 -0
- package/dist/src/ui/server.mjs +99 -189
- package/dist/src/utils/input-guards.d.ts +4 -1
- package/dist/src/utils/input-guards.d.ts.map +1 -1
- package/dist/src/utils/input-guards.js +6 -4
- package/dist/src/utils/input-guards.js.map +1 -1
- package/dist/src/utils/redaction.d.ts +24 -0
- package/dist/src/utils/redaction.d.ts.map +1 -0
- package/dist/src/utils/redaction.js +190 -0
- package/dist/src/utils/redaction.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -5
- package/scripts/check-workspace-deps.mjs +45 -0
- package/scripts/publish.sh +24 -33
package/dist/src/orgrt/types.js
CHANGED
|
@@ -2,13 +2,42 @@
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
/** Per-role provider config. Default (absent) = subscription login of local Claude Code. */
|
|
4
4
|
export const ProviderSchema = z.object({
|
|
5
|
-
kind: z.enum([
|
|
5
|
+
kind: z.enum([
|
|
6
|
+
'subscription', 'api-key', 'base-url', 'bedrock', 'vertex', 'gemini', 'openai',
|
|
7
|
+
'vercel-api-key', 'codex', 'antigravity',
|
|
8
|
+
]).default('subscription'),
|
|
9
|
+
/** Which Vercel AI SDK provider to use (only when kind='vercel-api-key'). */
|
|
10
|
+
vendor: z.enum([
|
|
11
|
+
'openai', 'anthropic', 'google', 'xai', 'deepseek', 'glm',
|
|
12
|
+
'mistral', 'groq', 'together', 'fireworks', 'cohere',
|
|
13
|
+
'perplexity', 'alibaba', 'openrouter', 'ollama',
|
|
14
|
+
'openai-compatible',
|
|
15
|
+
]).optional(),
|
|
6
16
|
/** env var NAME holding the API key (never the key itself) */
|
|
7
17
|
apiKeyEnv: z.string().optional(),
|
|
8
18
|
baseUrl: z.string().optional(),
|
|
9
19
|
/** env var NAME holding the auth token for base-url providers */
|
|
10
20
|
authTokenEnv: z.string().optional(),
|
|
11
21
|
}).strict();
|
|
22
|
+
const THREAT_TYPES = ['prompt_injection', 'jailbreak', 'pii_exposure', 'instruction_override',
|
|
23
|
+
'role_switching', 'context_manipulation', 'encoding_attack', 'data_exfiltration', 'unknown'];
|
|
24
|
+
export const FenceAllowlistRuleSchema = z.object({
|
|
25
|
+
id: z.string().min(1),
|
|
26
|
+
pattern: z.string().min(1),
|
|
27
|
+
types: z.array(z.enum(THREAT_TYPES)).default([]),
|
|
28
|
+
context: z.string().optional(),
|
|
29
|
+
reason: z.string().optional(),
|
|
30
|
+
source: z.string().optional(),
|
|
31
|
+
});
|
|
32
|
+
export const FenceConfigSchema = z.object({
|
|
33
|
+
enabled: z.boolean().default(true),
|
|
34
|
+
confidenceThreshold: z.number().min(0).max(1).optional(),
|
|
35
|
+
enablePIIDetection: z.boolean().optional(),
|
|
36
|
+
scanMessages: z.boolean().default(true),
|
|
37
|
+
scanOutput: z.boolean().default(false),
|
|
38
|
+
abortThreshold: z.number().min(0).max(1).default(0.8),
|
|
39
|
+
allowlist: z.array(FenceAllowlistRuleSchema).default([]),
|
|
40
|
+
}).partial().passthrough();
|
|
12
41
|
export const RolePolicySchema = z.object({
|
|
13
42
|
allowTools: z.array(z.string()).optional(),
|
|
14
43
|
denyTools: z.array(z.string()).default([]),
|
|
@@ -23,6 +52,7 @@ export const RolePolicySchema = z.object({
|
|
|
23
52
|
/** Git access level: 'none' blocks all git, 'read' allows status/log/diff,
|
|
24
53
|
* 'commit' allows add/commit, 'push' allows push. Default: 'read'. */
|
|
25
54
|
git: z.enum(['none', 'read', 'commit', 'push']).default('read'),
|
|
55
|
+
fence: FenceConfigSchema.optional(),
|
|
26
56
|
}).partial().passthrough();
|
|
27
57
|
export const RoleSchema = z.object({
|
|
28
58
|
id: z.string().min(1),
|
|
@@ -41,7 +71,7 @@ export const RoleSchema = z.object({
|
|
|
41
71
|
* agent runtime regardless of the org-level `runtime` field or the
|
|
42
72
|
* MONOMIND_RUNTIME env var ('claude' explicitly forces the Claude default).
|
|
43
73
|
* Enables mixed-runtime orgs — e.g. a Claude coordinator with opencode workers. */
|
|
44
|
-
runtime: z.enum(['claude', 'kimicode', 'opencode']).optional(),
|
|
74
|
+
runtime: z.enum(['claude', 'kimicode', 'opencode', 'vercel', 'codex', 'antigravity']).optional(),
|
|
45
75
|
/** Per-role override of run_config.max_turns_per_message — roles that legitimately
|
|
46
76
|
* need many more turns per message (e.g. a developer doing sequential build/fix/verify
|
|
47
77
|
* cycles) than others (e.g. docs, pm) shouldn't be forced onto one global budget. */
|
|
@@ -86,12 +116,13 @@ export const OrgDefSchema = z.object({
|
|
|
86
116
|
})).optional(),
|
|
87
117
|
}).partial().passthrough().default({})
|
|
88
118
|
.transform(rc => ({ max_concurrent_agents: 4, budget_tokens: 1_000_000, max_turns_per_message: 30, workspace: 'repo', stale_base_threshold: 0, ...rc })),
|
|
119
|
+
fence: FenceConfigSchema.optional(),
|
|
89
120
|
roles: z.array(RoleSchema).min(1),
|
|
90
121
|
/** Which agent runtime hosts this org's role sessions. When absent, the
|
|
91
122
|
* MONOMIND_RUNTIME env var is honored, falling back to the default Claude
|
|
92
123
|
* runner. Per-org values override the env var, and a role's own `runtime`
|
|
93
124
|
* field (see RoleSchema) overrides this per role. */
|
|
94
|
-
runtime: z.enum(['claude', 'kimicode', 'opencode']).optional(),
|
|
125
|
+
runtime: z.enum(['claude', 'kimicode', 'opencode', 'vercel', 'codex', 'antigravity']).optional(),
|
|
95
126
|
}).passthrough();
|
|
96
127
|
export const ORG_DIR = '.monomind/orgs';
|
|
97
128
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/orgrt/types.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4FAA4F;AAC5F,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/orgrt/types.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4FAA4F;AAC5F,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;QACX,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;QAC9E,gBAAgB,EAAE,OAAO,EAAE,aAAa;KACzC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IAC1B,6EAA6E;IAC7E,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC;QACb,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,U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EAAE,CAAC,CAAC,EAAE,qBAAqB,EAAE,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,qBAAqB,EAAE,EAAE,EAAE,SAAS,EAAE,MAAgB,EAAE,oBAAoB,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IACpK,KAAK,EAAE,iBAAiB,CAAC,QAAQ,EAAE;IACnC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC;;;0DAGsD;IACtD,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ,EAAE;CACjG,CAAC,CAAC,WAAW,EAAE,CAAC;AA2CjB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry of Vercel AI SDK providers. Each entry maps a vendor slug to the
|
|
3
|
+
* dynamic import spec, factory function, default model, and env var name.
|
|
4
|
+
*
|
|
5
|
+
* VercelAgentRunner uses this to resolve and construct the right provider
|
|
6
|
+
* instance at runtime. All packages are optionalDependencies — missing
|
|
7
|
+
* packages produce a clear actionable error instead of a crash.
|
|
8
|
+
*/
|
|
9
|
+
export interface VercelProviderDef {
|
|
10
|
+
vendor: string;
|
|
11
|
+
/** npm import specifier for dynamic import(). */
|
|
12
|
+
package: string;
|
|
13
|
+
/** Factory function exported by the package (e.g. createOpenAI). */
|
|
14
|
+
factory: string;
|
|
15
|
+
/** Sane default model when role doesn't pin one. */
|
|
16
|
+
defaultModel: string;
|
|
17
|
+
/** Default API key env var name. */
|
|
18
|
+
envVar: string;
|
|
19
|
+
/** Override base URL (e.g. GLM's z.ai endpoint). */
|
|
20
|
+
defaultBaseUrl?: string;
|
|
21
|
+
/** If true, use @ai-sdk/openai with custom baseURL (Chat Completions API). */
|
|
22
|
+
isOpenAiCompatible?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const VERCEL_PROVIDERS: Record<string, VercelProviderDef>;
|
|
25
|
+
/** Resolve a provider instance via dynamic import. Throws clear error if
|
|
26
|
+
* the package is missing (optionalDependencies pattern — mirrors how
|
|
27
|
+
* opencode-runner and kimicode-runner handle missing SDK packages). */
|
|
28
|
+
export declare function loadVercelProvider(def: VercelProviderDef, apiKey?: string, baseUrl?: string): Promise<(modelId: string) => any>;
|
|
29
|
+
//# sourceMappingURL=vercel-providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel-providers.d.ts","sourceRoot":"","sources":["../../../src/orgrt/vercel-providers.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8EAA8E;IAC9E,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAqH9D,CAAC;AAEF;;wEAEwE;AACxE,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,iBAAiB,EACtB,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,GAAG,CAAC,CA8BnC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// packages/@monomind/cli/src/orgrt/vercel-providers.ts
|
|
2
|
+
/**
|
|
3
|
+
* Registry of Vercel AI SDK providers. Each entry maps a vendor slug to the
|
|
4
|
+
* dynamic import spec, factory function, default model, and env var name.
|
|
5
|
+
*
|
|
6
|
+
* VercelAgentRunner uses this to resolve and construct the right provider
|
|
7
|
+
* instance at runtime. All packages are optionalDependencies — missing
|
|
8
|
+
* packages produce a clear actionable error instead of a crash.
|
|
9
|
+
*/
|
|
10
|
+
export const VERCEL_PROVIDERS = {
|
|
11
|
+
openai: {
|
|
12
|
+
vendor: 'openai',
|
|
13
|
+
package: '@ai-sdk/openai',
|
|
14
|
+
factory: 'createOpenAI',
|
|
15
|
+
defaultModel: 'gpt-5.5',
|
|
16
|
+
envVar: 'OPENAI_API_KEY',
|
|
17
|
+
},
|
|
18
|
+
anthropic: {
|
|
19
|
+
vendor: 'anthropic',
|
|
20
|
+
package: '@ai-sdk/anthropic',
|
|
21
|
+
factory: 'createAnthropic',
|
|
22
|
+
defaultModel: 'claude-sonnet-5',
|
|
23
|
+
envVar: 'ANTHROPIC_API_KEY',
|
|
24
|
+
},
|
|
25
|
+
glm: {
|
|
26
|
+
vendor: 'glm',
|
|
27
|
+
package: '@ai-sdk/openai',
|
|
28
|
+
factory: 'createOpenAI',
|
|
29
|
+
defaultModel: 'glm-5.2',
|
|
30
|
+
envVar: 'ZHIPU_API_KEY',
|
|
31
|
+
defaultBaseUrl: 'https://api.z.ai/api/paas/v4',
|
|
32
|
+
isOpenAiCompatible: true,
|
|
33
|
+
},
|
|
34
|
+
google: {
|
|
35
|
+
vendor: 'google',
|
|
36
|
+
package: '@ai-sdk/google',
|
|
37
|
+
factory: 'createGoogleGenerativeAI',
|
|
38
|
+
defaultModel: 'gemini-3.1-pro',
|
|
39
|
+
envVar: 'GOOGLE_GENERATIVE_AI_API_KEY',
|
|
40
|
+
},
|
|
41
|
+
xai: {
|
|
42
|
+
vendor: 'xai',
|
|
43
|
+
package: '@ai-sdk/xai',
|
|
44
|
+
factory: 'createXAI',
|
|
45
|
+
defaultModel: 'grok-4.5',
|
|
46
|
+
envVar: 'XAI_API_KEY',
|
|
47
|
+
},
|
|
48
|
+
deepseek: {
|
|
49
|
+
vendor: 'deepseek',
|
|
50
|
+
package: '@ai-sdk/deepseek',
|
|
51
|
+
factory: 'createDeepSeek',
|
|
52
|
+
defaultModel: 'deepseek-chat',
|
|
53
|
+
envVar: 'DEEPSEEK_API_KEY',
|
|
54
|
+
},
|
|
55
|
+
mistral: {
|
|
56
|
+
vendor: 'mistral',
|
|
57
|
+
package: '@ai-sdk/mistral',
|
|
58
|
+
factory: 'createMistral',
|
|
59
|
+
defaultModel: 'mistral-large-latest',
|
|
60
|
+
envVar: 'MISTRAL_API_KEY',
|
|
61
|
+
},
|
|
62
|
+
groq: {
|
|
63
|
+
vendor: 'groq',
|
|
64
|
+
package: '@ai-sdk/groq',
|
|
65
|
+
factory: 'createGroq',
|
|
66
|
+
defaultModel: 'moonshotai/kimi-k2-instruct-0905',
|
|
67
|
+
envVar: 'GROQ_API_KEY',
|
|
68
|
+
},
|
|
69
|
+
together: {
|
|
70
|
+
vendor: 'together',
|
|
71
|
+
package: '@ai-sdk/togetherai',
|
|
72
|
+
factory: 'createTogetherAI',
|
|
73
|
+
defaultModel: 'zai-org/GLM-5',
|
|
74
|
+
envVar: 'TOGETHER_API_KEY',
|
|
75
|
+
},
|
|
76
|
+
fireworks: {
|
|
77
|
+
vendor: 'fireworks',
|
|
78
|
+
package: '@ai-sdk/fireworks',
|
|
79
|
+
factory: 'createFireworks',
|
|
80
|
+
defaultModel: 'accounts/fireworks/models/glm-5p2',
|
|
81
|
+
envVar: 'FIREWORKS_API_KEY',
|
|
82
|
+
},
|
|
83
|
+
cohere: {
|
|
84
|
+
vendor: 'cohere',
|
|
85
|
+
package: '@ai-sdk/cohere',
|
|
86
|
+
factory: 'createCohere',
|
|
87
|
+
defaultModel: 'command-a-reasoning-08-2025',
|
|
88
|
+
envVar: 'COHERE_API_KEY',
|
|
89
|
+
},
|
|
90
|
+
perplexity: {
|
|
91
|
+
vendor: 'perplexity',
|
|
92
|
+
package: '@ai-sdk/perplexity',
|
|
93
|
+
factory: 'createPerplexity',
|
|
94
|
+
defaultModel: 'sonar-reasoning-pro',
|
|
95
|
+
envVar: 'PERPLEXITY_API_KEY',
|
|
96
|
+
},
|
|
97
|
+
alibaba: {
|
|
98
|
+
vendor: 'alibaba',
|
|
99
|
+
package: '@ai-sdk/alibaba',
|
|
100
|
+
factory: 'createAlibaba',
|
|
101
|
+
defaultModel: 'qwen3-max',
|
|
102
|
+
envVar: 'ALIBABA_API_KEY',
|
|
103
|
+
},
|
|
104
|
+
openrouter: {
|
|
105
|
+
vendor: 'openrouter',
|
|
106
|
+
package: '@openrouter/ai-sdk-provider',
|
|
107
|
+
factory: 'createOpenRouter',
|
|
108
|
+
defaultModel: 'anthropic/claude-sonnet-5',
|
|
109
|
+
envVar: 'OPENROUTER_API_KEY',
|
|
110
|
+
},
|
|
111
|
+
ollama: {
|
|
112
|
+
vendor: 'ollama',
|
|
113
|
+
package: 'ollama-ai-provider',
|
|
114
|
+
factory: 'createOllama',
|
|
115
|
+
defaultModel: 'llama3.3',
|
|
116
|
+
envVar: '',
|
|
117
|
+
defaultBaseUrl: 'http://localhost:11434/v1',
|
|
118
|
+
},
|
|
119
|
+
'openai-compatible': {
|
|
120
|
+
vendor: 'openai-compatible',
|
|
121
|
+
package: '@ai-sdk/openai',
|
|
122
|
+
factory: 'createOpenAI',
|
|
123
|
+
defaultModel: '',
|
|
124
|
+
envVar: '',
|
|
125
|
+
isOpenAiCompatible: true,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
/** Resolve a provider instance via dynamic import. Throws clear error if
|
|
129
|
+
* the package is missing (optionalDependencies pattern — mirrors how
|
|
130
|
+
* opencode-runner and kimicode-runner handle missing SDK packages). */
|
|
131
|
+
export async function loadVercelProvider(def, apiKey, baseUrl) {
|
|
132
|
+
// Hold the specifier in a variable so TypeScript types the result as `any`
|
|
133
|
+
// and does NOT try to resolve (and fail on) the missing module at compile
|
|
134
|
+
// time — same pattern as opencode-runner.ts for @opencode-ai/sdk.
|
|
135
|
+
const pkgSpec = def.package;
|
|
136
|
+
let mod;
|
|
137
|
+
try {
|
|
138
|
+
mod = await import(/* @vite-ignore */ pkgSpec);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
throw new Error(`VercelAgentRunner: vendor "${def.vendor}" requires the "${def.package}" package. ` +
|
|
142
|
+
`Install it: npm install ${def.package}`);
|
|
143
|
+
}
|
|
144
|
+
const factory = mod[def.factory];
|
|
145
|
+
if (!factory)
|
|
146
|
+
throw new Error(`VercelAgentRunner: ${def.package} does not export ${def.factory}`);
|
|
147
|
+
const opts = {};
|
|
148
|
+
if (apiKey)
|
|
149
|
+
opts.apiKey = apiKey;
|
|
150
|
+
const effectiveBaseUrl = baseUrl ?? def.defaultBaseUrl;
|
|
151
|
+
if (effectiveBaseUrl)
|
|
152
|
+
opts.baseURL = effectiveBaseUrl;
|
|
153
|
+
const provider = factory(opts);
|
|
154
|
+
// For OpenAI-compatible providers serving custom endpoints (GLM, Ollama,
|
|
155
|
+
// arbitrary OpenAI-compatible APIs), use .chat() factory — these endpoints
|
|
156
|
+
// typically only implement Chat Completions, not the Responses API.
|
|
157
|
+
if (def.isOpenAiCompatible && typeof provider.chat === 'function') {
|
|
158
|
+
return (modelId) => provider.chat(modelId);
|
|
159
|
+
}
|
|
160
|
+
return (modelId) => provider(modelId);
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=vercel-providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel-providers.js","sourceRoot":"","sources":["../../../src/orgrt/vercel-providers.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;;;;GAOG;AAkBH,MAAM,CAAC,MAAM,gBAAgB,GAAsC;IACjE,MAAM,EAAE;QACN,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,gBAAgB;QACzB,OAAO,EAAE,cAAc;QACvB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|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VercelAgentRunner — AgentRunner impl backed by the Vercel AI SDK.
|
|
3
|
+
*
|
|
4
|
+
* Architecture: unlike Claude/Kimi/Codex which spawn subprocess binaries or
|
|
5
|
+
* run the whole agent loop in-process via vendor SDKs, Vercel SDK is a thin
|
|
6
|
+
* HTTP client over each vendor's native API. We compose the agent loop
|
|
7
|
+
* manually via streamText + stopWhen: isStepCount(N), per Vercel v7 docs.
|
|
8
|
+
*
|
|
9
|
+
* Critical design decisions (see plan review §1-4):
|
|
10
|
+
* 1. Session resume: Vercel is stateless; we persist messages to disk via
|
|
11
|
+
* VercelSessionStore and reload on resume.
|
|
12
|
+
* 2. Tool policy: every tool's execute() wraps args.canUseTool — bypassing
|
|
13
|
+
* it would defeat the per-role policy engine (denyTools, file scope, etc.)
|
|
14
|
+
* 3. Cost: Vercel returns token usage but no USD; we yield cost_usd: 0
|
|
15
|
+
* (documented). Token budgets still enforce via policy.ts.
|
|
16
|
+
* 4. Mailbox consumption: Vercel's streamText takes a single prompt, not an
|
|
17
|
+
* async iterable. We loop over args.prompt, running one streamText per
|
|
18
|
+
* mailbox message and accumulating into messages[].
|
|
19
|
+
*
|
|
20
|
+
* Streaming asymmetry (documented): Vercel yields per-token text-delta events
|
|
21
|
+
* (real-time token streaming), while the Codex runner yields whole
|
|
22
|
+
* agent_message items at once. This matches each vendor's native behavior.
|
|
23
|
+
*/
|
|
24
|
+
import type { AgentRunner, AgentRunArgs, AgentMessage } from './agent-runner.js';
|
|
25
|
+
export interface VercelRunnerArgs extends AgentRunArgs {
|
|
26
|
+
/** Vendor slug from the provider config (e.g. 'glm', 'openai', 'deepseek'). */
|
|
27
|
+
vendor?: string;
|
|
28
|
+
/** Full provider config from the role definition. */
|
|
29
|
+
providerConfig?: {
|
|
30
|
+
kind?: string;
|
|
31
|
+
vendor?: string;
|
|
32
|
+
apiKeyEnv?: string;
|
|
33
|
+
baseUrl?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export declare class VercelAgentRunner implements AgentRunner {
|
|
37
|
+
run(args: VercelRunnerArgs): AsyncIterable<AgentMessage>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=vercel-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel-runner.d.ts","sourceRoot":"","sources":["../../../src/orgrt/vercel-runner.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjF,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,cAAc,CAAC,EAAE;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,qBAAa,iBAAkB,YAAW,WAAW;IAC5C,GAAG,CAAC,IAAI,EAAE,gBAAgB,GAAG,aAAa,CAAC,YAAY,CAAC,CAkI9D;CACF"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { loadVercelProvider, VERCEL_PROVIDERS } from './vercel-providers.js';
|
|
2
|
+
import { VercelSessionStore } from './vercel-session-store.js';
|
|
3
|
+
export class VercelAgentRunner {
|
|
4
|
+
async *run(args) {
|
|
5
|
+
const vendor = args.vendor ?? args.providerConfig?.vendor ?? 'openai';
|
|
6
|
+
const def = VERCEL_PROVIDERS[vendor];
|
|
7
|
+
if (!def)
|
|
8
|
+
throw new Error(`VercelAgentRunner: unknown vendor "${vendor}"`);
|
|
9
|
+
// Resolve API key from the named env var (inherited via process.env)
|
|
10
|
+
const envVarName = args.providerConfig?.apiKeyEnv ?? def.envVar;
|
|
11
|
+
const apiKey = envVarName
|
|
12
|
+
? (args.env[envVarName] ?? process.env[envVarName])
|
|
13
|
+
: undefined;
|
|
14
|
+
const baseUrl = args.providerConfig?.baseUrl ?? def.defaultBaseUrl;
|
|
15
|
+
// Dynamic import — fails with clear error if package missing
|
|
16
|
+
const modelFactory = await loadVercelProvider(def, apiKey, baseUrl);
|
|
17
|
+
const modelId = args.model ?? def.defaultModel;
|
|
18
|
+
if (!modelId) {
|
|
19
|
+
throw new Error(`VercelAgentRunner: no model specified for vendor "${vendor}". ` +
|
|
20
|
+
`Set adapter_config.model in the role definition.`);
|
|
21
|
+
}
|
|
22
|
+
const model = modelFactory(modelId);
|
|
23
|
+
// Dynamic import of the Vercel AI SDK core. Specifier held in a variable
|
|
24
|
+
// so TypeScript types the result as `any` and does NOT try to resolve
|
|
25
|
+
// (and fail on) the missing module at compile time.
|
|
26
|
+
const aiSpec = 'ai';
|
|
27
|
+
let streamText, tool, isStepCount;
|
|
28
|
+
try {
|
|
29
|
+
const ai = await import(/* @vite-ignore */ aiSpec);
|
|
30
|
+
streamText = ai.streamText;
|
|
31
|
+
tool = ai.tool;
|
|
32
|
+
isStepCount = ai.isStepCount;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
throw new Error('VercelAgentRunner requires the "ai" package. Install it: npm install ai');
|
|
36
|
+
}
|
|
37
|
+
// Session store for resume — org dir is set by session.ts via env
|
|
38
|
+
const orgDir = args.env.MONOMIND_ORG_DIR ?? args.cwd;
|
|
39
|
+
const roleId = args.env.MONOMIND_ROLE_ID ?? 'default';
|
|
40
|
+
const store = new VercelSessionStore(orgDir, roleId, args.resume);
|
|
41
|
+
let messages = await store.load();
|
|
42
|
+
// Build tools with policy gating — CRITICAL: every execute() must call
|
|
43
|
+
// canUseTool before running the handler, otherwise denyTools / file scope
|
|
44
|
+
// / fence guardrails are all silently bypassed.
|
|
45
|
+
const buildTools = () => {
|
|
46
|
+
const vercelTools = {};
|
|
47
|
+
for (const t of args.tools) {
|
|
48
|
+
vercelTools[t.name] = tool({
|
|
49
|
+
description: t.description,
|
|
50
|
+
inputSchema: t.schema,
|
|
51
|
+
execute: async (input) => {
|
|
52
|
+
if (args.canUseTool) {
|
|
53
|
+
const decision = await args.canUseTool(t.name, input);
|
|
54
|
+
if (decision && typeof decision === 'object' && 'behavior' in decision) {
|
|
55
|
+
if (decision.behavior === 'deny') {
|
|
56
|
+
throw new Error(`Tool ${t.name} denied by policy: ${decision.message ?? 'no reason'}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (decision === false) {
|
|
60
|
+
throw new Error(`Tool ${t.name} denied by policy`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return (await t.handler(input)).text;
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return vercelTools;
|
|
68
|
+
};
|
|
69
|
+
// Mailbox turn-loop: streamText takes one prompt at a time. The mailbox
|
|
70
|
+
// (args.prompt) is an async iterable of incoming messages; we consume
|
|
71
|
+
// each one, run a full streamText turn, and accumulate history.
|
|
72
|
+
try {
|
|
73
|
+
for await (const userMsg of args.prompt) {
|
|
74
|
+
const userText = typeof userMsg === 'string'
|
|
75
|
+
? userMsg
|
|
76
|
+
: (userMsg?.message?.content ?? String(userMsg ?? ''));
|
|
77
|
+
messages.push({ role: 'user', content: userText });
|
|
78
|
+
const result = streamText({
|
|
79
|
+
model,
|
|
80
|
+
system: args.systemPrompt,
|
|
81
|
+
messages: messages.map(m => ({ role: m.role, content: m.content })),
|
|
82
|
+
tools: buildTools(),
|
|
83
|
+
stopWhen: isStepCount(args.maxTurns),
|
|
84
|
+
});
|
|
85
|
+
let assistantText = '';
|
|
86
|
+
for await (const part of result.fullStream) {
|
|
87
|
+
if (part.type === 'text-delta') {
|
|
88
|
+
assistantText += part.textDelta;
|
|
89
|
+
yield { type: 'assistant', session_id: store.sessionId, text: part.textDelta };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
messages.push({ role: 'assistant', content: assistantText });
|
|
93
|
+
await store.save(messages);
|
|
94
|
+
// Vercel SDK v4+: `result.usage` is a Promise that resolves only AFTER
|
|
95
|
+
// the stream completes. Awaiting it here (post-fullStream drain) gives
|
|
96
|
+
// the real token counts; without the await, `.totalInputTokens` would
|
|
97
|
+
// be undefined and budgets would silently never enforce.
|
|
98
|
+
const usage = await result.usage;
|
|
99
|
+
// Yield token usage; cost_usd: 0 (Vercel returns no USD; documented —
|
|
100
|
+
// token budgets still enforce via policy.ts).
|
|
101
|
+
yield {
|
|
102
|
+
type: 'result',
|
|
103
|
+
session_id: store.sessionId,
|
|
104
|
+
subtype: 'success',
|
|
105
|
+
input_tokens: usage?.totalInputTokens ?? 0,
|
|
106
|
+
output_tokens: usage?.totalOutputTokens ?? 0,
|
|
107
|
+
cost_usd: 0,
|
|
108
|
+
is_error: false,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
if (err.code === 'MODULE_NOT_FOUND') {
|
|
114
|
+
throw new Error(`VercelAgentRunner requires the "${def.package}" package and "ai". ` +
|
|
115
|
+
`Install them: npm install ai ${def.package}`);
|
|
116
|
+
}
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=vercel-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel-runner.js","sourceRoot":"","sources":["../../../src/orgrt/vercel-runner.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAc/D,MAAM,OAAO,iBAAiB;IAC5B,KAAK,CAAC,CAAC,GAAG,CAAC,IAAsB;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,c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
export declare class VercelSessionStore {
|
|
6
|
+
readonly sessionId: string;
|
|
7
|
+
private readonly filePath;
|
|
8
|
+
constructor(orgDir: string, roleId: string, sessionId?: string);
|
|
9
|
+
load(): Promise<VercelMessage[]>;
|
|
10
|
+
save(messages: VercelMessage[]): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=vercel-session-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel-session-store.d.ts","sourceRoot":"","sources":["../../../src/orgrt/vercel-session-store.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,kBAAkB;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAElC,YAAY,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAK7D;IAEK,IAAI,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAOrC;IAEK,IAAI,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAQnD;CACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// packages/@monomind/cli/src/orgrt/vercel-session-store.ts
|
|
2
|
+
/**
|
|
3
|
+
* VercelSessionStore — persists Vercel conversation history for resume.
|
|
4
|
+
*
|
|
5
|
+
* The Vercel AI SDK is stateless: streamText/generateText don't persist
|
|
6
|
+
* conversation history server-side (unlike Claude Agent SDK's session ID).
|
|
7
|
+
* To support checkpoint/resume, we serialize the message array to disk and
|
|
8
|
+
* reload it on the next run when a session ID is provided.
|
|
9
|
+
*
|
|
10
|
+
* Session IDs are role-scoped and stable: a new UUID is minted per role per
|
|
11
|
+
* org (not per result), persisted in the filename, and reused across restarts
|
|
12
|
+
* via the `resume` argument. This matches the AgentRunner contract where
|
|
13
|
+
* session.ts carries `resumeSessionId` across maxTurns restarts and
|
|
14
|
+
* checkpoint-ops.ts persists it to `runtime.json`.
|
|
15
|
+
*/
|
|
16
|
+
import * as fs from 'node:fs';
|
|
17
|
+
import * as path from 'node:path';
|
|
18
|
+
import * as crypto from 'node:crypto';
|
|
19
|
+
/** Cap to prevent unbounded growth; oldest non-system messages dropped. */
|
|
20
|
+
const MAX_MESSAGES = 200;
|
|
21
|
+
export class VercelSessionStore {
|
|
22
|
+
sessionId;
|
|
23
|
+
filePath;
|
|
24
|
+
constructor(orgDir, roleId, sessionId) {
|
|
25
|
+
this.sessionId = sessionId ?? `${roleId}-${crypto.randomUUID()}`;
|
|
26
|
+
const sessionsDir = path.join(orgDir, 'sessions');
|
|
27
|
+
fs.mkdirSync(sessionsDir, { recursive: true });
|
|
28
|
+
this.filePath = path.join(sessionsDir, `${this.sessionId}.json`);
|
|
29
|
+
}
|
|
30
|
+
async load() {
|
|
31
|
+
try {
|
|
32
|
+
const data = await fs.promises.readFile(this.filePath, 'utf8');
|
|
33
|
+
return JSON.parse(data);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async save(messages) {
|
|
40
|
+
const trimmed = messages.length > MAX_MESSAGES
|
|
41
|
+
? [
|
|
42
|
+
...messages.filter(m => m.role === 'system'),
|
|
43
|
+
...messages.filter(m => m.role !== 'system').slice(-(MAX_MESSAGES - 1)),
|
|
44
|
+
]
|
|
45
|
+
: messages;
|
|
46
|
+
await fs.promises.writeFile(this.filePath, JSON.stringify(trimmed, null, 2));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=vercel-session-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel-session-store.js","sourceRoot":"","sources":["../../../src/orgrt/vercel-session-store.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AG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;aACxE;YACH,CAAC,CAAC,QAAQ,CAAC;QACb,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/E,CAAC;CACF"}
|
|
@@ -16,7 +16,16 @@ export interface ModelPrice {
|
|
|
16
16
|
cw: number;
|
|
17
17
|
cr: number;
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Canonical pricing map — union of all models across every pricing table in
|
|
21
|
+
* this repo (this file, src/ui/collector.mjs, src/ui/server.mjs, and
|
|
22
|
+
* .claude/helpers/token-tracker.cjs). Those four are plain JS/CJS that
|
|
23
|
+
* cannot `import` this `.ts` module directly, so they carry their own
|
|
24
|
+
* hand-synced copies of this table; `tests/*-pricing-parity.test.ts` (or
|
|
25
|
+
* the equivalent per-package test) asserts they all cover the same model
|
|
26
|
+
* *set* so a newly added model here doesn't quietly stay unpriced in the
|
|
27
|
+
* others.
|
|
28
|
+
*/
|
|
20
29
|
export declare const MODEL_PRICING: Record<string, ModelPrice>;
|
|
21
30
|
/**
|
|
22
31
|
* Canonical default model IDs — single source of truth for code that needs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-pricing.d.ts","sourceRoot":"","sources":["../../../src/pricing/model-pricing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAG,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAG,MAAM,CAAC;IACZ,EAAE,EAAG,MAAM,CAAC;CACb;AAED
|
|
1
|
+
{"version":3,"file":"model-pricing.d.ts","sourceRoot":"","sources":["../../../src/pricing/model-pricing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAG,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAG,MAAM,CAAC;IACZ,EAAE,EAAG,MAAM,CAAC;CACb;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CA6BpD,CAAC;AASF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;IACzB,yCAAyC;aACzC,KAAK,EAAuB,MAAM;IAClC,kDAAkD;aAClD,MAAM,EAAsB,MAAM;IAClC,wCAAwC;aACxC,IAAI,EAAwB,MAAM;CAC1B,CAAC;AAEX;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAShE"}
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Canonical pricing map — union of all models across every pricing table in
|
|
3
|
+
* this repo (this file, src/ui/collector.mjs, src/ui/server.mjs, and
|
|
4
|
+
* .claude/helpers/token-tracker.cjs). Those four are plain JS/CJS that
|
|
5
|
+
* cannot `import` this `.ts` module directly, so they carry their own
|
|
6
|
+
* hand-synced copies of this table; `tests/*-pricing-parity.test.ts` (or
|
|
7
|
+
* the equivalent per-package test) asserts they all cover the same model
|
|
8
|
+
* *set* so a newly added model here doesn't quietly stay unpriced in the
|
|
9
|
+
* others.
|
|
10
|
+
*/
|
|
2
11
|
export const MODEL_PRICING = {
|
|
12
|
+
// ── Frontier (Fable/Mythos) ────────────────────────────────────────────────
|
|
13
|
+
'claude-fable-5': { in: 10e-6, out: 50e-6, cw: 12.5e-6, cr: 1e-6 },
|
|
14
|
+
'claude-mythos-5': { in: 10e-6, out: 50e-6, cw: 12.5e-6, cr: 1e-6 },
|
|
3
15
|
// ── Opus ────────────────────────────────────────────────────────────────────
|
|
16
|
+
'claude-opus-5': { in: 5e-6, out: 25e-6, cw: 6.25e-6, cr: 0.5e-6 },
|
|
4
17
|
'claude-opus-4-8': { in: 5e-6, out: 25e-6, cw: 6.25e-6, cr: 0.5e-6 },
|
|
18
|
+
'claude-opus-4-7': { in: 5e-6, out: 25e-6, cw: 6.25e-6, cr: 0.5e-6 },
|
|
5
19
|
'claude-opus-4-6': { in: 5e-6, out: 25e-6, cw: 6.25e-6, cr: 0.5e-6 },
|
|
6
20
|
'claude-opus-4-5': { in: 5e-6, out: 25e-6, cw: 6.25e-6, cr: 0.5e-6 },
|
|
21
|
+
'claude-opus-4-1': { in: 15e-6, out: 75e-6, cw: 18.75e-6, cr: 1.5e-6 },
|
|
7
22
|
'claude-opus-4': { in: 15e-6, out: 75e-6, cw: 18.75e-6, cr: 1.5e-6 },
|
|
8
23
|
// ── Sonnet ──────────────────────────────────────────────────────────────────
|
|
24
|
+
'claude-sonnet-5': { in: 3e-6, out: 15e-6, cw: 3.75e-6, cr: 0.3e-6 },
|
|
9
25
|
'claude-sonnet-4-6': { in: 3e-6, out: 15e-6, cw: 3.75e-6, cr: 0.3e-6 },
|
|
10
26
|
'claude-sonnet-4-5': { in: 3e-6, out: 15e-6, cw: 3.75e-6, cr: 0.3e-6 },
|
|
11
27
|
'claude-sonnet-4': { in: 3e-6, out: 15e-6, cw: 3.75e-6, cr: 0.3e-6 },
|
|
@@ -16,6 +32,7 @@ export const MODEL_PRICING = {
|
|
|
16
32
|
'claude-haiku-4': { in: 0.8e-6, out: 4e-6, cw: 1e-6, cr: 0.08e-6 },
|
|
17
33
|
'claude-3-5-haiku': { in: 0.8e-6, out: 4e-6, cw: 1e-6, cr: 0.08e-6 },
|
|
18
34
|
// ── OpenAI ──────────────────────────────────────────────────────────────────
|
|
35
|
+
'gpt-5': { in: 2.5e-6, out: 10e-6, cw: 2.5e-6, cr: 1.25e-6 },
|
|
19
36
|
'gpt-4o': { in: 2.5e-6, out: 10e-6, cw: 2.5e-6, cr: 1.25e-6 },
|
|
20
37
|
'gpt-4o-mini': { in: 0.15e-6, out: 0.6e-6, cw: 0.15e-6, cr: 0.075e-6 },
|
|
21
38
|
// ── Google ──────────────────────────────────────────────────────────────────
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-pricing.js","sourceRoot":"","sources":["../../../src/pricing/model-pricing.ts"],"names":[],"mappings":"AAmBA
|
|
1
|
+
{"version":3,"file":"model-pricing.js","sourceRoot":"","sources":["../../../src/pricing/model-pricing.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAA+B;IACvD,8EAA8E;IAC9E,gBAAgB,EAAK,EAAE,EAAE,EAAE,KAAK,EAAI,GAAG,EAAE,KAAK,EAAI,EAAE,EAAE,OAAO,EAAG,EAAE,EAAE,IAAI,EAAM;IAC9E,iBAAiB,EAAI,EAAE,EAAE,EAAE,KAAK,EAAI,GAAG,EAAE,KAAK,EAAI,EAAE,EAAE,OAAO,EAAG,EAAE,EAAE,IAAI,EAAM;IAC9E,+EAA+E;IAC/E,eAAe,EAAM,EAAE,EAAE,EAAE,IAAI,EAAK,GAAG,EAAE,KAAK,EAAI,EAAE,EAAE,OAAO,EAAG,EAAE,EAAE,MAAM,EAAI;IAC9E,iBAAiB,EAAI,EAAE,EAAE,EAAE,IAAI,EAAK,GAAG,EAAE,KAAK,EAAI,EAAE,EAAE,OAAO,EAAG,EAAE,EAAE,MAAM,EAAI;IAC9E,iBAAiB,EAAI,EAAE,EAAE,EAAE,IAAI,EAAK,GAAG,EAAE,KAAK,EAAI,EAAE,EAAE,OAAO,EAAG,EAAE,EAAE,MAAM,EAAI;IAC9E,iBAAiB,EAAI,EAAE,EAAE,EAAE,IAAI,EAAK,GAAG,EAAE,KAAK,EAAI,EAAE,EAAE,OAAO,EAAG,EAAE,EAAE,MAAM,EAAI;IAC9E,iBAAiB,EAAI,EAAE,EAAE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