@code-yeongyu/senpi-agent-core 2026.9.30 → 2026.10.1-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.
Files changed (64) hide show
  1. package/README.md +49 -20
  2. package/dist/agent-loop.d.ts +27 -3
  3. package/dist/agent-loop.js +192 -56
  4. package/dist/agent.d.ts +21 -7
  5. package/dist/agent.js +38 -18
  6. package/dist/harness/execution/tools.d.ts +1 -1
  7. package/dist/harness/execution/tools.js +0 -2
  8. package/dist/harness/messages.js +1 -0
  9. package/dist/harness/pico3/bash.d.ts +10 -0
  10. package/dist/harness/pico3/bash.js +25 -0
  11. package/dist/harness/pico3/bounded.d.ts +21 -0
  12. package/dist/harness/pico3/bounded.js +95 -0
  13. package/dist/harness/pico3/chord.d.ts +41 -0
  14. package/dist/harness/pico3/chord.js +147 -0
  15. package/dist/harness/pico3/context.d.ts +16 -0
  16. package/dist/harness/pico3/context.js +88 -0
  17. package/dist/harness/pico3/harness.d.ts +198 -0
  18. package/dist/harness/pico3/harness.js +645 -0
  19. package/dist/harness/pico3/hooks.d.ts +10 -0
  20. package/dist/harness/pico3/hooks.js +33 -0
  21. package/dist/harness/pico3/index.d.ts +19 -0
  22. package/dist/harness/pico3/index.js +15 -0
  23. package/dist/harness/pico3/jsonl.d.ts +58 -0
  24. package/dist/harness/pico3/jsonl.js +322 -0
  25. package/dist/harness/pico3/kinds/collapse.d.ts +49 -0
  26. package/dist/harness/pico3/kinds/collapse.js +191 -0
  27. package/dist/harness/pico3/kinds/entries.d.ts +78 -0
  28. package/dist/harness/pico3/kinds/entries.js +13 -0
  29. package/dist/harness/pico3/kinds/frames.d.ts +9 -0
  30. package/dist/harness/pico3/kinds/frames.js +75 -0
  31. package/dist/harness/pico3/kinds/generation.d.ts +94 -0
  32. package/dist/harness/pico3/kinds/generation.js +504 -0
  33. package/dist/harness/pico3/kinds/job.d.ts +44 -0
  34. package/dist/harness/pico3/kinds/job.js +143 -0
  35. package/dist/harness/pico3/kinds/plugin.d.ts +15 -0
  36. package/dist/harness/pico3/kinds/plugin.js +35 -0
  37. package/dist/harness/pico3/kinds/post-tools.d.ts +22 -0
  38. package/dist/harness/pico3/kinds/post-tools.js +145 -0
  39. package/dist/harness/pico3/kinds/task-api.d.ts +3 -0
  40. package/dist/harness/pico3/kinds/task-api.js +45 -0
  41. package/dist/harness/pico3/kinds/tool.d.ts +43 -0
  42. package/dist/harness/pico3/kinds/tool.js +373 -0
  43. package/dist/harness/pico3/legacy-tracker.d.ts +11 -0
  44. package/dist/harness/pico3/legacy-tracker.js +39 -0
  45. package/dist/harness/pico3/membrane.d.ts +23 -0
  46. package/dist/harness/pico3/membrane.js +140 -0
  47. package/dist/harness/pico3/memory.d.ts +53 -0
  48. package/dist/harness/pico3/memory.js +265 -0
  49. package/dist/harness/pico3/scheduler.d.ts +49 -0
  50. package/dist/harness/pico3/scheduler.js +437 -0
  51. package/dist/harness/pico3/session.d.ts +264 -0
  52. package/dist/harness/pico3/session.js +1328 -0
  53. package/dist/harness/pico3/system.d.ts +126 -0
  54. package/dist/harness/pico3/system.js +244 -0
  55. package/dist/harness/pico3/types.d.ts +973 -0
  56. package/dist/harness/pico3/types.js +94 -0
  57. package/dist/harness/pico3/view.d.ts +34 -0
  58. package/dist/harness/pico3/view.js +404 -0
  59. package/dist/harness/runtime/drive/tool-placement.js +2 -27
  60. package/dist/harness/telemetry.d.ts +36 -36
  61. package/dist/harness/tools/image.js +1 -1
  62. package/dist/proxy.d.ts +2 -2
  63. package/dist/types.d.ts +111 -34
  64. package/package.json +9 -5
