@zenera/neo 1.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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +178 -0
  3. package/dist/agent.d.ts +66 -0
  4. package/dist/agent.js +97 -0
  5. package/dist/architecture.d.ts +74 -0
  6. package/dist/architecture.js +105 -0
  7. package/dist/embedding.d.ts +60 -0
  8. package/dist/embedding.js +21 -0
  9. package/dist/embeddings/gemini.d.ts +24 -0
  10. package/dist/embeddings/gemini.js +71 -0
  11. package/dist/embeddings/index.d.ts +4 -0
  12. package/dist/embeddings/index.js +4 -0
  13. package/dist/embeddings/openai.d.ts +18 -0
  14. package/dist/embeddings/openai.js +27 -0
  15. package/dist/embeddings/openrouter.d.ts +21 -0
  16. package/dist/embeddings/openrouter.js +54 -0
  17. package/dist/events.d.ts +144 -0
  18. package/dist/events.js +110 -0
  19. package/dist/ids.d.ts +14 -0
  20. package/dist/ids.js +33 -0
  21. package/dist/index.d.ts +25 -0
  22. package/dist/index.js +25 -0
  23. package/dist/inspect/client.d.ts +2 -0
  24. package/dist/inspect/client.js +1326 -0
  25. package/dist/inspect/css.d.ts +2 -0
  26. package/dist/inspect/css.js +164 -0
  27. package/dist/inspect/index.d.ts +9 -0
  28. package/dist/inspect/index.js +12 -0
  29. package/dist/inspect/page.d.ts +3 -0
  30. package/dist/inspect/page.js +93 -0
  31. package/dist/inspect/report.d.ts +54 -0
  32. package/dist/inspect/report.js +62 -0
  33. package/dist/kernel.d.ts +178 -0
  34. package/dist/kernel.js +929 -0
  35. package/dist/memory-stores/factory.d.ts +15 -0
  36. package/dist/memory-stores/factory.js +29 -0
  37. package/dist/memory-stores/file.d.ts +37 -0
  38. package/dist/memory-stores/file.js +174 -0
  39. package/dist/memory-stores/in-memory.d.ts +17 -0
  40. package/dist/memory-stores/in-memory.js +80 -0
  41. package/dist/memory-stores/index.d.ts +4 -0
  42. package/dist/memory-stores/index.js +5 -0
  43. package/dist/memory.d.ts +115 -0
  44. package/dist/memory.js +213 -0
  45. package/dist/model.d.ts +25 -0
  46. package/dist/model.js +2 -0
  47. package/dist/models/anthropic.d.ts +36 -0
  48. package/dist/models/anthropic.js +293 -0
  49. package/dist/models/factory.d.ts +202 -0
  50. package/dist/models/factory.js +533 -0
  51. package/dist/models/gemini.d.ts +45 -0
  52. package/dist/models/gemini.js +368 -0
  53. package/dist/models/index.d.ts +7 -0
  54. package/dist/models/index.js +7 -0
  55. package/dist/models/openai-chat.d.ts +19 -0
  56. package/dist/models/openai-chat.js +203 -0
  57. package/dist/models/openai-responses.d.ts +31 -0
  58. package/dist/models/openai-responses.js +258 -0
  59. package/dist/models/openrouter.d.ts +44 -0
  60. package/dist/models/openrouter.js +230 -0
  61. package/dist/payload-stores/factory.d.ts +15 -0
  62. package/dist/payload-stores/factory.js +30 -0
  63. package/dist/payload-stores/file.d.ts +29 -0
  64. package/dist/payload-stores/file.js +112 -0
  65. package/dist/payload-stores/in-memory.d.ts +17 -0
  66. package/dist/payload-stores/in-memory.js +40 -0
  67. package/dist/payload-stores/index.d.ts +4 -0
  68. package/dist/payload-stores/index.js +5 -0
  69. package/dist/payload.d.ts +89 -0
  70. package/dist/payload.js +181 -0
  71. package/dist/project/config.d.ts +302 -0
  72. package/dist/project/config.js +290 -0
  73. package/dist/project/index.d.ts +4 -0
  74. package/dist/project/index.js +4 -0
  75. package/dist/project/load.d.ts +142 -0
  76. package/dist/project/load.js +430 -0
  77. package/dist/project/refs.d.ts +23 -0
  78. package/dist/project/refs.js +70 -0
  79. package/dist/prompt.d.ts +66 -0
  80. package/dist/prompt.js +62 -0
  81. package/dist/runner.d.ts +103 -0
  82. package/dist/runner.js +537 -0
  83. package/dist/services.d.ts +23 -0
  84. package/dist/services.js +44 -0
  85. package/dist/skill-providers/factory.d.ts +16 -0
  86. package/dist/skill-providers/factory.js +26 -0
  87. package/dist/skill-providers/file.d.ts +44 -0
  88. package/dist/skill-providers/file.js +209 -0
  89. package/dist/skill-providers/index.d.ts +4 -0
  90. package/dist/skill-providers/index.js +5 -0
  91. package/dist/skill-providers/static.d.ts +13 -0
  92. package/dist/skill-providers/static.js +47 -0
  93. package/dist/skills.d.ts +102 -0
  94. package/dist/skills.js +232 -0
  95. package/dist/state.d.ts +86 -0
  96. package/dist/state.js +49 -0
  97. package/dist/tools/exa.d.ts +23 -0
  98. package/dist/tools/exa.js +389 -0
  99. package/dist/tools/index.d.ts +4 -0
  100. package/dist/tools/index.js +6 -0
  101. package/dist/tools/sandbox.d.ts +172 -0
  102. package/dist/tools/sandbox.js +602 -0
  103. package/dist/tools/workspace.d.ts +53 -0
  104. package/dist/tools/workspace.js +1034 -0
  105. package/dist/trajectory.d.ts +213 -0
  106. package/dist/trajectory.js +232 -0
  107. package/dist/types.d.ts +195 -0
  108. package/dist/types.js +134 -0
  109. package/package.json +98 -0
