@ghostmind-dev/agent 0.1.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/README.md +141 -0
- package/dist/budget.d.ts +39 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +34 -0
- package/dist/budget.js.map +1 -0
- package/dist/consult.d.ts +25 -0
- package/dist/consult.d.ts.map +1 -0
- package/dist/consult.js +80 -0
- package/dist/consult.js.map +1 -0
- package/dist/events.d.ts +119 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +24 -0
- package/dist/events.js.map +1 -0
- package/dist/guide.d.ts +103 -0
- package/dist/guide.d.ts.map +1 -0
- package/dist/guide.js +268 -0
- package/dist/guide.js.map +1 -0
- package/dist/hooks.d.ts +80 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +56 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/jev.d.ts +74 -0
- package/dist/jev.d.ts.map +1 -0
- package/dist/jev.js +82 -0
- package/dist/jev.js.map +1 -0
- package/dist/loop.d.ts +142 -0
- package/dist/loop.d.ts.map +1 -0
- package/dist/loop.js +550 -0
- package/dist/loop.js.map +1 -0
- package/dist/model.d.ts +173 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +205 -0
- package/dist/model.js.map +1 -0
- package/dist/seams.d.ts +137 -0
- package/dist/seams.d.ts.map +1 -0
- package/dist/seams.js +45 -0
- package/dist/seams.js.map +1 -0
- package/dist/skills.d.ts +36 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +168 -0
- package/dist/skills.js.map +1 -0
- package/dist/testing.d.ts +36 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +60 -0
- package/dist/testing.js.map +1 -0
- package/dist/tools.d.ts +114 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +136 -0
- package/dist/tools.js.map +1 -0
- package/package.json +50 -0
package/dist/jev.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** The work so far as a compact log for Jev — the last steps weigh most. */
|
|
2
|
+
export function workLog(messages) {
|
|
3
|
+
const firstTask = messages.findIndex(m => m.role === 'user' && m.content.startsWith('Task: '));
|
|
4
|
+
return messages
|
|
5
|
+
.slice(Math.max(0, firstTask))
|
|
6
|
+
.filter(m => m.role !== 'system')
|
|
7
|
+
.slice(-24)
|
|
8
|
+
.map(m => {
|
|
9
|
+
if (m.role === 'tool')
|
|
10
|
+
return { tool_result: m.content.slice(0, 4000) };
|
|
11
|
+
if (m.role === 'assistant')
|
|
12
|
+
return { agent: m.content?.slice(0, 1500) ?? null, calls: m.tool_calls?.map(c => `${c.function.name}(${c.function.arguments.slice(0, 300)})`) };
|
|
13
|
+
return { [m.role]: m.content.slice(0, 500) };
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The answer checks from Potion's dropped verdict node, minus the one Jev is documented to be bad at:
|
|
18
|
+
* "is every fact and number supported by the work" asks it to compare figures across a long
|
|
19
|
+
* transcript (counting, numbers and long context are its jaggedness). Keep questions atomic.
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_CHECKS = {
|
|
22
|
+
answers_every_part: { question: 'Does `final_answer` address every part of `task.goal`?', feedback: 'Part of the request is not answered.' },
|
|
23
|
+
expected_form: { question: 'Is `final_answer` in the form `task.expectation` describes?', feedback: 'The answer is not in the expected form: re-read the expected output.' },
|
|
24
|
+
};
|
|
25
|
+
/** A stopCheck that sends the worker back when Jev finds the answer falls short. */
|
|
26
|
+
export function jevStopCheck(provider, checks = DEFAULT_CHECKS) {
|
|
27
|
+
if (!provider.decide)
|
|
28
|
+
throw new Error('jevStopCheck needs a ModelProvider with decide().');
|
|
29
|
+
const decide = provider.decide.bind(provider);
|
|
30
|
+
return async (ctx) => {
|
|
31
|
+
const questions = Object.fromEntries(Object.entries(checks).map(([id, c]) => [id, { type: 'noul', instructions: c.question }]));
|
|
32
|
+
// Short context on purpose: the task and the answer, plus only the last few steps of work.
|
|
33
|
+
const state = { task: { goal: ctx.task.goal, expectation: ctx.task.expectation }, final_answer: (ctx.answer ?? '').slice(0, 2000), work: workLog(ctx.messages).slice(-6) };
|
|
34
|
+
try {
|
|
35
|
+
const { answers, cost } = await decide(state, questions);
|
|
36
|
+
ctx.spend(cost, 'jevStopCheck');
|
|
37
|
+
const failed = Object.entries(checks)
|
|
38
|
+
.filter(([id, c]) => {
|
|
39
|
+
const a = answers[id];
|
|
40
|
+
return a?.type === 'noul' && a.noul < (c.min ?? 0.5);
|
|
41
|
+
})
|
|
42
|
+
.map(([, c]) => c.feedback);
|
|
43
|
+
if (failed.length)
|
|
44
|
+
return { verdict: 'go', reason: `${failed.join(' ')} Fix it and reply with the corrected answer.` };
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// No answer is not a failed check: the stop stands.
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** A toolGate where Jev judges whether a call serves the person's goal. */
|
|
52
|
+
export function jevToolGate(provider, options = {}) {
|
|
53
|
+
if (!provider.decide)
|
|
54
|
+
throw new Error('jevToolGate needs a ModelProvider with decide().');
|
|
55
|
+
const decide = provider.decide.bind(provider);
|
|
56
|
+
const question = options.question ?? 'Does calling `tool` with `args` (the change: `change`) serve what the person asked in `goal`, and nothing they did not ask for?';
|
|
57
|
+
const min = options.min ?? 0.3;
|
|
58
|
+
return async (ctx) => {
|
|
59
|
+
if (!options.everyCall && ctx.change === null)
|
|
60
|
+
return;
|
|
61
|
+
try {
|
|
62
|
+
const { answers, cost } = await decide({ goal: ctx.task.goal, tool: ctx.tool, args: ctx.args, change: ctx.change }, { serves: { type: 'noul', instructions: question } });
|
|
63
|
+
ctx.spend(cost, 'jevToolGate');
|
|
64
|
+
const a = answers.serves;
|
|
65
|
+
if (a?.type !== 'noul' || a.noul >= min)
|
|
66
|
+
return;
|
|
67
|
+
const reason = `Jev judged ${ctx.tool} unlikely to serve the request (p=${a.noul.toFixed(2)}).`;
|
|
68
|
+
return options.below === 'refuse' ? { verdict: 'go', reason, result: `Refused: ${reason} Do what the person asked, or ask them.` } : { verdict: 'pause', reason };
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// No answer: the gate does not act on a guess.
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** Ask Jev one question outside the loop — a convenience with the same cost accounting. */
|
|
76
|
+
export async function ask(provider, state, question, signal) {
|
|
77
|
+
if (!provider.decide)
|
|
78
|
+
throw new Error('This provider cannot decide');
|
|
79
|
+
const { answers, cost } = await provider.decide(state, { q: question }, signal);
|
|
80
|
+
return { answer: answers.q, cost };
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=jev.js.map
|
package/dist/jev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jev.js","sourceRoot":"","sources":["../src/jev.ts"],"names":[],"mappings":"AA0BA,4EAA4E;AAC5E,MAAM,UAAU,OAAO,CAAC,QAAgC;IACtD,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/F,OAAO,QAAQ;SACZ,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;SAC7B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;SAChC,KAAK,CAAC,CAAC,EAAE,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE;QACP,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO,EAAE,WAAW,EAAE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C,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;YAChG,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,MAAM,yCAAyC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QACpK,CAAC;QAAC,MAAM,CAAC;YACP,+CAA+C;QACjD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,QAAuB,EAAE,KAAc,EAAE,QAAkB,EAAE,MAAoB;IACzG,IAAI,CAAC,QAAQ,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACrE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;IAChF,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;AACrC,CAAC"}
|
package/dist/loop.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The loop — the hard part every app's agent shares.
|
|
3
|
+
*
|
|
4
|
+
* One worker model does the work; the loop keeps it honest and bounded. Ported from Potion's Talk,
|
|
5
|
+
* where each guard answers a failure its evaluation found:
|
|
6
|
+
*
|
|
7
|
+
* [opening] greeting ─► the app's welcome, no worker · small talk ─► one short reply, no tools · task ─┐
|
|
8
|
+
* │
|
|
9
|
+
* ┌─► [step] budget? beforeStep hook? ─► the worker, offered EVERY tool ◄──────────────────────────┘
|
|
10
|
+
* │ │ (a router offering only some was how a model came to say
|
|
11
|
+
* │ │ "I have no tool for that" about a tool it had — Pi's lesson)
|
|
12
|
+
* │ ▼
|
|
13
|
+
* │ tool calls? ──yes──► toolGate · approval for changes · duplicate guard · run · rewriteOutput ─┐
|
|
14
|
+
* │ │ no, it stopped │
|
|
15
|
+
* │ ▼ │
|
|
16
|
+
* │ post-processors ─► stopCheck: accept (done) · pause (needs_person) · go (nudge, back) ──┐ │
|
|
17
|
+
* └───────────────────────────────────────────────────────────────────────────────────────┴─────┘
|
|
18
|
+
*
|
|
19
|
+
* The guards: step and tool-call caps (the last step answers with tools shown but not callable — how
|
|
20
|
+
* a model is made to answer without it writing tool markup instead), a USD cap, nudges, a transient
|
|
21
|
+
* reminder at the END of the context (weak models hold the thread better from there — Aider), leaked
|
|
22
|
+
* tool-call markup read back into real calls, an empty reply sent back twice then reported, identical
|
|
23
|
+
* reads run once (OpenCode's doom-loop guard), a "you may have enough" note every few reads (Gemini
|
|
24
|
+
* CLI), long results capped, guide reads that give their step back, and a declined change that ends
|
|
25
|
+
* the run on the person's move rather than being retried.
|
|
26
|
+
*
|
|
27
|
+
* Two models, two jobs. The WORKER writes, plans and calls tools. JEV decides: it answers typed
|
|
28
|
+
* questions with calibrated probabilities, never prose, at a fraction of a cent — so the loop asks it
|
|
29
|
+
* wherever a step is a judgement rather than a generation: is there a task at all ([opening]), which
|
|
30
|
+
* skills does it need, and — offered to the worker at every step as `ask_jev` — which existing option
|
|
31
|
+
* fits, is this a duplicate, how relevant is this. An app can put Jev behind the hooks too
|
|
32
|
+
* (`jevStopCheck`, `jevToolGate` in jev.ts). With a provider that cannot decide, all of that is
|
|
33
|
+
* skipped and the loop still runs.
|
|
34
|
+
*
|
|
35
|
+
* By default nothing judges the worker after it stops (Pi: the model decides). What can send it
|
|
36
|
+
* back is a `stopCheck` hook — a code check an app owns ("every id linked in the answer came from a
|
|
37
|
+
* tool"), or Jev's checks.
|
|
38
|
+
*/
|
|
39
|
+
import { type Budget } from './budget.ts';
|
|
40
|
+
import { type Guidance, type GuideOptions } from './guide.ts';
|
|
41
|
+
import type { AgentEvent, EventLog } from './events.ts';
|
|
42
|
+
import { type Hooks } from './hooks.ts';
|
|
43
|
+
import type { ChatMessage, ModelProvider, ToolCall } from './model.ts';
|
|
44
|
+
import { type AgentResult, type AgentTask, type Approve, type MemoryStore, type PostProcessor, type PromptPack, type SessionStore, type SkillSource } from './seams.ts';
|
|
45
|
+
import { type AgentTool, type Toolset } from './tools.ts';
|
|
46
|
+
export interface AgentOptions {
|
|
47
|
+
/** The model seam: `openrouter()` in an app, `scriptedModel()` in a test. */
|
|
48
|
+
provider: ModelProvider;
|
|
49
|
+
task: AgentTask;
|
|
50
|
+
/** The worker model id. Default: the provider's. */
|
|
51
|
+
model?: string;
|
|
52
|
+
toolsets?: Toolset[];
|
|
53
|
+
/** Tools offered at every step besides the toolsets. */
|
|
54
|
+
alwaysTools?: AgentTool[];
|
|
55
|
+
/** Offer `ask_jev` at every step. Default true when the provider can decide. */
|
|
56
|
+
askJev?: boolean;
|
|
57
|
+
/** Replace any of the engine's words. */
|
|
58
|
+
prompts?: Partial<Omit<PromptPack, 'opening'>> & {
|
|
59
|
+
opening?: Partial<PromptPack['opening']>;
|
|
60
|
+
};
|
|
61
|
+
/** The person's standing instructions, below the system rules, never instead of them. */
|
|
62
|
+
instructions?: string | null;
|
|
63
|
+
memory?: MemoryStore;
|
|
64
|
+
/** Earlier turns (no system message). Default: loaded from `session`. */
|
|
65
|
+
history?: ChatMessage[];
|
|
66
|
+
/** Where the conversation is kept: loaded before the run when no `history` is given, saved after. */
|
|
67
|
+
session?: {
|
|
68
|
+
store: SessionStore;
|
|
69
|
+
id: string;
|
|
70
|
+
};
|
|
71
|
+
/** Skills: Jev picks which the task needs; the picked ones become use_skill / read_skill_file. */
|
|
72
|
+
skills?: SkillSource;
|
|
73
|
+
/** Asks the person to approve one change. Without it, every change is refused. */
|
|
74
|
+
approve?: Approve;
|
|
75
|
+
hooks?: Hooks;
|
|
76
|
+
/** Applied in order to the final answer. */
|
|
77
|
+
postProcessors?: PostProcessor[];
|
|
78
|
+
budget?: Budget;
|
|
79
|
+
/** How closely Jev guides the worker at the loop's checkpoints. Default 'auto': from the model, adapted, learned. */
|
|
80
|
+
guidance?: Guidance;
|
|
81
|
+
/** Thresholds and the per-model profile store for the guide. */
|
|
82
|
+
guide?: Omit<GuideOptions, 'guidance'>;
|
|
83
|
+
/** Ask Jev first whether there is a task at all. Default true when the provider can decide. */
|
|
84
|
+
opening?: boolean;
|
|
85
|
+
/** Tools whose calls are preparation: no tool call spent, the step given back. Default: the skill tools. */
|
|
86
|
+
guideTools?: string[];
|
|
87
|
+
/** Stream the worker's text as it is written (`delta` events). */
|
|
88
|
+
stream?: boolean;
|
|
89
|
+
signal?: AbortSignal;
|
|
90
|
+
onEvent?: (event: AgentEvent) => void;
|
|
91
|
+
/** The append-only log: every event, including every message the model saw. */
|
|
92
|
+
log?: EventLog;
|
|
93
|
+
}
|
|
94
|
+
export declare const LEAKED_CALL: RegExp;
|
|
95
|
+
/**
|
|
96
|
+
* Some models (DeepSeek through some providers) write their tool calls as their own markup in the
|
|
97
|
+
* text instead of as structured calls:
|
|
98
|
+
* <||DSML|| invoke name="search"> <||DSML|| parameter name="query" string="true">…</…parameter> </…invoke>
|
|
99
|
+
* That is read back into real calls, so the model still does what it meant; nothing of it is shown.
|
|
100
|
+
*/
|
|
101
|
+
export declare function parseLeakedCalls(text: string): ToolCall[];
|
|
102
|
+
/**
|
|
103
|
+
* Streams text through, but holds back anything that may be the start of tool-call markup until it
|
|
104
|
+
* is clear either way. Once markup is seen, nothing more of this step is shown.
|
|
105
|
+
*/
|
|
106
|
+
export declare function leakFilter(emit: (text: string) => void): {
|
|
107
|
+
push(text: string): void;
|
|
108
|
+
end(): void;
|
|
109
|
+
};
|
|
110
|
+
/** A decision node: one question, two or more paths; each path's text is what Jev reads to choose it. */
|
|
111
|
+
export interface DecisionNode<P extends string> {
|
|
112
|
+
question: string;
|
|
113
|
+
paths: Record<P, string>;
|
|
114
|
+
}
|
|
115
|
+
export interface NodeOutcome<P extends string> {
|
|
116
|
+
path: P;
|
|
117
|
+
/** Every path's probability, highest first. */
|
|
118
|
+
ranked: {
|
|
119
|
+
path: P;
|
|
120
|
+
p: number;
|
|
121
|
+
}[];
|
|
122
|
+
confidence: number;
|
|
123
|
+
cost: number;
|
|
124
|
+
}
|
|
125
|
+
export declare function passNode<P extends string>(provider: ModelProvider, node: DecisionNode<P>, state: unknown, signal?: AbortSignal): Promise<NodeOutcome<P>>;
|
|
126
|
+
export declare function runAgent(options: AgentOptions): Promise<AgentResult>;
|
|
127
|
+
export interface SubagentSpec {
|
|
128
|
+
name: string;
|
|
129
|
+
/** When the parent should hand a task to it. */
|
|
130
|
+
description: string;
|
|
131
|
+
/** What "done" means for this sub-agent. */
|
|
132
|
+
expectation: string;
|
|
133
|
+
/** Everything but the task and the signal; the sub-agent gets its OWN transcript. */
|
|
134
|
+
options: Omit<AgentOptions, 'task' | 'signal' | 'history' | 'session'>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A whole agent as one tool. Its transcript is isolated — the parent sees only the status and the
|
|
138
|
+
* answer, never the sub-agent's tool results — and what it spent is added to the parent's total, so
|
|
139
|
+
* the parent's USD cap covers it.
|
|
140
|
+
*/
|
|
141
|
+
export declare function subagentTool(spec: SubagentSpec): AgentTool;
|
|
142
|
+
//# sourceMappingURL=loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,EAAsB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAe,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAe,KAAK,KAAK,EAAyD,MAAM,YAAY,CAAC;AAC5G,OAAO,KA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