@op0ai/sdk 0.3.1 → 0.4.1

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 (83) hide show
  1. package/README.md +2 -2
  2. package/dist/guards.d.ts +1 -61
  3. package/dist/guards.js +1 -88
  4. package/dist/hash.d.ts +1 -6
  5. package/dist/hash.js +1 -18
  6. package/dist/index.d.ts +1 -121
  7. package/dist/index.js +14 -171
  8. package/dist/session.d.ts +1 -47
  9. package/dist/session.js +2 -88
  10. package/dist/{agent.d.ts → types/agent.d.ts} +1 -2
  11. package/dist/{agui.d.ts → types/agui.d.ts} +0 -1
  12. package/dist/{config.d.ts → types/config.d.ts} +0 -1
  13. package/dist/{contract.d.ts → types/contract.d.ts} +0 -1
  14. package/dist/{data.d.ts → types/data.d.ts} +0 -1
  15. package/dist/{define.d.ts → types/define.d.ts} +0 -1
  16. package/dist/{distill.d.ts → types/distill.d.ts} +0 -1
  17. package/dist/{events.d.ts → types/events.d.ts} +0 -1
  18. package/dist/{evlog.d.ts → types/evlog.d.ts} +0 -1
  19. package/dist/types/guards.d.ts +60 -0
  20. package/dist/types/hash.d.ts +5 -0
  21. package/dist/types/index.d.ts +120 -0
  22. package/dist/{platform.d.ts → types/platform.d.ts} +0 -1
  23. package/dist/types/session.d.ts +46 -0
  24. package/dist/{source.d.ts → types/source.d.ts} +0 -1
  25. package/dist/{tool.d.ts → types/tool.d.ts} +0 -1
  26. package/dist/{usectx.d.ts → types/usectx.d.ts} +0 -1
  27. package/dist/types/vault.d.ts +20 -0
  28. package/dist/vault.d.ts +1 -21
  29. package/dist/vault.js +1 -25
  30. package/package.json +4 -3
  31. package/dist/agent.d.ts.map +0 -1
  32. package/dist/agent.js +0 -72
  33. package/dist/agent.js.map +0 -1
  34. package/dist/agui.d.ts.map +0 -1
  35. package/dist/agui.js +0 -22
  36. package/dist/agui.js.map +0 -1
  37. package/dist/config.d.ts.map +0 -1
  38. package/dist/config.js +0 -39
  39. package/dist/config.js.map +0 -1
  40. package/dist/contract.d.ts.map +0 -1
  41. package/dist/contract.js +0 -66
  42. package/dist/contract.js.map +0 -1
  43. package/dist/data.d.ts.map +0 -1
  44. package/dist/data.js +0 -211
  45. package/dist/data.js.map +0 -1
  46. package/dist/define.d.ts.map +0 -1
  47. package/dist/define.js +0 -87
  48. package/dist/define.js.map +0 -1
  49. package/dist/distill.d.ts.map +0 -1
  50. package/dist/distill.js +0 -113
  51. package/dist/distill.js.map +0 -1
  52. package/dist/events.d.ts.map +0 -1
  53. package/dist/events.js +0 -25
  54. package/dist/events.js.map +0 -1
  55. package/dist/evlog.d.ts.map +0 -1
  56. package/dist/evlog.js +0 -124
  57. package/dist/evlog.js.map +0 -1
  58. package/dist/fleet-names.d.ts +0 -11
  59. package/dist/fleet-names.d.ts.map +0 -1
  60. package/dist/fleet-names.js +0 -10
  61. package/dist/fleet-names.js.map +0 -1
  62. package/dist/guards.d.ts.map +0 -1
  63. package/dist/guards.js.map +0 -1
  64. package/dist/hash.d.ts.map +0 -1
  65. package/dist/hash.js.map +0 -1
  66. package/dist/index.d.ts.map +0 -1
  67. package/dist/index.js.map +0 -1
  68. package/dist/platform.d.ts.map +0 -1
  69. package/dist/platform.js +0 -10
  70. package/dist/platform.js.map +0 -1
  71. package/dist/session.d.ts.map +0 -1
  72. package/dist/session.js.map +0 -1
  73. package/dist/source.d.ts.map +0 -1
  74. package/dist/source.js +0 -96
  75. package/dist/source.js.map +0 -1
  76. package/dist/tool.d.ts.map +0 -1
  77. package/dist/tool.js +0 -16
  78. package/dist/tool.js.map +0 -1
  79. package/dist/usectx.d.ts.map +0 -1
  80. package/dist/usectx.js +0 -220
  81. package/dist/usectx.js.map +0 -1
  82. package/dist/vault.d.ts.map +0 -1
  83. package/dist/vault.js.map +0 -1