@@ -0,0 +1,198 @@
1
+ import type { Context } from "@earendil-works/chord";
2
+ import { withAbortSignal } from "@earendil-works/chord/context";
3
+ import type { TSchema } from "typebox";
4
+ import { collapse } from "./kinds/collapse.ts";
5
+ import { generation } from "./kinds/generation.ts";
6
+ import { job } from "./kinds/job.ts";
7
+ import { plugin } from "./kinds/plugin.ts";
8
+ import { postTools } from "./kinds/post-tools.ts";
9
+ import { tool } from "./kinds/tool.ts";
10
+ import { isCoreKind } from "./session.ts";
11
+ import { type SystemSection } from "./system.ts";
12
+ import { type AnyKind, type AnyToolDeclaration, type ConfigFacade, type ConfigOfKinds, type ContextView, type ConversationSpec, type DisjointConfig, type Entry, type EntryKind, type EntryScan, type HooksOf, type HostTx, type Id, type Input, type JsonObject, type JsonValue, type Models, type Namespace, type NamespaceDefaults, type NewEntry, type PluginHandler, type ProcessHost, type RewindableState, type SendInput, type StickyState, type Storage, type Task, type ToolDeclaration, type UserInput } from "./types.ts";
13
+ import { type Watch } from "./view.ts";
14
+ export interface HarnessOptions<Ks extends readonly AnyKind[] = []> {
15
+ models: Models;
16
+ tools?: AnyToolDeclaration[];
17
+ /** Ordinary kinds authored with `defineTask`. Their `config` merges onto `c.config`; keys must be disjoint. */
18
+ taskKinds?: Ks;
19
+ sections?: SystemSection[];
20
+ plugins?: {
21
+ [name: string]: PluginHandler;
22
+ };
23
+ processHost?: ProcessHost;
24
+ /** Clock for durable kernel timestamps and retry scheduling. */
25
+ now?: () => number;
26
+ root?: {
27
+ rewindable?: Partial<RewindableState>;
28
+ sticky?: Partial<StickyState>;
29
+ };
30
+ /** Errors from listeners, hooks, watches, and the scheduler. Never delivered as commit failures. */
31
+ onReport?: (error: unknown) => void;
32
+ }
33
+ export type BuiltinKinds = readonly [
34
+ typeof generation,
35
+ typeof tool,
36
+ typeof postTools,
37
+ typeof collapse,
38
+ typeof job,
39
+ typeof plugin
40
+ ];
41
+ export type ConfigFor<Ks extends readonly AnyKind[]> = ConfigOfKinds<[...BuiltinKinds, ...Ks]>;
42
+ export interface ConversationHandle<Cfg extends object = ConfigFor<[]>> {
43
+ readonly id: Id;
44
+ readonly config: ConfigFacade<Cfg>;
45
+ send(input: SendInput, ctx: Context): Promise<InputHandle>;
46
+ write(entry: NewEntry, ctx: Context): Promise<Id>;
47
+ commit<T>(fn: (tx: HostTx, ctx: Context) => T | Promise<T>, ctx: Context): Promise<T>;
48
+ rewindable(ctx: Context): Promise<RewindableState>;
49
+ sticky(ctx: Context): Promise<StickyState>;
50
+ context(ctx: Context): Promise<ContextView>;
51
+ fork(at: Id | "start", spec: Omit<ConversationSpec, "parent">, ctx: Context): Promise<ConversationHandle<Cfg>>;
52
+ collapse(instructions: string | undefined, ctx: Context): Promise<Id>;
53
+ reset(handoff: string | undefined, ctx: Context): Promise<void>;
54
+ abort(ctx: Context): Promise<void>;
55
+ waitForIdle(ctx: Context): Promise<void>;
56
+ hooks<T extends JsonObject, K extends AnyKind>(namespace: Namespace<T>, kind: K, handlers: Partial<HooksOf<K>>, opts?: {
57
+ subtree?: boolean;
58
+ }): () => void;
59
+ watch(ctx: Context): Promise<Watch>;
60
+ }
61
+ export interface InputHandle {
62
+ readonly id: Id;
63
+ result(ctx: Context): Promise<Input | undefined>;
64
+ wait(ctx: Context): Promise<Input>;
65
+ abort(ctx: Context): Promise<"aborted" | "already_placed" | "not_found">;
66
+ }
67
+ export declare class Harness<Ks extends readonly AnyKind[] = []> {
68
+ private readonly session;
69
+ private readonly scheduler;
70
+ private readonly views;
71
+ private readonly kinds;
72
+ private readonly namespaces;
73
+ private readonly tools;
74
+ private readonly sectionMap;
75
+ private readonly entryKinds;
76
+ private readonly revisions;
77
+ private readonly plugins;
78
+ private readonly hookRegistrations;
79
+ private readonly conversationListeners;
80
+ private readonly onReport;
81
+ private readonly now;
82
+ private readonly ctx;
83
+ private readonly options;
84
+ private resumed;
85
+ private suspended;
86
+ static open<Ks extends readonly AnyKind[] = []>(storage: Storage, options: HarnessOptions<Ks> & (DisjointConfig<[...BuiltinKinds, ...Ks]> extends true ? unknown : {
87
+ readonly __error: "config keys collide across kinds";
88
+ }), ctx: Context): Promise<Harness<Ks>>;
89
+ private constructor();
90
+ private notifyConversation;
91
+ private assertInvocation;
92
+ private assertTaskConversationScope;
93
+ private assertOwnedConversation;
94
+ private init;
95
+ resume(): void;
96
+ private reconcileOrphans;
97
+ quiescent(): boolean;
98
+ hold(): () => void;
99
+ /** Cancel and join in-process invocations, clear transient waits, then close without terminalizing tasks. */
100
+ suspend(ctx: Context): Promise<void>;
101
+ registerTaskKind<K extends AnyKind>(kind: K): () => void;
102
+ namespace<T extends JsonObject>(id: string, defaults: NamespaceDefaults<T>, opts?: {
103
+ view?: (slice: Readonly<T>) => JsonValue;
104
+ }): Namespace<T>;
105
+ /** Register a tool. A duplicate name rejects. Unregister removes only this exact declaration; idempotent. */
106
+ registerTool(tool: AnyToolDeclaration, at?: "open" | "runtime"): () => void;
107
+ registerSection(section: SystemSection, at?: "open" | "runtime"): () => void;
108
+ registerEntryKind(kind: EntryKind): () => void;
109
+ /** Register namespace-bound handlers for one kind's hook points, harness-wide. Both tokens must be current. */
110
+ hooks<T extends JsonObject, K extends AnyKind>(namespace: Namespace<T>, kind: K, handlers: Partial<HooksOf<K>>, _opts?: Readonly<Record<string, never>>): () => void;
111
+ private checkKind;
112
+ private checkNamespace;
113
+ private addHooks;
114
+ root(ctx: Context): Promise<ConversationHandle<ConfigFor<Ks>>>;
115
+ onConversation(listener: (conversation: ConversationHandle<ConfigFor<Ks>>) => void): () => void;
116
+ conversation(id: Id, ctx: Context): Promise<ConversationHandle<ConfigFor<Ks>> | undefined>;
117
+ createConversation(spec: ConversationSpec & {
118
+ input?: UserInput;
119
+ }, ctx: Context): Promise<ConversationHandle<ConfigFor<Ks>>>;
120
+ entries(scan: EntryScan, ctx: Context): Promise<Entry[]>;
121
+ getTask(id: Id, ctx: Context): Promise<Task | undefined>;
122
+ abortInput(id: Id, ctx: Context, conversationId?: Id): Promise<"aborted" | "already_placed" | "not_found">;
123
+ abortTask(id: Id, ctx: Context): Promise<"marked" | "terminal">;
124
+ /** Durably mark a task for abort without signalling its invocation; the scheduler aborts it when it next drains. */
125
+ markTask(id: Id, ctx: Context): Promise<"marked" | "terminal">;
126
+ waitForIdle(ctx: Context): Promise<void>;
127
+ waitForTask(id: Id, ctx: Context): Promise<Task>;
128
+ /** Signals every invocation, waits for them, closes storage. Writes nothing. */
129
+ close(ctx: Context): Promise<void>;
130
+ private handle;
131
+ /** Capture and subscribe in one line operation. */
132
+ private watch;
133
+ private inputHandle;
134
+ }
135
+ /**
136
+ * §9: H = newest fork-visible entry with a head. Active transcript = H plus every fork-visible entry
137
+ * with id ≥ H.head, chronological, nothing dropped inside the range; the whole transcript if no head.
138
+ */
139
+ export declare function captureActiveTranscript(scan: (s: EntryScan) => Promise<Entry[]>, conversationId: Id): Promise<Entry[]>;
140
+ export type { ConversationView, Envelope, ViewEvent } from "./types.ts";
141
+ export type { Watch } from "./view.ts";
142
+ export { applyEnvelope, WATCH_CAPACITY } from "./view.ts";
143
+ export { isCoreKind, withAbortSignal };
144
+ /** The built-in kinds, as typed witnesses for `api.task`, `waitForTask`, and `hooks(kind, …)`. */
145
+ export declare const kinds: {
146
+ readonly generation: import("./types.ts").CoreKind<import("./kinds/generation.ts").GenerationInput, import("./kinds/generation.ts").GenerationCheckpoint, import("./kinds/generation.ts").GenerationResult, import("./kinds/generation.ts").GenerationFailure, {
147
+ assistant?: Id;
148
+ }, import("./kinds/generation.ts").GenerationHooks, {
149
+ readonly rewindable: {
150
+ readonly model: import("./types.ts").ModelRef | undefined;
151
+ readonly thinkingLevel: import("./types.ts").ThinkingLevel;
152
+ readonly selectedTools: string[];
153
+ readonly profile: string;
154
+ };
155
+ readonly sticky: {
156
+ readonly retry: import("./types.ts").RetryPolicy;
157
+ };
158
+ }>;
159
+ readonly tool: import("./types.ts").CoreKind<import("./kinds/tool.ts").ToolInput, import("./kinds/tool.ts").ToolCheckpoint, import("./kinds/tool.ts").ToolTaskResult, never, {
160
+ entry: Id;
161
+ }, import("./kinds/tool.ts").ToolHooks>;
162
+ readonly postTools: import("./types.ts").CoreKind<import("./kinds/post-tools.ts").PostToolsInput, never, import("./kinds/post-tools.ts").PostToolsResult, never, null, import("./kinds/post-tools.ts").PostToolsHooks, {
163
+ readonly sticky: {
164
+ readonly steeringMode: "all" | "one-at-a-time";
165
+ readonly followUpMode: "all" | "one-at-a-time";
166
+ };
167
+ }>;
168
+ readonly collapse: import("./types.ts").CoreKind<import("./kinds/collapse.ts").CollapseInput, import("./kinds/collapse.ts").CollapseCheckpoint, {
169
+ summary: Id;
170
+ }, import("./kinds/collapse.ts").CollapseFailure, null, import("./kinds/collapse.ts").CollapseHooks, {
171
+ readonly rewindable: {
172
+ readonly threshold: number;
173
+ readonly keepRecent: number;
174
+ };
175
+ }>;
176
+ readonly job: Readonly<import("./types.ts").Kind<import("./kinds/job.ts").JobInput, import("./kinds/job.ts").JobCheckpoint, import("./kinds/job.ts").JobResult, import("./kinds/job.ts").JobFailure, {
177
+ killed: boolean;
178
+ }, object, import("./types.ts").KindConfig<import("./types.ts").ConfigShape, import("./types.ts").ConfigShape>, import("./kinds/job.ts").JobOutput, import("./types.ts").TaskTx>>;
179
+ readonly plugin: Readonly<import("./types.ts").Kind<import("./kinds/plugin.ts").PluginInput, {
180
+ phase: "started";
181
+ }, import("@earendil-works/chord").JsonValue, {
182
+ reason: "missing_handler" | "threw";
183
+ detail: string;
184
+ }, null, object, import("./types.ts").KindConfig<import("./types.ts").ConfigShape, import("./types.ts").ConfigShape>, JsonObject, import("./types.ts").TaskTx>>;
185
+ };
186
+ export declare const entries: {
187
+ readonly user: EntryKind<import("./kinds/entries.ts").UserEntry>;
188
+ readonly assistant: EntryKind<import("./kinds/entries.ts").AssistantEntry>;
189
+ readonly toolResult: EntryKind<import("./kinds/entries.ts").ToolResultEntry>;
190
+ readonly system: EntryKind<import("./kinds/entries.ts").SystemEntry>;
191
+ readonly notice: EntryKind<import("./kinds/entries.ts").NoticeEntry>;
192
+ readonly usage: EntryKind<import("./kinds/entries.ts").UsageEntry>;
193
+ readonly summary: EntryKind<import("./kinds/entries.ts").SummaryEntry>;
194
+ readonly handoff: EntryKind<import("./kinds/entries.ts").HandoffEntry>;
195
+ readonly reset: EntryKind<import("./kinds/entries.ts").ResetEntry>;
196
+ };
197
+ export type { ToolDeclaration, TSchema };
198
+ //# sourceMappingURL=harness.d.ts.map