@@ -0,0 +1,66 @@
1
+ import type { Payload } from './payload.ts';
2
+ import type { RunSpec } from './state.ts';
3
+ /**
4
+ * A block of prompt text, optionally tagged with where it came from.
5
+ *
6
+ * `path` is metadata, not an instruction to go and read something: the text is
7
+ * already here. It exists so the trajectory can answer "which file do I edit to
8
+ * change this?" — the one question a rendered prompt cannot answer by itself.
9
+ */
10
+ export interface PromptText {
11
+ text: string;
12
+ /** the editable document this text came from, if any */
13
+ path?: string;
14
+ /** opt-in wrapper tag, e.g. `intent` → `<intent>…</intent>` */
15
+ section?: string;
16
+ }
17
+ /**
18
+ * One contributor to a system prompt: literal text, text computed from the run
19
+ * context, or a tagged block (usually a file loaded by `promptFile`).
20
+ *
21
+ * The function form gets `RunSpec`, not `AgentState`, on purpose. The system
22
+ * prompt is the provider's cache prefix; one that varied with mutable state
23
+ * would invalidate that prefix every turn and append a node every turn. A
24
+ * `RunSpec` is fixed at `createState`, so `forkDepth` and the output contract
25
+ * are available while "prompt that grows with the conversation" is not
26
+ * expressible — per-turn content belongs at the tail, as input and results.
27
+ */
28
+ export type PromptPart<TCtx = unknown> = string | ((ctx: TCtx, spec: RunSpec) => string) | PromptText;
29
+ export type Instructions<TCtx = unknown> = string | ((ctx: TCtx, spec: RunSpec) => string) | PromptPart<TCtx>[];
30
+ /**
31
+ * Loads a prompt file and remembers where it came from.
32
+ *
33
+ * Read once, at agent construction, and synchronously: this is setup, the same
34
+ * moment a module is imported or a config parsed, so a bad path fails at
35
+ * startup with a stack trace pointing at the agent — not on the first LLM call
36
+ * of a run in production. It also keeps the prompt genuinely constant for the
37
+ * life of the agent, which is what the provider's cache assumes anyway.
38
+ *
39
+ * A prompt that must change without a restart is a different feature: rebuild
40
+ * the agent, or use the function form.
41
+ */
42
+ export declare function promptFile(path: string, section?: string): PromptText;
43
+ /** A document that fed a prompt, with the exact bytes it contributed. */
44
+ export interface PromptSource {
45
+ path: string;
46
+ content: Payload;
47
+ }
48
+ export interface ComposedPrompt {
49
+ /** exactly what the provider will receive */
50
+ text: string;
51
+ /** the editable contributors, in the order they were rendered */
52
+ sources: PromptSource[];
53
+ }
54
+ /**
55
+ * Renders the authored parts, then the kernel's derived text, into one string —
56
+ * and reports which documents went into it.
57
+ *
58
+ * `derived` (the skill index, the `final_output` instruction) is appended last
59
+ * so the volatile tail never invalidates the cacheable prefix, and it is *not*
60
+ * reported as a source: neither is a file anyone edits.
61
+ *
62
+ * The only async here is `put`: the composer does no I/O of its own, because by
63
+ * this point every part already carries its text.
64
+ */
65
+ export declare function composePrompt<TCtx>(instructions: Instructions<TCtx> | undefined, ctx: TCtx, spec: RunSpec, put: (text: string) => Promise<Payload>, derived?: string[]): Promise<ComposedPrompt>;
66
+ //# sourceMappingURL=prompt.d.ts.map
package/dist/prompt.js ADDED
@@ -0,0 +1,62 @@
1
+ import { readFileSync } from 'node:fs';
2
+ /**
3
+ * Loads a prompt file and remembers where it came from.
4
+ *
5
+ * Read once, at agent construction, and synchronously: this is setup, the same
6
+ * moment a module is imported or a config parsed, so a bad path fails at
7
+ * startup with a stack trace pointing at the agent — not on the first LLM call
8
+ * of a run in production. It also keeps the prompt genuinely constant for the
9
+ * life of the agent, which is what the provider's cache assumes anyway.
10
+ *
11
+ * A prompt that must change without a restart is a different feature: rebuild
12
+ * the agent, or use the function form.
13
+ */
14
+ export function promptFile(path, section) {
15
+ const text = readFileSync(path, 'utf8');
16
+ return section === undefined ? { text, path } : { text, path, section };
17
+ }
18
+ const SEPARATOR = '\n\n';
19
+ /**
20
+ * Markers are opt-in because they are tokens the model reads: a wrapper that
21
+ * "does not influence the content" does not exist for an LLM.
22
+ */
23
+ function wrap(part) {
24
+ return part.section ? `<${part.section}>\n${part.text}\n</${part.section}>` : part.text;
25
+ }
26
+ /**
27
+ * Renders the authored parts, then the kernel's derived text, into one string —
28
+ * and reports which documents went into it.
29
+ *
30
+ * `derived` (the skill index, the `final_output` instruction) is appended last
31
+ * so the volatile tail never invalidates the cacheable prefix, and it is *not*
32
+ * reported as a source: neither is a file anyone edits.
33
+ *
34
+ * The only async here is `put`: the composer does no I/O of its own, because by
35
+ * this point every part already carries its text.
36
+ */
37
+ export async function composePrompt(instructions, ctx, spec, put, derived = []) {
38
+ const parts = instructions === undefined
39
+ ? []
40
+ : Array.isArray(instructions)
41
+ ? instructions
42
+ : [instructions];
43
+ const chunks = [];
44
+ const sources = [];
45
+ for (const part of parts) {
46
+ if (typeof part === 'string') {
47
+ chunks.push(part);
48
+ }
49
+ else if (typeof part === 'function') {
50
+ chunks.push(part(ctx, spec));
51
+ }
52
+ else {
53
+ if (part.path && part.text) {
54
+ sources.push({ path: part.path, content: await put(part.text) });
55
+ }
56
+ chunks.push(wrap(part));
57
+ }
58
+ }
59
+ chunks.push(...derived);
60
+ return { text: chunks.filter(Boolean).join(SEPARATOR), sources };
61
+ }
62
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1,103 @@
1
+ import type { z } from 'zod';
2
+ import { Agent, AgentRegistry, type AgentOptions } from './agent.ts';
3
+ import { type Architecture } from './architecture.ts';
4
+ import { RunStream } from './events.ts';
5
+ import { type IdClock } from './ids.ts';
6
+ import type { MemoryStore } from './memory.ts';
7
+ import type { Model } from './model.ts';
8
+ import { PayloadResolver, type PayloadStore } from './payload.ts';
9
+ import { Services } from './services.ts';
10
+ import { type SkillProvider } from './skills.ts';
11
+ import { type AgentState } from './state.ts';
12
+ import { type HandoffNode, type TrajectoryNode } from './trajectory.ts';
13
+ import { type Input, type TokenUsage } from './types.ts';
14
+ /**
15
+ * Collapsing history is two decisions, and they belong on different sides of
16
+ * the I/O line: *which* nodes go (pure, so the kernel can stay pure) and *how*
17
+ * they are rendered (a model call, so the driver owns it).
18
+ */
19
+ export interface HandoffPolicy {
20
+ /** nodes the outgoing agent leaves behind, or null to keep everything */
21
+ select(state: AgentState, handoff: HandoffNode): TrajectoryNode[] | null;
22
+ }
23
+ export type Summary = string | {
24
+ text: string;
25
+ usage?: TokenUsage;
26
+ };
27
+ export interface Summarizer {
28
+ summarize(nodes: TrajectoryNode[], reason: string, services: Services): Promise<Summary>;
29
+ }
30
+ export interface JoinPolicy {
31
+ /** what the parent sees for this branch */
32
+ summarize(child: AgentState, services: Services): Promise<string>;
33
+ /** whether one branch's failure aborts the others */
34
+ onBranchError?: 'continue' | 'abort_siblings';
35
+ }
36
+ /** A summarizer that asks a model, so the compaction node holds real prose. */
37
+ export declare function modelSummarizer(model: Model, instructions?: string): Summarizer;
38
+ export interface RunnerOptions<TCtx = unknown> {
39
+ /** default model for agents that do not pin their own */
40
+ model?: Model;
41
+ context?: TCtx;
42
+ services?: Services;
43
+ payloads?: PayloadStore | PayloadResolver;
44
+ memory?: MemoryStore[];
45
+ skills?: SkillProvider[];
46
+ handoffPolicy?: HandoffPolicy;
47
+ /** renders the nodes a policy selected; defaults to a structural note */
48
+ summarizer?: Summarizer;
49
+ joinPolicy?: JoinPolicy;
50
+ /** use `Model.stream` when the model implements it (default: true) */
51
+ stream?: boolean;
52
+ /**
53
+ * Store the exact request behind every `llm_call` node, so a finished run
54
+ * can be inspected (see `renderRunReport`) instead of guessed at. Off by
55
+ * default: it re-stores the whole projected transcript once per turn, which
56
+ * is quadratic in run length and defeats the point of a compact state.
57
+ */
58
+ recordRequests?: boolean;
59
+ clock?: IdClock;
60
+ }
61
+ export interface RunOptions<T = string, TCtx = unknown> {
62
+ context?: TCtx;
63
+ /** typed result: the schema drives both validation and `RunResult<T>` */
64
+ output?: z.ZodType<T>;
65
+ signal?: AbortSignal;
66
+ maxForkDepth?: number;
67
+ }
68
+ /**
69
+ * The driver: it owns all nondeterminism and all I/O, and calls the kernel to
70
+ * advance the state. Every checkpoint event carries a complete snapshot, so a
71
+ * consumer can persist it and later `resume()` from exactly that point.
72
+ *
73
+ * There is no turn budget. A run ends on a final answer, an abort or an
74
+ * unrecoverable error.
75
+ */
76
+ export declare class AgentRunner<TCtx = unknown> {
77
+ #private;
78
+ readonly registry: AgentRegistry<TCtx>;
79
+ readonly services: Services;
80
+ constructor(opts?: RunnerOptions<TCtx>);
81
+ /** Registers agents; chainable. */
82
+ add(...agents: Agent<TCtx>[]): this;
83
+ /** Creates + registers + returns an agent in one call. */
84
+ agent(opts: AgentOptions<TCtx>): Agent<TCtx>;
85
+ get(name: string): Agent<TCtx>;
86
+ /**
87
+ * The declared wiring as plain JSON: agents, their tools, skills, memory
88
+ * and hand-offs. It lives here rather than on the registry because three
89
+ * of those answers are the runner's: the fallback model, the skill
90
+ * catalogs behind `services`, and the context that resolves memory scopes.
91
+ */
92
+ describe(): Promise<Architecture>;
93
+ /**
94
+ * Starts a new run. State creation is explicit inside, so the first event a
95
+ * consumer sees (`run_created`) already carries a persistable snapshot.
96
+ */
97
+ run<T = string>(agent: Agent<TCtx> | string, input?: Input, opts?: RunOptions<T, TCtx>): RunStream<T>;
98
+ /** Continues a persisted run from its own snapshot. */
99
+ resume<T = string>(state: AgentState, opts?: RunOptions<T, TCtx>): RunStream<T>;
100
+ /** Adds a follow-up message to a finished (or paused) run and continues it. */
101
+ send<T = string>(state: AgentState, input: Input, opts?: RunOptions<T, TCtx>): RunStream<T>;
102
+ }
103
+ //# sourceMappingURL=runner.d.ts.map