package/dist/session.js CHANGED
@@ -1,88 +1,2 @@
1
- // session.ts the Session seam (ADR-30): coding-ops over harness-agnostic LIVE sessions.
2
- //
3
- // Parallel to the Source seam (source.ts = static repos; this = live coding sessions). Three modes:
4
- // owned — op0 creates the session in our runtime (WfP/Sandbox): full control + full intercept.
5
- // attached — op0 drives an EXISTING session via the session-connector (local daemon, ADR-4d): partial.
6
- // streamed — op0 observes + intercepts a session it does NOT run, via the lapdog/trajectory pattern:
7
- // HOOKS = observe (fail-open, fire-and-forget) · model-PROXY = in-path = INTERCEPTABLE.
8
- // This is how we "audit work we're not controlling" AND keep a governance gate (deepsec)
9
- // on the proxy path even for sessions we didn't launch.
10
- //
11
- // Harness-agnostic (Claude Code / Codex / Cursor / Gemini / opencode / Copilot / Factory / Pi): MINE the
12
- // OSS reference `datadog-labs/trajectory` (per-client hook/proxy/watcher/backfill instrumentation) rather
13
- // than hand-rolling — the "check for an existing OSS framework first" lesson. *Verify its license before
14
- // adapting code; otherwise inspiration-only and build our thin capture on the same vectors.* Observability
15
- // is commoditized by Datadog (lapdog/trajectory) — our moat is the ACT half: govern · intercept · turn the
16
- // session into a governed onloop run · the flywheel. evlog ingests these traces as just another Source.
17
- //
18
- // Pure TS, zero deps (Node + Worker). Reuses the @op0-ai/cord guards so a streamed session yields the SAME
19
- // evlog WideEvents + tamper-evident audit as an owned cord run.
20
- import { makeAuditChain, verifyChain } from "./guards.js";
21
- import { newId } from "./hash.js";
22
- export const DEFAULT_RULES = [
23
- { id: "force-push", match: (e) => e.kind === "tool_call" && /\bgit\s+push\b.*--force(?!-with-lease)/.test(e.name), decision: "deny", why: "force-push without --force-with-lease" },
24
- { id: "rm-rf", match: (e) => e.kind === "tool_call" && /\brm\s+-rf\b/.test(e.name), decision: "approve", why: "destructive delete — needs human approval" },
25
- { id: "secret-exfil", match: (e) => e.kind === "tool_call" && /(curl|wget)\b.*(\.env|secret|token|key)/i.test(e.name), decision: "approve", why: "possible secret exfiltration" },
26
- ];
27
- // enforceable ONLY when the event is actionable: owned/attached (we drive it) or streamed-via-PROXY (in-path).
28
- // streamed-via-hook is observe-only (fail-open) → we can flag/audit but not block.
29
- const canEnforce = (mode, vector) => mode === "owned" || mode === "attached" || (mode === "streamed" && vector === "proxy");
30
- export const intercept = (stream, rules = DEFAULT_RULES) => {
31
- const out = [];
32
- for (const e of stream.events) {
33
- for (const r of rules) {
34
- if (r.match(e))
35
- out.push({ event: e, rule: r, decision: r.decision, enforceable: canEnforce(stream.mode, e.vector) });
36
- }
37
- }
38
- return out;
39
- };
40
- export const ingestSession = (stream, rules = DEFAULT_RULES) => {
41
- const chain = makeAuditChain();
42
- chain.append({ actor: "deepsec", action: "session.capture", scopeId: stream.mode, payload: { harness: stream.harness, mode: stream.mode } });
43
- const events = stream.events.map((e) => ({
44
- ts: e.ts, runId: stream.runId, tenantId: "op0", cordId: "@op0/coding-ops",
45
- kind: e.kind === "tool_call" || e.kind === "tool_result" ? "tool" : e.kind === "model" ? "model" : "step",
46
- name: e.name, durationMs: 0, ok: true,
47
- attrs: { vector: e.vector, ...(e.attrs ?? {}) },
48
- }));
49
- const interceptions = intercept(stream, rules);
50
- for (const i of interceptions) {
51
- chain.append({
52
- actor: "deepsec",
53
- action: i.enforceable ? `intercept.${i.decision}` : "intercept.flag",
54
- scopeId: stream.mode,
55
- payload: { rule: i.rule.id, why: i.rule.why, event: i.event.name, enforceable: i.enforceable },
56
- });
57
- }
58
- chain.append({ actor: "deepsec", action: "session.settle", scopeId: stream.mode, payload: { runId: stream.runId, events: events.length, interceptions: interceptions.length } });
59
- return { runId: stream.runId, harness: stream.harness, mode: stream.mode, events, audit: chain.entries, interceptions };
60
- };
61
- // --- streamed adapter: parse a lapdog/trajectory-style JSONL capture into a SessionStream ---
62
- // (lapdog hooks POST one JSON per event; trajectory writes JSONL timelines. This is a minimal normalized
63
- // subset for the spike; the real adapter maps each harness's hook/proxy schema — mine trajectory's.)
64
- export const fromTrajectoryJsonl = (jsonl, harness, mode = "streamed") => {
65
- const events = [];
66
- for (const line of jsonl.split("\n")) {
67
- const t = line.trim();
68
- if (!t)
69
- continue;
70
- let o;
71
- try {
72
- o = JSON.parse(t);
73
- }
74
- catch {
75
- continue;
76
- }
77
- events.push({
78
- ts: o.ts ?? new Date().toISOString(),
79
- kind: o.kind ?? "lifecycle",
80
- name: o.name ?? o.tool ?? o.event ?? "event",
81
- vector: o.vector ?? "hook",
82
- attrs: o.attrs, tokensIn: o.tokensIn, tokensOut: o.tokensOut, costUsd: o.costUsd,
83
- });
84
- }
85
- return { mode, harness, runId: newId(), events };
86
- };
87
- export { verifyChain };
88
- //# sourceMappingURL=session.js.map
1
+ var a=e=>{let n=2166136261;for(let o=0;o<e.length;o++)n^=e.charCodeAt(o),n=Math.imul(n,16777619);return(n>>>0).toString(16).padStart(8,"0")};var p=()=>Date.now().toString(36)+"-"+Math.random().toString(36).slice(2,8);var l=e=>a([e.seq,e.ts,e.actor,e.action,e.scopeId,e.payloadHash,e.prevHash].join("|")),u=()=>{let e=[];return{entries:e,append({actor:n,action:o,scopeId:r,payload:s}){let t=e.length,i=new Date().toISOString(),g=t===0?"GENESIS":e[t-1]?.hash??"GENESIS",y=a(JSON.stringify(s??null)),c={seq:t,ts:i,actor:n,action:o,scopeId:r,payloadHash:y,prevHash:g},d={...c,hash:l(c)};return e.push(d),d}}},f=e=>{for(let n=0;n<e.length;n++){let o=e[n];if(!o)return!1;let r=n===0?"GENESIS":e[n-1]?.hash??"GENESIS";if(o.prevHash!==r)return!1;let{hash:s,...t}=o;if(s!==l(t))return!1}return!0};var h=[{id:"force-push",match:e=>e.kind==="tool_call"&&/\bgit\s+push\b.*--force(?!-with-lease)/.test(e.name),decision:"deny",why:"force-push without --force-with-lease"},{id:"rm-rf",match:e=>e.kind==="tool_call"&&/\brm\s+-rf\b/.test(e.name),decision:"approve",why:"destructive delete \u2014 needs human approval"},{id:"secret-exfil",match:e=>e.kind==="tool_call"&&/(curl|wget)\b.*(\.env|secret|token|key)/i.test(e.name),decision:"approve",why:"possible secret exfiltration"}],m=(e,n)=>e==="owned"||e==="attached"||e==="streamed"&&n==="proxy",v=(e,n=h)=>{let o=[];for(let r of e.events)for(let s of n)s.match(r)&&o.push({event:r,rule:s,decision:s.decision,enforceable:m(e.mode,r.vector)});return o},I=(e,n=h)=>{let o=u();o.append({actor:"deepsec",action:"session.capture",scopeId:e.mode,payload:{harness:e.harness,mode:e.mode}});let r=e.events.map(t=>({ts:t.ts,runId:e.runId,tenantId:"op0",cordId:"@op0/coding-ops",kind:t.kind==="tool_call"||t.kind==="tool_result"?"tool":t.kind==="model"?"model":"step",name:t.name,durationMs:0,ok:!0,attrs:{vector:t.vector,...t.attrs??{}}})),s=v(e,n);for(let t of s)o.append({actor:"deepsec",action:t.enforceable?`intercept.${t.decision}`:"intercept.flag",scopeId:e.mode,payload:{rule:t.rule.id,why:t.rule.why,event:t.event.name,enforceable:t.enforceable}});return o.append({actor:"deepsec",action:"session.settle",scopeId:e.mode,payload:{runId:e.runId,events:r.length,interceptions:s.length}}),{runId:e.runId,harness:e.harness,mode:e.mode,events:r,audit:o.entries,interceptions:s}},b=(e,n,o="streamed")=>{let r=[];for(let s of e.split(`
2
+ `)){let t=s.trim();if(!t)continue;let i;try{i=JSON.parse(t)}catch{continue}r.push({ts:i.ts??new Date().toISOString(),kind:i.kind??"lifecycle",name:i.name??i.tool??i.event??"event",vector:i.vector??"hook",attrs:i.attrs,tokensIn:i.tokensIn,tokensOut:i.tokensOut,costUsd:i.costUsd})}return{mode:o,harness:n,runId:p(),events:r}};export{h as DEFAULT_RULES,b as fromTrajectoryJsonl,I as ingestSession,v as intercept,f as verifyChain};
@@ -17,7 +17,6 @@ export declare const fakeInference: (script: Array<{
17
17
  /**
18
18
  * portsAsTools — expose selected resource ports to the agent as callable tools. THIS is governed-tools = ports:
19
19
  * the agent can only act through capabilities the cord declared + the host bound. `onTool` lets the cord audit
20
- * every call (one wide-event per action). ponytail: only the ports you pass become tools — nothing else.
20
+ * every call (one wide-event per action). Only the ports you pass become tools — nothing else.
21
21
  */
22
22
  export declare const portsAsTools: (res: Resources, onTool?: (name: string, args: Record<string, unknown>) => void) => ToolSpec[];
23
- //# sourceMappingURL=agent.d.ts.map
@@ -84,4 +84,3 @@ export interface Emitter {
84
84
  errored(error: string): void;
85
85
  }
86
86
  export declare function createEmitter(runId: string, sink: AgentEventSink): Emitter;
87
- //# sourceMappingURL=agui.d.ts.map
@@ -75,4 +75,3 @@ export declare function toolsToOpenAI(tools: readonly Tool[] | ToolSet): Array<{
75
75
  parameters: unknown;
76
76
  };
77
77
  }>;
78
- //# sourceMappingURL=config.d.ts.map
@@ -39,4 +39,3 @@ export declare function accumToolCalls(acc: Record<number, ToolCallAccum>, delta
39
39
  arguments?: string;
40
40
  };
41
41
  }>): Record<number, ToolCallAccum>;
