@op0ai/sdk 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 +38 -0
- package/README.md +28 -0
- package/dist/agent.d.ts +23 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +72 -0
- package/dist/agent.js.map +1 -0
- package/dist/agui.d.ts +87 -0
- package/dist/agui.d.ts.map +1 -0
- package/dist/agui.js +22 -0
- package/dist/agui.js.map +1 -0
- package/dist/config.d.ts +76 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +38 -0
- package/dist/config.js.map +1 -0
- package/dist/data.d.ts +168 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +211 -0
- package/dist/data.js.map +1 -0
- package/dist/define.d.ts +30 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +87 -0
- package/dist/define.js.map +1 -0
- package/dist/distill.d.ts +68 -0
- package/dist/distill.d.ts.map +1 -0
- package/dist/distill.js +113 -0
- package/dist/distill.js.map +1 -0
- package/dist/events.d.ts +39 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +25 -0
- package/dist/events.js.map +1 -0
- package/dist/evlog.d.ts +71 -0
- package/dist/evlog.d.ts.map +1 -0
- package/dist/evlog.js +124 -0
- package/dist/evlog.js.map +1 -0
- package/dist/guards.d.ts +61 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +88 -0
- package/dist/guards.js.map +1 -0
- package/dist/hash.d.ts +6 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +18 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +120 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +175 -0
- package/dist/index.js.map +1 -0
- package/dist/platform.d.ts +97 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +10 -0
- package/dist/platform.js.map +1 -0
- package/dist/session.d.ts +47 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +88 -0
- package/dist/session.js.map +1 -0
- package/dist/source.d.ts +65 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +96 -0
- package/dist/source.js.map +1 -0
- package/dist/tool.d.ts +43 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +16 -0
- package/dist/tool.js.map +1 -0
- package/dist/usectx.d.ts +93 -0
- package/dist/usectx.d.ts.map +1 -0
- package/dist/usectx.js +220 -0
- package/dist/usectx.js.map +1 -0
- package/dist/vault.d.ts +21 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +25 -0
- package/dist/vault.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,4GAA4G;AAC5G,2GAA2G;AAC3G,4GAA4G;AAC5G,+GAA+G;AAC/G,uDAAuD;AA0CvD,MAAM,OAAO,GAAG,UAAU,CAAC;AAE3B,0GAA0G;AAC1G,MAAM,UAAU,mBAAmB,CAAC,OAKnC;IACC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACrC,MAAM,EAAE,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACxF,MAAM,aAAa,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;IAElC,OAAO;QACL,KAAK,CAAC,IAAI,CAAC,IAAI;YACb,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;YACzC,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC7C,CAAC;QAED,KAAK,CAAC,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AAI,CAAC,IAAI,EAAE,CAAC;gBAC1C,IAAI,GAAuB,CAAC;gBAC5B,4CAA4C;gBAC5C,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,GAAG,QAAQ,kBAAkB,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;gBACpF,4CAA4C;gBAC5C,IAAI,IAAI,CAAC,EAAE;oBAAE,GAAG,GAAI,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAsB,CAAC,GAAG,CAAC;gBACjE,4CAA4C;gBAC5C,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE;oBAC7B,MAAM,EAAE,KAAK;oBACb,OAAO;oBACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,OAAO,EAAE,gBAAgB,IAAI,CAAC,IAAI,EAAE;wBACpC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;wBAC5B,MAAM;wBACN,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBACxB,CAAC;iBACH,CAAC,CAAC;gBACH,IAAI,GAAG,CAAC,EAAE;oBAAE,SAAS,IAAI,CAAC,CAAC;YAC7B,CAAC;YACD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,EAAE,EAAE,CAAC;QAChG,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/tool.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { Source } from "./source.ts";
|
|
3
|
+
import type { Emitter } from "./agui.ts";
|
|
4
|
+
import type { WideSink } from "./evlog.ts";
|
|
5
|
+
/**
|
|
6
|
+
* What a tool's `execute` receives: the cord's typed env/bindings, its Source, the AG-UI event emitter (the UI
|
|
7
|
+
* timeline lane), an optional evlog `wide` sink (the ops+audit lane — Analytics Engine + tamper-evident audit),
|
|
8
|
+
* and an abort signal. `emit` and `wide` share the run's id, so the two lanes correlate.
|
|
9
|
+
*/
|
|
10
|
+
export interface ToolContext<Env = unknown> {
|
|
11
|
+
readonly env: Env;
|
|
12
|
+
readonly source: Source;
|
|
13
|
+
readonly emit: Emitter;
|
|
14
|
+
readonly wide?: WideSink;
|
|
15
|
+
readonly signal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
/** A governed tool. `inputSchema` is the zod schema (function-calling models need its JSON-schema). */
|
|
18
|
+
export interface Tool<Env = unknown> {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly description: string;
|
|
21
|
+
readonly inputSchema: z.ZodType;
|
|
22
|
+
/** Input is typed at authoring time via {@link defineTool}; erased here so a registry can be heterogeneous. */
|
|
23
|
+
readonly execute: (args: never, context: ToolContext<Env>) => Promise<unknown>;
|
|
24
|
+
}
|
|
25
|
+
/** A cord's tool registry: a name → Tool map. */
|
|
26
|
+
export type ToolSet<Env = unknown> = Record<string, Tool<Env>>;
|
|
27
|
+
/**
|
|
28
|
+
* Author a governed tool with full input inference: `execute(args, ctx)` gets `z.infer<Input>`.
|
|
29
|
+
* The `Env` type param ties the tool to its cord's typed bindings.
|
|
30
|
+
*/
|
|
31
|
+
export declare function defineTool<Input extends z.ZodType, Env = unknown>(spec: {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
input: Input;
|
|
35
|
+
execute: (args: z.infer<Input>, context: ToolContext<Env>) => Promise<unknown>;
|
|
36
|
+
}): Tool<Env>;
|
|
37
|
+
/** Manifest form of a tool (for cord.json / discovery). */
|
|
38
|
+
export interface ToolManifestEntry {
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly description: string;
|
|
41
|
+
}
|
|
42
|
+
export declare function toolManifest<Env>(tools: ToolSet<Env>): ToolManifestEntry[];
|
|
43
|
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AE,IAAI,EAAE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAChF,GAAG,IAAI,CAAC,GAAG,CAAC,CAOZ;AAED,2DAA2D;AAC3D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,iBAAiB,EAAE,CAE1E"}
|
package/dist/tool.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Author a governed tool with full input inference: `execute(args, ctx)` gets `z.infer<Input>`.
|
|
3
|
+
* The `Env` type param ties the tool to its cord's typed bindings.
|
|
4
|
+
*/
|
|
5
|
+
export function defineTool(spec) {
|
|
6
|
+
return {
|
|
7
|
+
name: spec.name,
|
|
8
|
+
description: spec.description,
|
|
9
|
+
inputSchema: spec.input,
|
|
10
|
+
execute: spec.execute,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function toolManifest(tools) {
|
|
14
|
+
return Object.values(tools).map((t) => ({ name: t.name, description: t.description }));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=tool.js.map
|
package/dist/tool.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAmCA;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAyC,IAKlE;IACC,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,IAAI,CAAC,KAAK;QACvB,OAAO,EAAE,IAAI,CAAC,OAA+B;KAC9C,CAAC;AACJ,CAAC;AAQD,MAAM,UAAU,YAAY,CAAM,KAAmB;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AACzF,CAAC"}
|
package/dist/usectx.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** A resolved Source: a flat, posix-relative file view of a target. The cord depends ONLY on this. */
|
|
2
|
+
export interface FileSet {
|
|
3
|
+
/** does this path exist (file or dir), relative to the target root */
|
|
4
|
+
exists(path: string): Promise<boolean>;
|
|
5
|
+
/** utf-8 contents of a file, or null if absent/unreadable */
|
|
6
|
+
read(path: string): Promise<string | null>;
|
|
7
|
+
/** every tracked FILE path (recursive, posix-relative); excludes .git / node_modules */
|
|
8
|
+
paths(): Promise<string[]>;
|
|
9
|
+
}
|
|
10
|
+
/** THE usectx boundary: resolve a target to a FileSet. */
|
|
11
|
+
export type Acquire = (target: string) => Promise<FileSet>;
|
|
12
|
+
/** Build a FileSet from an in-memory path→content map. The non-repo Sources (an evlog trace, an R2 snapshot) resolve to this. */
|
|
13
|
+
export declare function fileSetOf(files: Record<string, string>): FileSet;
|
|
14
|
+
export type TargetKind = "repo" | "url" | "fs" | "evlog" | "r2" | "zip" | "unknown";
|
|
15
|
+
/** Detect a target's kind so the resolver can route it to the right connection (Notion §7 open item, made concrete). */
|
|
16
|
+
export declare function classifyTarget(target: string): TargetKind;
|
|
17
|
+
/** Acquire a PUBLIC repo over HTTPS (Git Trees API + raw contents). 403/404/truncation LOUD-FAIL (never score an empty/partial tree). */
|
|
18
|
+
export declare const acquireGitHub: (token?: string) => Acquire;
|
|
19
|
+
/**
|
|
20
|
+
* The github connection surface usectx needs from the connections engine (executor). The host implements this
|
|
21
|
+
* (wired to executor's `github_v3_rest_api` connection — verified live 2026-06-29); @op0-ai/cord stays dep-free.
|
|
22
|
+
* This is the authed path: 5000/hr, dedicated identity, redaction/audit at the connection.
|
|
23
|
+
*/
|
|
24
|
+
export interface GithubConnection {
|
|
25
|
+
reposGet(o: {
|
|
26
|
+
owner: string;
|
|
27
|
+
repo: string;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
default_branch?: string;
|
|
30
|
+
}>;
|
|
31
|
+
gitGetTree(o: {
|
|
32
|
+
owner: string;
|
|
33
|
+
repo: string;
|
|
34
|
+
tree_sha: string;
|
|
35
|
+
recursive: "1";
|
|
36
|
+
}): Promise<{
|
|
37
|
+
tree?: Array<{
|
|
38
|
+
path: string;
|
|
39
|
+
type: string;
|
|
40
|
+
}>;
|
|
41
|
+
truncated?: boolean;
|
|
42
|
+
}>;
|
|
43
|
+
reposGetContent(o: {
|
|
44
|
+
owner: string;
|
|
45
|
+
repo: string;
|
|
46
|
+
path: string;
|
|
47
|
+
ref: string;
|
|
48
|
+
}): Promise<{
|
|
49
|
+
content?: string;
|
|
50
|
+
encoding?: string;
|
|
51
|
+
} | null>;
|
|
52
|
+
}
|
|
53
|
+
/** Acquire a repo's FileSet through an executor github connection (the authed, by-design path). */
|
|
54
|
+
export declare const acquireExecutor: (conn: GithubConnection) => Acquire;
|
|
55
|
+
/** Acquire a single live URL as a one-file FileSet (path "" or the URL's basename). */
|
|
56
|
+
export declare const acquireHttp: Acquire;
|
|
57
|
+
/** Acquire a local checkout over node:fs (LOCAL/CLI/tests only; lazy import keeps the module Worker-safe). */
|
|
58
|
+
export declare const acquireFs: Acquire;
|
|
59
|
+
/** A custom Source resolver for a target kind (e.g. evlog: / r2: / a registry handle). */
|
|
60
|
+
export type SourceResolver = (target: string) => Promise<FileSet>;
|
|
61
|
+
export interface UsectxConfig {
|
|
62
|
+
/** authed by-design path; preferred for repos when present */
|
|
63
|
+
executor?: GithubConnection;
|
|
64
|
+
/** public HTTPS bootstrap for repos; token lifts the rate limit */
|
|
65
|
+
github?: {
|
|
66
|
+
token?: string;
|
|
67
|
+
};
|
|
68
|
+
/** allow live-URL acquisition */
|
|
69
|
+
http?: boolean;
|
|
70
|
+
/** allow local-fs acquisition (Node/CLI) */
|
|
71
|
+
fs?: boolean;
|
|
72
|
+
/** custom resolvers by kind — the non-repo Sources (evlog / r2 / zip / handle) */
|
|
73
|
+
resolvers?: Partial<Record<TargetKind, SourceResolver>>;
|
|
74
|
+
/** in-band redaction applied to every read() (scrub secrets/PII before content leaves the boundary) */
|
|
75
|
+
redact?: (text: string | null, ctx: {
|
|
76
|
+
target: string;
|
|
77
|
+
path: string;
|
|
78
|
+
}) => string | null;
|
|
79
|
+
/** in-band audit hook fired on each acquire + read (the connection's audit lane) */
|
|
80
|
+
audit?: (entry: {
|
|
81
|
+
op: "acquire" | "read";
|
|
82
|
+
target: string;
|
|
83
|
+
kind: TargetKind;
|
|
84
|
+
path?: string;
|
|
85
|
+
}) => void;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Build the usectx boundary. `acquire(target)` classifies the target, routes it to the right adapter
|
|
89
|
+
* (executor preferred for repos, else github; custom resolvers for evlog/r2/zip/url/fs), and wraps the
|
|
90
|
+
* resulting FileSet with in-band redaction + audit. This is the one acquisition primitive a cord uses.
|
|
91
|
+
*/
|
|
92
|
+
export declare function usectx(config?: UsectxConfig): Acquire;
|
|
93
|
+
//# sourceMappingURL=usectx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usectx.d.ts","sourceRoot":"","sources":["../src/usectx.ts"],"names":[],"mappings":"AAaA,sGAAsG;AACtG,MAAM,WAAW,OAAO;IACtB,sEAAsE;IACtE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,6DAA6D;IAC7D,IAAI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QAAC,IAAI,EAAE,UAAU,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACtG;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,MAAM,GAAE,YAAiB,GAAG,OAAO,CAiCzD"}
|
package/dist/usectx.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// usectx.ts — the context-acquisition seam: how a cord ACQUIRES context (the READ-side Source). This is the
|
|
2
|
+
// usectx boundary (Notion: "usectx + the Source contract"). A cord does NOT reach the world directly; it asks
|
|
3
|
+
// usectx for a target, and usectx resolves it via the right connection (auth · rate-limit · redaction · audit
|
|
4
|
+
// in-band). The whole boundary is one function: acquire(target) => FileSet.
|
|
5
|
+
//
|
|
6
|
+
// const acquire = usectx({ github: { token }, executor, redact, audit });
|
|
7
|
+
// const fs = await acquire("github.com/op0ai/op0dotdev"); // → FileSet (exists/read/paths)
|
|
8
|
+
//
|
|
9
|
+
// A repo is one kind of Source; an evlog trace, an R2 snapshot, a zip, a live URL are others behind the SAME
|
|
10
|
+
// seam (custom resolvers). Pure TS, zero static deps (Node fs is loaded lazily so the module stays Worker-safe).
|
|
11
|
+
// Sibling to source.ts: source.ts is the WRITE/commit Source (bidirectionalSource); usectx is the READ/context
|
|
12
|
+
// Source. Pairs with executor as the authed, by-design connection backend (the interim engine toward hosted usectx).
|
|
13
|
+
const norm = (p) => p.replace(/^\.?\/+/, "").replace(/\/+$/, "");
|
|
14
|
+
// ---------- in-memory FileSet (for evlog / R2 / zip Sources + tests) ----------
|
|
15
|
+
/** Build a FileSet from an in-memory path→content map. The non-repo Sources (an evlog trace, an R2 snapshot) resolve to this. */
|
|
16
|
+
export function fileSetOf(files) {
|
|
17
|
+
const map = new Map(Object.entries(files).map(([k, v]) => [norm(k), v]));
|
|
18
|
+
return {
|
|
19
|
+
async exists(p) {
|
|
20
|
+
const k = norm(p);
|
|
21
|
+
if (map.has(k))
|
|
22
|
+
return true;
|
|
23
|
+
for (const key of map.keys())
|
|
24
|
+
if (key.startsWith(k + "/"))
|
|
25
|
+
return true; // dir
|
|
26
|
+
return false;
|
|
27
|
+
},
|
|
28
|
+
async read(p) {
|
|
29
|
+
const v = map.get(norm(p));
|
|
30
|
+
return v ?? null;
|
|
31
|
+
},
|
|
32
|
+
async paths() {
|
|
33
|
+
return [...map.keys()];
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Detect a target's kind so the resolver can route it to the right connection (Notion §7 open item, made concrete). */
|
|
38
|
+
export function classifyTarget(target) {
|
|
39
|
+
const t = target.trim();
|
|
40
|
+
if (t.startsWith("evlog:"))
|
|
41
|
+
return "evlog";
|
|
42
|
+
if (t.startsWith("r2:"))
|
|
43
|
+
return "r2";
|
|
44
|
+
if (/\.zip($|\?)/i.test(t))
|
|
45
|
+
return "zip";
|
|
46
|
+
if (/^git@github\.com:|github\.com[/:]/.test(t) || /^[\w.-]+\/[\w.-]+$/.test(t))
|
|
47
|
+
return "repo";
|
|
48
|
+
if (/^https?:\/\//.test(t))
|
|
49
|
+
return "url";
|
|
50
|
+
if (/^(\.\/|\/|[a-zA-Z]:\\)/.test(t) || t === ".")
|
|
51
|
+
return "fs";
|
|
52
|
+
return "unknown";
|
|
53
|
+
}
|
|
54
|
+
// ---------- github adapter (raw HTTPS — the public, no-auth bootstrap; Worker + Node) ----------
|
|
55
|
+
const parseRepo = (target) => {
|
|
56
|
+
const m = target.trim().replace(/\.git$/, "").match(/(?:github\.com[/:])?([^/\s]+)\/([^/\s]+)\/?$/);
|
|
57
|
+
const owner = m?.[1];
|
|
58
|
+
const repo = m?.[2];
|
|
59
|
+
if (!owner || !repo)
|
|
60
|
+
throw new Error(`not a github repo target: ${target}`);
|
|
61
|
+
return { owner, repo };
|
|
62
|
+
};
|
|
63
|
+
const ghFetch = async (url, headers) => {
|
|
64
|
+
const r = await fetch(url, { headers });
|
|
65
|
+
if (r.status === 403 || r.status === 429) {
|
|
66
|
+
const remaining = r.headers.get("x-ratelimit-remaining");
|
|
67
|
+
throw new Error(`github ${r.status} for ${url}` +
|
|
68
|
+
(remaining === "0" ? " — rate limit exhausted; set a token to lift 60→5000/hr (or use executor)" : " (forbidden/auth)"));
|
|
69
|
+
}
|
|
70
|
+
return { status: r.status, json: r.ok ? await r.json() : null };
|
|
71
|
+
};
|
|
72
|
+
/** Acquire a PUBLIC repo over HTTPS (Git Trees API + raw contents). 403/404/truncation LOUD-FAIL (never score an empty/partial tree). */
|
|
73
|
+
export const acquireGitHub = (token) => async (target) => {
|
|
74
|
+
const { owner, repo } = parseRepo(target);
|
|
75
|
+
const gh = {
|
|
76
|
+
"user-agent": "op0-cord-usectx",
|
|
77
|
+
accept: "application/vnd.github+json",
|
|
78
|
+
...(token ? { authorization: `Bearer ${token}` } : {}),
|
|
79
|
+
};
|
|
80
|
+
const meta = await ghFetch(`https://api.github.com/repos/${owner}/${repo}`, gh);
|
|
81
|
+
if (meta.status === 404)
|
|
82
|
+
throw new Error(`github repo not found: ${owner}/${repo}`);
|
|
83
|
+
const branch = meta.json?.default_branch ?? "main";
|
|
84
|
+
const treeRes = await ghFetch(`https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}?recursive=1`, gh);
|
|
85
|
+
if (treeRes.status === 404)
|
|
86
|
+
throw new Error(`github tree not found: ${owner}/${repo}@${branch}`);
|
|
87
|
+
const tree = treeRes.json ?? { tree: [] };
|
|
88
|
+
if (tree.truncated === true)
|
|
89
|
+
throw new Error(`github tree truncated for ${owner}/${repo}@${branch} — needs paged acquisition / a token (use executor)`);
|
|
90
|
+
const files = new Set(), dirs = new Set();
|
|
91
|
+
for (const n of tree.tree ?? [])
|
|
92
|
+
(n.type === "tree" ? dirs : files).add(norm(n.path));
|
|
93
|
+
const cache = new Map();
|
|
94
|
+
return {
|
|
95
|
+
async exists(p) { const k = norm(p); return files.has(k) || dirs.has(k); },
|
|
96
|
+
async paths() { return [...files]; },
|
|
97
|
+
async read(p) {
|
|
98
|
+
const k = norm(p);
|
|
99
|
+
if (!files.has(k))
|
|
100
|
+
return null;
|
|
101
|
+
if (cache.has(k))
|
|
102
|
+
return cache.get(k) ?? null;
|
|
103
|
+
const txt = await fetch(`https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${k}`, {
|
|
104
|
+
headers: { "user-agent": "op0-cord-usectx" },
|
|
105
|
+
}).then((r) => (r.ok ? r.text() : null));
|
|
106
|
+
cache.set(k, txt);
|
|
107
|
+
return txt;
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
/** Acquire a repo's FileSet through an executor github connection (the authed, by-design path). */
|
|
112
|
+
export const acquireExecutor = (conn) => async (target) => {
|
|
113
|
+
const { owner, repo } = parseRepo(target);
|
|
114
|
+
const meta = await conn.reposGet({ owner, repo });
|
|
115
|
+
const branch = meta.default_branch ?? "main";
|
|
116
|
+
const treeRes = await conn.gitGetTree({ owner, repo, tree_sha: branch, recursive: "1" });
|
|
117
|
+
if (treeRes.truncated === true)
|
|
118
|
+
throw new Error(`github tree truncated for ${owner}/${repo}@${branch} via executor — needs paged acquisition`);
|
|
119
|
+
const files = new Set(), dirs = new Set();
|
|
120
|
+
for (const n of treeRes.tree ?? [])
|
|
121
|
+
(n.type === "tree" ? dirs : files).add(norm(n.path));
|
|
122
|
+
const cache = new Map();
|
|
123
|
+
return {
|
|
124
|
+
async exists(p) { const k = norm(p); return files.has(k) || dirs.has(k); },
|
|
125
|
+
async paths() { return [...files]; },
|
|
126
|
+
async read(p) {
|
|
127
|
+
const k = norm(p);
|
|
128
|
+
if (!files.has(k))
|
|
129
|
+
return null;
|
|
130
|
+
if (cache.has(k))
|
|
131
|
+
return cache.get(k) ?? null;
|
|
132
|
+
const r = await conn.reposGetContent({ owner, repo, path: k, ref: branch });
|
|
133
|
+
const txt = r?.content ? (r.encoding === "base64" ? atob(r.content.replace(/\n/g, "")) : r.content) : null;
|
|
134
|
+
cache.set(k, txt);
|
|
135
|
+
return txt;
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
// ---------- http + fs adapters (a live URL · a local checkout) ----------
|
|
140
|
+
/** Acquire a single live URL as a one-file FileSet (path "" or the URL's basename). */
|
|
141
|
+
export const acquireHttp = async (target) => {
|
|
142
|
+
const res = await fetch(target, { headers: { "user-agent": "op0-cord-usectx" } });
|
|
143
|
+
if (!res.ok)
|
|
144
|
+
throw new Error(`usectx http ${res.status} for ${target}`);
|
|
145
|
+
const body = await res.text();
|
|
146
|
+
const name = norm(new URL(target).pathname.split("/").pop() || "index");
|
|
147
|
+
return fileSetOf({ [name || "index"]: body });
|
|
148
|
+
};
|
|
149
|
+
/** Acquire a local checkout over node:fs (LOCAL/CLI/tests only; lazy import keeps the module Worker-safe). */
|
|
150
|
+
export const acquireFs = async (dir) => {
|
|
151
|
+
const { existsSync, readFileSync, readdirSync } = await import("node:fs");
|
|
152
|
+
const { join, relative, sep } = await import("node:path");
|
|
153
|
+
const IGNORED = /(^|\/)(\.git|node_modules)(\/|$)/;
|
|
154
|
+
return {
|
|
155
|
+
async exists(p) { return existsSync(join(dir, p)); },
|
|
156
|
+
async read(p) { try {
|
|
157
|
+
return readFileSync(join(dir, p), "utf8");
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return null;
|
|
161
|
+
} },
|
|
162
|
+
async paths() {
|
|
163
|
+
try {
|
|
164
|
+
return readdirSync(dir, { recursive: true, withFileTypes: true })
|
|
165
|
+
.filter((d) => d.isFile())
|
|
166
|
+
.map((d) => relative(dir, join((d.parentPath ?? d.path), d.name)).split(sep).join("/"))
|
|
167
|
+
.filter((p) => !IGNORED.test(p));
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Build the usectx boundary. `acquire(target)` classifies the target, routes it to the right adapter
|
|
177
|
+
* (executor preferred for repos, else github; custom resolvers for evlog/r2/zip/url/fs), and wraps the
|
|
178
|
+
* resulting FileSet with in-band redaction + audit. This is the one acquisition primitive a cord uses.
|
|
179
|
+
*/
|
|
180
|
+
export function usectx(config = {}) {
|
|
181
|
+
const repoAcquire = config.executor
|
|
182
|
+
? acquireExecutor(config.executor)
|
|
183
|
+
: acquireGitHub(config.github?.token);
|
|
184
|
+
const pick = (kind, target) => {
|
|
185
|
+
const custom = config.resolvers?.[kind];
|
|
186
|
+
if (custom)
|
|
187
|
+
return custom(target);
|
|
188
|
+
switch (kind) {
|
|
189
|
+
case "repo": return repoAcquire(target);
|
|
190
|
+
case "url":
|
|
191
|
+
if (config.http)
|
|
192
|
+
return acquireHttp(target);
|
|
193
|
+
break;
|
|
194
|
+
case "fs":
|
|
195
|
+
if (config.fs)
|
|
196
|
+
return acquireFs(target);
|
|
197
|
+
break;
|
|
198
|
+
default: break;
|
|
199
|
+
}
|
|
200
|
+
throw new Error(`usectx: no resolver bound for target kind "${kind}" (${target})`);
|
|
201
|
+
};
|
|
202
|
+
return async (target) => {
|
|
203
|
+
const kind = classifyTarget(target);
|
|
204
|
+
config.audit?.({ op: "acquire", target, kind });
|
|
205
|
+
const base = await pick(kind, target);
|
|
206
|
+
if (!config.redact && !config.audit)
|
|
207
|
+
return base;
|
|
208
|
+
// wrap read() with redaction + audit; exists/paths pass through
|
|
209
|
+
return {
|
|
210
|
+
exists: base.exists.bind(base),
|
|
211
|
+
paths: base.paths.bind(base),
|
|
212
|
+
read: async (p) => {
|
|
213
|
+
config.audit?.({ op: "read", target, kind, path: p });
|
|
214
|
+
const raw = await base.read(p);
|
|
215
|
+
return config.redact ? config.redact(raw, { target, path: p }) : raw;
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=usectx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usectx.js","sourceRoot":"","sources":["../src/usectx.ts"],"names":[],"mappings":"AA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,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5B,IAAI,EAAE,KAAK,EAAE,CAAS,EAAE,EAAE;gBACxB,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;gBACtD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YACvE,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/vault.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,KAAK;IACpB,yGAAyG;IACzG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxH,yDAAyD;IACzD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,gCAAgC;IAChC,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CAC1C;AAED,0GAA0G;AAC1G,eAAO,MAAM,QAAQ,QAAO,KAAK,GAAG;IAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;CAgB1G,CAAC"}
|
package/dist/vault.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.js","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,4GAA4G;AAC5G,uGAAuG;AACvG,4GAA4G;AAC5G,wCAAwC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,0GAA0G;AAC1G,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAsF,EAAE;IAC9G,MAAM,KAAK,GAAG,IAAI,GAAG,EAA6D,CAAC;IACnF,OAAO;QACL,KAAK;QACL,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI;YACvB,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YACnD,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YACxC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChE,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,GAAG;YACX,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,IAAI,IAAI,CAAC;QACtC,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE;YACpB,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAC/D,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@op0ai/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
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
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./guards": {
|
|
14
|
+
"types": "./dist/guards.d.ts",
|
|
15
|
+
"default": "./dist/guards.js"
|
|
16
|
+
},
|
|
17
|
+
"./vault": {
|
|
18
|
+
"types": "./dist/vault.d.ts",
|
|
19
|
+
"default": "./dist/vault.js"
|
|
20
|
+
},
|
|
21
|
+
"./hash": {
|
|
22
|
+
"types": "./dist/hash.d.ts",
|
|
23
|
+
"default": "./dist/hash.js"
|
|
24
|
+
},
|
|
25
|
+
"./session": {
|
|
26
|
+
"types": "./dist/session.d.ts",
|
|
27
|
+
"default": "./dist/session.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"zod": "^4.4.3"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"vitest": "^4.1.9"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"test": "node scripts/dep-lint.mjs && vitest run --passWithNoTests",
|
|
43
|
+
"typecheck": "tsgo --noEmit -p tsconfig.json",
|
|
44
|
+
"build": "tsc -p tsconfig.build.json",
|
|
45
|
+
"prepack": "node scripts/sync-sdk.mjs && node ../../scripts/publish-exports.mjs prepack",
|
|
46
|
+
"postpack": "node ../../scripts/publish-exports.mjs postpack"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"op0",
|
|
50
|
+
"agents",
|
|
51
|
+
"agent",
|
|
52
|
+
"runtime",
|
|
53
|
+
"runspec",
|
|
54
|
+
"governance",
|
|
55
|
+
"cloudflare",
|
|
56
|
+
"workers",
|
|
57
|
+
"fleet"
|
|
58
|
+
],
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "git",
|
|
61
|
+
"url": "git+https://github.com/op0ai/op0dotdev.git",
|
|
62
|
+
"directory": "packages/sdk"
|
|
63
|
+
},
|
|
64
|
+
"homepage": "https://op0.ai",
|
|
65
|
+
"bugs": {
|
|
66
|
+
"url": "https://github.com/op0ai/op0dotdev/issues"
|
|
67
|
+
},
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": ">=18"
|
|
70
|
+
},
|
|
71
|
+
"publishConfig": {
|
|
72
|
+
"access": "public"
|
|
73
|
+
},
|
|
74
|
+
"types": "./dist/index.d.ts"
|
|
75
|
+
}
|