42
- //# sourceMappingURL=contract.d.ts.map
@@ -165,4 +165,3 @@ export type DataResponse = {
165
165
  */
166
166
  export declare function dataPlaneRpc(engine: DataEngine, req: DataRequest, connId?: string): Promise<DataResponse>;
167
167
  export {};
168
- //# sourceMappingURL=data.d.ts.map
@@ -27,4 +27,3 @@ export interface AgentRpcContext {
27
27
  * This is the server half of the thin typed client (client.tsx). RPC edits commit immediately (no debounce).
28
28
  */
29
29
  export declare function cordRpc(request: Request, ctx: AgentRpcContext): Promise<Response>;
30
- //# sourceMappingURL=define.d.ts.map
@@ -65,4 +65,3 @@ export interface SkillStore {
65
65
  export declare function storeSkillSink(store: SkillStore, opts?: {
66
66
  prefix?: string;
67
67
  }): SkillSink;
68
- //# sourceMappingURL=distill.d.ts.map
@@ -36,4 +36,3 @@ export declare function askLedgerEvent(fields: Omit<AskLedgerEvent, "kind" | "at
36
36
  export declare function isAskLedgerEvent(r: unknown): r is AskLedgerEvent;
37
37
  /** The tenant a cord addr belongs to under the LOCKED `<team>--<name>` scheme; null = solo/untenanted. */
38
38
  export declare const tenantOfAgent: (cord: string) => string | null;
39
- //# sourceMappingURL=events.d.ts.map
@@ -68,4 +68,3 @@ export declare function agentObserver(opts: {
68
68
  host: SqlHost;
69
69
  analytics?: AnalyticsSink;
70
70
  }): AgentObserver;
71
- //# sourceMappingURL=evlog.d.ts.map
@@ -0,0 +1,60 @@
1
+ export type GuardEvent = {
2
+ cord: string;
3
+ tool?: string;
4
+ scope?: string;
5
+ input: unknown;
6
+ };
7
+ export type WideEvent = {
8
+ ts: string;
9
+ runId: string;
10
+ tenantId: string;
11
+ cordId: string;
12
+ kind: "turn" | "step" | "model" | "tool" | "eval";
13
+ name: string;
14
+ durationMs: number;
15
+ ok: boolean;
16
+ scope?: string;
17
+ error?: {
18
+ code: string;
19
+ why: string;
20
+ };
21
+ attrs?: Record<string, unknown>;
22
+ };
23
+ export type AuditEntry = {
24
+ seq: number;
25
+ ts: string;
26
+ actor: string;
27
+ action: string;
28
+ scopeId: string;
29
+ payloadHash: string;
30
+ prevHash: string;
31
+ hash: string;
32
+ };
33
+ export type Guard = {
34
+ name: string;
35
+ /** Gate hook: deny by throwing (deepsec scope check), or instrument by side-effect. */
36
+ onCall?: (ev: GuardEvent) => void | Promise<void>;
37
+ /** Output transform applied before persist/export (deepsec redaction). */
38
+ redact?: <T>(value: T) => T;
39
+ /** Wide-event sink (deepeval instrumentation). */
40
+ onEvent?: (e: WideEvent) => void;
41
+ };
42
+ export type AuditChain = {
43
+ entries: AuditEntry[];
44
+ append(e: {
45
+ actor: string;
46
+ action: string;
47
+ scopeId: string;
48
+ payload: unknown;
49
+ }): AuditEntry;
50
+ };
51
+ export declare const makeAuditChain: () => AuditChain;
52
+ /** Re-derive every hash; any insert/edit/delete breaks the chain → returns false. (The S7 red test.) */
53
+ export declare const verifyChain: (entries: AuditEntry[]) => boolean;
54
+ /** deepsec — scope gate + redaction (ADR-10). The runtime also drives an audit chain tagged actor="deepsec". */
55
+ export declare const deepsec: (opts?: {
56
+ allow?: string[];
57
+ secrets?: RegExp[];
58
+ }) => Guard;
59
+ /** deepeval — instruments every run (ADR-24). Collects wide-events; prod forwards to evlog (OTLP + PostHog). */
60
+ export declare const deepeval: (sink?: WideEvent[]) => Guard;
@@ -0,0 +1,5 @@
1
+ export declare const hashHex: (s: string) => string;
2
+ /** A url-safe slug for vault keys (target → reports/<slug>/<runId>.json). */
3
+ export declare const slug: (s: string) => string;
4
+ /** A short, sortable-ish run id (timestamp + entropy). No node: deps. */
5
+ export declare const newId: () => string;
@@ -0,0 +1,120 @@
1
+ export * from "./hash.ts";
2
+ export * from "./vault.ts";
3
+ export * from "./guards.ts";
4
+ export * from "./platform.ts";
5
+ export * from "./agent.ts";
6
+ export * from "./source.ts";
7
+ export * from "./agui.ts";
8
+ export * from "./tool.ts";
9
+ export * from "./config.ts";
10
+ export * from "./define.ts";
11
+ export * from "./contract.ts";
12
+ export * from "./evlog.ts";
13
+ export * from "./events.ts";
14
+ export * from "./usectx.ts";
15
+ export * from "./distill.ts";
16
+ export * from "./data.ts";
17
+ import type { Vault } from "./vault.ts";
18
+ import type { Resources, ResourceNeed } from "./platform.ts";
19
+ import { type Guard, type WideEvent, type AuditEntry } from "./guards.ts";
20
+ /** A sub-cord: an encapsulated unit composed into a parent. `any` generics (not `unknown`) so a typed
21
+ * `subcords` record — { scan: Subagent<string,Facts>, score: Subagent<Facts,EvalResult>, ... } — is assignable
22
+ * to Record<string, Subagent> (Subagent<X,Y> is NOT assignable to Subagent<unknown,unknown> — invariant `run`
23
+ * param — but IS assignable to Subagent<any,any>). Same heterogeneous-registry seam as data.ts's AnyFn. */
24
+ export type Subagent<I = any, O = any> = {
25
+ id: string;
26
+ mount: "local" | "registry";
27
+ run: (input: I) => Promise<O>;
28
+ };
29
+ /** Mount an OWNED sub-cord in-process (deterministic trunk). */
30
+ export declare function use<I, O>(sc: {
31
+ id: string;
32
+ run: (input: I) => Promise<O>;
33
+ }): Subagent<I, O>;
34
+ /** Mount a THIRD-PARTY/registry cord over MCP (the trust boundary; an executor toolkit). */
35
+ export declare function useRemote<I, O>(sc: {
36
+ id: string;
37
+ call: (input: I) => Promise<O>;
38
+ }): Subagent<I, O>;
39
+ export type Expose = {
40
+ codemode?: boolean;
41
+ mcp?: string;
42
+ cli?: boolean;
43
+ openapi?: boolean;
44
+ };
45
+ export type AgentDef<Input, Output> = {
46
+ id: string;
47
+ kind?: "agent-ful" | "agent-less";
48
+ inference?: "managed" | "byo";
49
+ /** The scope this cord's run requests — checked by deepsec against its allow-list (H4). */
50
+ scope?: string;
51
+ expose?: Expose;
52
+ guards?: Guard[];
53
+ subcords?: Record<string, Subagent>;
54
+ /** Durable resources this cord requires; the host MUST bind them or the run fails fast (validated post-gate). */
55
+ needs?: ResourceNeed[];
56
+ /** The deterministic trunk: compose sub-cords (ctx) + use the host-bound resources (res). */
57
+ run: (input: Input, ctx: Record<string, (input: any) => Promise<any>>, res: Resources) => Promise<Output>;
58
+ };
59
+ export type RunBudget = {
60
+ cap: number;
61
+ used: number;
62
+ depth: number;
63
+ maxDepth: number;
64
+ };
65
+ export type RunOpts = {
66
+ tenantId?: string;
67
+ scope?: string;
68
+ vault?: Vault;
69
+ resources?: Resources;
70
+ budget?: Partial<Pick<RunBudget, "cap" | "maxDepth">>;
71
+ onEvent?: (e: WideEvent) => void;
72
+ };
73
+ export type RunResult<O> = {
74
+ output: O;
75
+ runId: string;
76
+ artifact?: {
77
+ key: string;
78
+ version: string;
79
+ hash: string;
80
+ };
81
+ audit: AuditEntry[];
82
+ events: WideEvent[];
83
+ budget: RunBudget;
84
+ };
85
+ export type AgentManifest = {
86
+ id: string;
87
+ version: string;
88
+ kind: "agent-ful" | "agent-less";
89
+ inference: "managed" | "byo";
90
+ scope?: string;
91
+ expose: Expose;
92
+ subcords: string[];
93
+ guards: string[];
94
+ needs: ResourceNeed[];
95
+ };
96
+ export type Agent<Input, Output> = {
97
+ id: string;
98
+ expose: Expose;
99
+ manifest: AgentManifest;
100
+ run: (input: Input, opts?: RunOpts) => Promise<Output>;
101
+ runFull: (input: Input, opts?: RunOpts) => Promise<RunResult<Output>>;
102
+ };
103
+ export declare function defineAgent<Input, Output>(def: AgentDef<Input, Output>): Agent<Input, Output>;
104
+ /** /.well-known/op0.json (ADR-18) generated from the cord's `expose`. Host is filled at deploy. */
105
+ export declare const wellKnown: (m: AgentManifest, host?: string) => {
106
+ auth?: {
107
+ type: string;
108
+ scopes: string[];
109
+ };
110
+ skills: string;
111
+ cli?: string;
112
+ openapi?: string;
113
+ mcp: string[];
114
+ docs: string;
115
+ };
116
+ /** Content-address the manifest for skillkit publish/fork lineage (signed → forkOf{atCommit} later, ADR-22). */
117
+ export declare const signManifest: (m: AgentManifest) => {
118
+ manifest: AgentManifest;
119
+ hash: string;
120
+ };
@@ -94,4 +94,3 @@ export interface RunSpec {
94
94
  /** Who checks the result: a verifier cord/tool name, or "none" (explicitly unverified). */
95
95
  verifier?: string;
96
96
  }
97
- //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1,46 @@
1
+ import { verifyChain, type WideEvent, type AuditEntry } from "./guards.ts";
2
+ export type SessionMode = "owned" | "attached" | "streamed";
3
+ export type CaptureVector = "hook" | "proxy" | "watcher" | "backfill";
4
+ /** A normalized coding-session event (mirrors lapdog/trajectory capture). */
5
+ export type SessionEvent = {
6
+ ts: string;
7
+ kind: "lifecycle" | "prompt" | "model" | "tool_call" | "tool_result" | "permission";
8
+ name: string;
9
+ vector: CaptureVector;
10
+ attrs?: Record<string, unknown>;
11
+ tokensIn?: number;
12
+ tokensOut?: number;
13
+ costUsd?: number;
14
+ };
15
+ export type SessionStream = {
16
+ mode: SessionMode;
17
+ harness: string;
18
+ runId: string;
19
+ events: SessionEvent[];
20
+ };
21
+ export type Decision = "allow" | "deny" | "approve";
22
+ export type Rule = {
23
+ id: string;
24
+ match: (e: SessionEvent) => boolean;
25
+ decision: Decision;
26
+ why: string;
27
+ };
28
+ export declare const DEFAULT_RULES: Rule[];
29
+ export type Interception = {
30
+ event: SessionEvent;
31
+ rule: Rule;
32
+ decision: Decision;
33
+ enforceable: boolean;
34
+ };
35
+ export declare const intercept: (stream: SessionStream, rules?: Rule[]) => Interception[];
36
+ export type SessionTrace = {
37
+ runId: string;
38
+ harness: string;
39
+ mode: SessionMode;
40
+ events: WideEvent[];
41
+ audit: AuditEntry[];
42
+ interceptions: Interception[];
43
+ };
44
+ export declare const ingestSession: (stream: SessionStream, rules?: Rule[]) => SessionTrace;
45
+ export declare const fromTrajectoryJsonl: (jsonl: string, harness: string, mode?: SessionMode) => SessionStream;
46
+ export { verifyChain };
@@ -62,4 +62,3 @@ export declare function githubCommitter(config: {
62
62
  base?: string;
63
63
  fetch?: typeof fetch;
64
64
  }): Committer;
65
- //# sourceMappingURL=source.d.ts.map
@@ -40,4 +40,3 @@ export interface ToolManifestEntry {
40
40
  readonly description: string;
41
41
  }
42
42
  export declare function toolManifest<Env>(tools: ToolSet<Env>): ToolManifestEntry[];
43
- //# sourceMappingURL=tool.d.ts.map
@@ -90,4 +90,3 @@ export interface UsectxConfig {
90
90
  * resulting FileSet with in-band redaction + audit. This is the one acquisition primitive a cord uses.
91
91
  */
92
92
  export declare function usectx(config?: UsectxConfig): Acquire;
93
- //# sourceMappingURL=usectx.d.ts.map
@@ -0,0 +1,20 @@
1
+ export interface Vault {
2
+ /** Write a deliverable; returns its key + version + content hash (content-addressing → fork lineage). */
3
+ put(key: string, body: string, meta?: Record<string, unknown>): Promise<{
4
+ key: string;
5
+ version: string;
6
+ hash: string;
7
+ }>;
8
+ /** Read a deliverable back (latest version), or null. */
9
+ get(key: string): Promise<string | null>;
10
+ /** List keys under a prefix. */
11
+ list(prefix?: string): Promise<string[]>;
12
+ }
13
+ /** In-memory Vault — the verify/Node default and the H3 red-test substrate. Versions on repeated keys. */
14
+ export declare const memVault: () => Vault & {
15
+ store: Map<string, {
16
+ body: string;
17
+ version: number;
18
+ meta?: unknown;
19
+ }>;
20
+ };
package/dist/vault.d.ts CHANGED
@@ -1,21 +1 @@
1
- export interface Vault {
2
- /** Write a deliverable; returns its key + version + content hash (content-addressing → fork lineage). */
3
- put(key: string, body: string, meta?: Record<string, unknown>): Promise<{
4
- key: string;
5
- version: string;
6
- hash: string;
7
- }>;
8
- /** Read a deliverable back (latest version), or null. */
9
- get(key: string): Promise<string | null>;
10
- /** List keys under a prefix. */
11
- list(prefix?: string): Promise<string[]>;
12
- }
13
- /** In-memory Vault — the verify/Node default and the H3 red-test substrate. Versions on repeated keys. */
14
- export declare const memVault: () => Vault & {
15
- store: Map<string, {
16
- body: string;
17
- version: number;
18
- meta?: unknown;
19
- }>;
20
- };
21
- //# sourceMappingURL=vault.d.ts.map
1
+ export * from "./types/vault.js";
package/dist/vault.js CHANGED
@@ -1,25 +1 @@
1
- // vault.ts the Vault seam (ADR-8). A cord's deliverables are persisted as versioned artifacts; the cord
2
- // core depends ONLY on this interface, so the SAME run logic writes to an in-memory store (Node/verify), an
3
- // R2 bucket (the Worker — see worker/src/vault.ts), or Cloudflare Artifacts (the versioned git target,
4
- // deploy-time). H3 = "every assess leaves a versioned deliverable" — the runtime calls vault.put() once the
5
- // deepsec gate has redacted the output.
6
- import { hashHex } from "./hash.js";
7
- /** In-memory Vault — the verify/Node default and the H3 red-test substrate. Versions on repeated keys. */
8
- export const memVault = () => {
9
- const store = new Map();
10
- return {
11
- store,
12
- async put(key, body, meta) {
13
- const version = (store.get(key)?.version ?? 0) + 1;
14
- store.set(key, { body, version, meta });
15
- return { key, version: String(version), hash: hashHex(body) };
16
- },
17
- async get(key) {
18
- return store.get(key)?.body ?? null;
19
- },
20
- async list(prefix = "") {
21
- return [...store.keys()].filter((k) => k.startsWith(prefix));
22
- },
23
- };
24
- };
25
- //# sourceMappingURL=vault.js.map
1
+ var s=r=>{let t=2166136261;for(let n=0;n<r.length;n++)t^=r.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")};var a=()=>{let r=new Map;return{store:r,async put(t,n,i){let e=(r.get(t)?.version??0)+1;return r.set(t,{body:n,version:e,meta:i}),{key:t,version:String(e),hash:s(n)}},async get(t){return r.get(t)?.body??null},async list(t=""){return[...r.keys()].filter(n=>n.startsWith(t))}}};export{a as memVault};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@op0ai/sdk",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "description": "The op0 SDK — an agent with a computer: a governed function under a RunSpec (goal + stop rules + verifier), typed ports, a vendor-free core. Build agents that run on op0 (op0.ai), the governed runtime for agent work. Proprietary — free to use WITH the op0 runtime.",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -36,14 +36,15 @@
36
36
  "zod": "^4.4.3"
37
37
  },
38
38
  "devDependencies": {
39
+ "esbuild": "^0.28.1",
39
40
  "vitest": "^4.1.9"
40
41
  },
41
42
  "scripts": {
42
43
  "test": "node scripts/dep-lint.mjs && vitest run",
43
44
  "typecheck": "tsgo --noEmit -p tsconfig.json",
44
45
  "build": "tsc -p tsconfig.build.json",
45
- "prepack": "node ../../scripts/publish-exports.mjs prepack",
46
- "postpack": "node ../../scripts/publish-exports.mjs postpack"
46
+ "prepack": "npm test && node scripts/build-dist.mjs prepack",
47
+ "postpack": "node scripts/build-dist.mjs postpack"
47
48
  },
48
49
  "keywords": [
49
50
  "op0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAW,SAAS,EAAE,MAAM,eAAe,CAAC;AAEhG;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,WAAW,SAAS,KAAG,OA8BpD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,KAAK,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAC,KAAG,SAGxF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,SAAS,EAAE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,KAAG,QAAQ,EAoBrH,CAAC"}
package/dist/agent.js DELETED
@@ -1,72 +0,0 @@
1
- /**
2
- * minimalHarness — model → (tool calls)* → final text, bounded by maxSteps. The agent reasons freely but can
3
- * only ACT through the `tools` it's given (which are the cord's governed ports — see portsAsTools), so an
4
- * agent-ful cord stays inside its declared scope by construction, not by prompt.
5
- */
6
- export const minimalHarness = (inference) => ({
7
- async run({ instructions, input, tools, maxSteps = 8 }) {
8
- const messages = [
9
- { role: "system", content: instructions },
10
- { role: "user", content: input },
11
- ];
12
- const byName = new Map(tools.map((t) => [t.name, t]));
13
- // Outer loop: genuinely sequential — each step's model call reads `messages`, which only gains this
14
- // step's tool results after they're appended below; there is nothing to await concurrently across steps.
15
- for (let step = 0; step < maxSteps; step++) {
16
- // oxlint-disable-next-line no-await-in-loop
17
- const r = await inference.generate({ messages, tools });
18
- if (r.toolCalls && r.toolCalls.length > 0) {
19
- // one assistant turn carrying the tool_calls, then one tool turn per result (OpenAI convention; the
20
- // adapter maps it to the provider wire format). Unknown tools are surfaced, never thrown — self-correct.
21
- messages.push({ role: "assistant", content: r.text ?? "", toolCalls: r.toolCalls });
22
- // Inner loop: kept sequential too — tools are governed ports (kv_incr etc.) whose side effects can
23
- // be order-sensitive; parallelizing would reorder effects the model issued in a specific sequence.
24
- for (const tc of r.toolCalls) {
25
- const tool = byName.get(tc.name);
26
- // oxlint-disable-next-line no-await-in-loop
27
- const result = tool ? await tool.run(tc.args) : { error: `unknown tool: ${tc.name}` };
28
- messages.push({ role: "tool", content: JSON.stringify(result), toolCallId: tc.id });
29
- }
30
- continue; // let the model see the tool results and decide next
31
- }
32
- return { output: r.text ?? "", steps: step + 1 };
33
- }
34
- throw new Error(`harness: maxSteps ${maxSteps} exhausted without a final answer`);
35
- },
36
- });
37
- /**
38
- * fakeInference — a scripted model for TDD (no network, deterministic). Pass the exact turn sequence the loop
39
- * should see: each entry is either tool calls or final text. This is how the agent loop is unit-tested; the
40
- * real adapter (AI Gateway / Anthropic) plugs into the same Inference port at deploy.
41
- */
42
- export const fakeInference = (script) => {
43
- let i = 0;
44
- return { async generate() { return script[i++] ?? { text: "(script exhausted)" }; } };
45
- };
46
- /**
47
- * portsAsTools — expose selected resource ports to the agent as callable tools. THIS is governed-tools = ports:
48
- * the agent can only act through capabilities the cord declared + the host bound. `onTool` lets the cord audit
49
- * every call (one wide-event per action). ponytail: only the ports you pass become tools — nothing else.
50
- */
51
- export const portsAsTools = (res, onTool) => {
52
- const tools = [];
53
- if (res.kv) {
54
- tools.push({
55
- name: "kv_incr",
56
- description: "Increment a durable counter by key. args: { key: string, by?: number }",
57
- parameters: { type: "object", properties: { key: { type: "string" }, by: { type: "number" } }, required: ["key"] },
58
- run: async (a) => { onTool?.("kv_incr", a); return { count: await res.kv.incr(String(a['key']), typeof a['by'] === "number" ? a['by'] : 1) }; },
59
- });
60
- }
61
- if (res.vault) {
62
- tools.push({
63
- name: "vault_put",
64
- description: "Persist a deliverable. args: { key: string, body: string }",
65
- parameters: { type: "object", properties: { key: { type: "string" }, body: { type: "string" } }, required: ["key", "body"] },
66
- run: async (a) => { onTool?.("vault_put", a); return await res.vault.put(String(a['key']), String(a['body'])); },
67
- });
68
- }
69
- // add source/sql/vector tools here as a cord needs them (ponytail: not before)
70
- return tools;
71
- };
72
- //# sourceMappingURL=agent.js.map
package/dist/agent.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAoB,EAAW,EAAE,CAAC,CAAC;IAChE,KAAK,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,GAAG,CAAC,EAAE;QACpD,MAAM,QAAQ,GAAc;YAC1B,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE;YACzC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE;SACjC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 @@
1
- // agui.ts — the cord's event layer: a typed, AG-UI-aligned stream of what the cord is doing. It is THREE things
2
- // at once: (1) the cord↔UI wire (AG-UI), (2) the observability story (one event per step — the "stack trace" the
3
- // playground renders in motion), and (3) what the thin typed client consumes. Events are plain JSON so the host
4
- // can persist them on the DO (durable → the timeline survives reload) and replay them to a reconnecting client.
5
- // Hoisted from inside createEmitter (captures nothing — pure).
6
- const now = () => Date.now();
7
- export function createEmitter(runId, sink) {
8
- const send = (event) => sink(event);
9
- return {
10
- runId,
11
- started: (threadId) => send({ type: "RUN_STARTED", runId, threadId, ts: now() }),
12
- text: (delta) => send({ type: "TEXT_MESSAGE_CONTENT", runId, delta, ts: now() }),
13
- toolStart: (toolCallId, name, args) => send({ type: "TOOL_CALL_START", runId, toolCallId, name, args, ts: now() }),
14
- toolResult: (r) => send({ type: "TOOL_CALL_RESULT", runId, ...r, ts: now() }),
15
- sourceStaged: (path) => send({ type: "SOURCE_STAGED", runId, path, ts: now() }),
16
- sourceCommitted: (paths, external) => send({ type: "SOURCE_COMMITTED", runId, paths, external, ts: now() }),
17
- stateDelta: (patch) => send({ type: "STATE_DELTA", runId, patch, ts: now() }),
18
- finished: () => send({ type: "RUN_FINISHED", runId, ts: now() }),
19
- errored: (error) => send({ type: "RUN_ERROR", runId, error, ts: now() }),
20
- };
21
- }
22
- //# sourceMappingURL=agui.js.map
package/dist/agui.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"agui.js","sourceRoot":"","sources":["../src/agui.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,iHAAiH;AACjH,gHAAgH;AAChH,gHAAgH;AAoChH,+DAA+D;AAC/D,MAAM,GAAG,GAAG,GAAW,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AAErC,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,IAAoB;IAC/D,MAAM,IAAI,GAAG,CAAC,KAAiB,EAAQ,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC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