@agentproto/runtime 0.7.0 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentproto/runtime",
3
- "version": "0.7.0",
3
+ "version": "1.0.0",
4
4
  "description": "@agentproto/runtime — long-running gateway that turns an agentproto workspace into a live runtime. Composes @agentproto/mcp-server (CRUD verbs) with HTTP transport, HEARTBEAT.md autonomy loop, and append-only conversation persistence. Drop a workspace dir, point your MCP client at it, and the agent ticks on its own.",
5
5
  "keywords": [
6
6
  "agentproto",
@@ -91,25 +91,27 @@
91
91
  "gray-matter": "^4.0.3",
92
92
  "ws": "^8.18.0",
93
93
  "zod": "^4.4.3",
94
- "@agentproto/acp": "0.5.0",
94
+ "@agentproto/acp": "0.6.0",
95
+ "@agentproto/auth": "0.1.1",
96
+ "@agentproto/driver-agent-cli": "2.0.0",
95
97
  "@agentproto/workflow": "0.1.0",
96
98
  "@agentproto/workflow-loader": "0.1.0",
97
- "@agentproto/workflow-runtime": "0.4.0",
98
- "@agentproto/provider-kit": "0.2.1",
99
- "@agentproto/provider-presets": "0.3.0",
100
- "@agentproto/eval-reporters": "0.2.1",
99
+ "@agentproto/workflow-runtime": "0.5.0",
100
+ "@agentproto/provider-kit": "0.3.0",
101
+ "@agentproto/provider-presets": "0.4.1",
102
+ "@agentproto/eval-reporters": "0.2.3",
101
103
  "@agentproto/agent": "0.2.1",
102
104
  "@agentproto/manifest": "0.2.1",
103
- "@agentproto/mcp-server": "0.2.2",
104
- "@agentproto/model-catalog": "0.4.0",
105
- "@agentproto/providers-store": "0.2.1",
105
+ "@agentproto/mcp-server": "0.2.3",
106
+ "@agentproto/model-catalog": "0.6.0",
107
+ "@agentproto/providers-store": "0.3.1",
106
108
  "@agentproto/redaction": "0.2.1",
107
- "@agentproto/sandbox": "0.1.2",
109
+ "@agentproto/sandbox": "0.1.4",
108
110
  "@agentproto/secrets": "0.2.0",
109
- "@agentproto/telemetry-langfuse": "0.2.1"
111
+ "@agentproto/telemetry-langfuse": "0.2.2"
110
112
  },
111
113
  "optionalDependencies": {
112
- "@agentproto/sandbox-e2b": "0.1.2"
114
+ "@agentproto/sandbox-e2b": "0.2.0"
113
115
  },
114
116
  "devDependencies": {
115
117
  "@types/node": "^25.6.2",
@@ -1,256 +0,0 @@
1
- import { CatalogProvider } from '@agentproto/model-catalog';
2
-
3
- /**
4
- * Pure resolver for `~/.agentproto/config.json`'s `defaults` block —
5
- * computes the effective `skills` + `options` + `auth` for an `agent_start`
6
- * spawn before adapter-specific normalization. No fs, no adapter I/O, so
7
- * it's unit-testable in isolation from `session-spawn.ts` (which owns the
8
- * fs read + the adapter-manifest lookup).
9
- *
10
- * Precedence (lowest → highest): global `defaults` < `defaults.adapters.
11
- * <slug>` < the explicit `agent_start` call.
12
- * - `options`: shallow-merged maps, later (higher-precedence) keys win.
13
- * - `skills`: global ∪ per-adapter when the caller didn't pass `skills`
14
- * at all; an explicit `skills` (even `[]`) REPLACES the union rather
15
- * than merging into it — a deliberate exact set, mirroring how an
16
- * explicit `mcpServers: []` opts out of the hermes default in
17
- * `session-spawn.ts`.
18
- * - `auth`: surfaces the RAW billing-auth material (requested mode, both
19
- * candidate credentials, per-spawn provider pin, and the `explicit`
20
- * signal) so the descriptor-aware resolver ({@link resolveAuthSpec},
21
- * which also needs the adapter's provider/subscription descriptor +
22
- * providers.json) can decide the final mode, env var, scrub set, and
23
- * credential source. Credentials are named in config or the provider
24
- * store — never read from the ambient shell env.
25
- */
26
-
27
- /**
28
- * Deterministic billing-auth config for one adapter slug (today, only
29
- * claude-code interprets it — see `AgentCliStartOptions.auth` in
30
- * `@agentproto/driver-agent-cli`). EXPLICIT credential selection, not
31
- * scrub-by-absence: `token`/`apiKey` are the actual secret values, named
32
- * here (or supplied per-spawn) rather than inherited from the launching
33
- * shell. Never logged; only a fingerprint (see {@link credentialFingerprint})
34
- * is ever surfaced back to a caller.
35
- */
36
- interface DefaultsAdapterAuthConfig {
37
- /** `"subscription"` or `"api-key"`. Omitted ⇒ the resolver picks by
38
- * ordered preference (subscription first for adapters that support it —
39
- * see {@link resolveAuthSpec}), never a hardcoded default. */
40
- mode?: "subscription" | "api-key";
41
- /** The subscription bearer token for `"subscription"` mode — minted via
42
- * `claude setup-token` (bills the Max/Pro subscription, not API credits),
43
- * SET to the adapter's `authSubscription.setEnv`. */
44
- token?: string;
45
- /** Explicit API key for `"api-key"` mode, SET to `providerEnvVar(provider)`.
46
- * Wins over the `providers.json` store key for the same provider. */
47
- apiKey?: string;
48
- /** Per-spawn provider PIN — overrides the adapter's fixed provider and the
49
- * model-derived provider (the sharp edge for by-model routers whose config
50
- * routes a catalog-"anthropic" model elsewhere). A `CatalogProvider` id. */
51
- provider?: CatalogProvider;
52
- }
53
- interface DefaultsAdapterConfig {
54
- skills?: string[];
55
- options?: Record<string, boolean | number | string>;
56
- auth?: DefaultsAdapterAuthConfig;
57
- }
58
- /** Shape of `config.json`'s top-level `defaults` block. */
59
- interface SpawnDefaultsConfig {
60
- skills?: string[];
61
- options?: Record<string, boolean | number | string>;
62
- adapters?: Record<string, DefaultsAdapterConfig>;
63
- /** Depth cutoff for the role-derived default (see `resolveRole` in
64
- * `role.ts`) applied when an `agent_start` call omits `role`:
65
- * `depth < cutoff` → supervisor, `depth >= cutoff` → executor.
66
- * Default 1 (root spawns keep today's unrestricted behaviour; any
67
- * spawn made THROUGH an orchestrator defaults to executor). Tune
68
- * this up (e.g. to a large number) to restore the old permissive
69
- * behaviour for existing deep spawns wholesale. */
70
- defaultRoleDepthCutoff?: number;
71
- /** Trust-boundary cap on pack-carried roles (see `role-registry.ts`'s
72
- * `loadRoleRegistry`): a role pack whose `toolPolicy.delegation` is
73
- * `"allow"` at a level ABOVE this cap has it forced to `"deny"` —
74
- * the pack can still declare the intent, the daemon just refuses to
75
- * grant it. Lets an operator install third-party role packs without
76
- * trusting every one of them to self-grant delegation. Undefined
77
- * (default) ⇒ no cap, any pack-declared level may carry
78
- * `delegation: "allow"` (back-compat: #214 had no such knob). */
79
- maxGrantableDelegation?: number;
80
- /** Default per-session Langfuse tracing opt-in when an `agent_start` call
81
- * omits `trace`. Default false — sessions trace only when they opt in or
82
- * this is on. See `filterSessionObserver` / `SpawnAgentInput.trace`. */
83
- langfuseTracing?: boolean;
84
- /** Redactor slug applied to traced session content before it's sent to
85
- * Langfuse (see `@agentproto/redaction`'s registry). Default "secrets"
86
- * (deny-list by key + value-scan for secret shapes). */
87
- traceRedactor?: string;
88
- }
89
- interface ResolveSpawnDefaultsInput {
90
- /** Explicit-call `skills`. Undefined ⇒ caller expressed no preference,
91
- * fall through to the config union. Provided ⇒ replaces it outright. */
92
- skills?: string[];
93
- /** Explicit-call AIP-45 `options` map — wins per-key over both the
94
- * global and per-adapter config defaults. */
95
- options?: Record<string, boolean | number | string>;
96
- /** Explicit-call `agent_start.auth` override. `mode` wins over
97
- * `defaults.adapters.<slug>.auth.mode`; the credential field matching the
98
- * RESOLVED mode wins over the matching config field. Undefined ⇒ falls
99
- * through entirely to the per-adapter config default. */
100
- auth?: DefaultsAdapterAuthConfig;
101
- }
102
- interface ResolvedSpawnDefaults {
103
- skills: string[];
104
- options: Record<string, boolean | number | string>;
105
- /** RAW billing-auth material (config precedence applied) — fed to the
106
- * descriptor-aware {@link resolveAuthSpec}, which owns the final mode /
107
- * env / scrub / credential-source decision. Both candidate credentials
108
- * are surfaced (NOT collapsed to one), since the ordered-mode selection
109
- * needs to know which are available before it picks the mode. */
110
- auth: ResolvedSpawnAuthMaterial;
111
- }
112
- interface ResolvedSpawnAuthMaterial {
113
- /** Operator-requested mode (per-spawn > per-adapter config), or undefined
114
- * ⇒ let the resolver pick by ordered preference. */
115
- requestedMode?: "subscription" | "api-key";
116
- /** True when the operator explicitly configured `auth` (per-spawn OR in
117
- * `defaults.adapters.<slug>.auth`). The ONLY way to tell "set mode, no
118
- * key" (fail-fast) from "set nothing" (ambient) — both give no credential.
119
- * DECISION 5. */
120
- explicit: boolean;
121
- /** Subscription bearer token (per-spawn > config), if configured. */
122
- subscriptionCredential?: string;
123
- /** Explicit API key (per-spawn > config), if configured — distinct from the
124
- * providers.json store key the resolver fetches separately. */
125
- apiKeyCredential?: string;
126
- /** Per-spawn provider pin, if given. */
127
- provider?: CatalogProvider;
128
- }
129
- declare function resolveSpawnDefaults(defaults: SpawnDefaultsConfig | undefined, adapterSlug: string, input: ResolveSpawnDefaultsInput): ResolvedSpawnDefaults;
130
- /**
131
- * Derive a SAFE, non-secret fingerprint for a resolved auth credential —
132
- * NEVER the raw value — for recording on the session descriptor / surfacing
133
- * in `agentproto sessions --watch` and `agent_sessions_list` (the
134
- * "verifiability" requirement: answer "what was used" without exposing the
135
- * secret). Format: `<mode> · <shape-prefix>…<last4>` when the shape is known
136
- * (e.g. `subscription · sk-ant-oat…3f9c`), else `<mode> · …<last4>`.
137
- *
138
- * The shape marker is matched from a PUBLIC key-prefix table (longest-match),
139
- * not derived from `mode` — see {@link CREDENTIAL_FINGERPRINT_PREFIXES}. Only
140
- * the matched prefix + the last 4 characters are ever surfaced, never the
141
- * middle (mirrors GitHub's `ghp_…abcd` style).
142
- */
143
- declare function credentialFingerprint(mode: "subscription" | "api-key", credential: string): string;
144
- /**
145
- * The adapter's billing-auth capability, projected from its AIP-45 manifest
146
- * (`provider` / `authEnforce` / `authSubscription`) by the host resolver. The
147
- * runtime reads THIS, never the manifest directly — keeping the LLM-catalog
148
- * coupling in the runtime and the driver mechanical.
149
- */
150
- interface AdapterAuthDescriptor {
151
- /** FIXED provider for a single-provider adapter; omitted for by-model
152
- * routers (provider then derives from the requested model). */
153
- provider?: CatalogProvider;
154
- /** Enforcement policy — `"always"` engages every spawn (claude-code's
155
- * #312 fail-fast); `"when-configured"` (default) only when `explicit`. */
156
- authEnforce?: "always" | "when-configured";
157
- /** Subscription (OAuth/bearer) support. Presence ⇒ the adapter supports
158
- * `"subscription"` mode. Mirrors the driver's `AgentCliAuthSubscription`. */
159
- authSubscription?: {
160
- setEnv: string;
161
- conflictEnv?: string[];
162
- unsetEnvAdd?: string[];
163
- };
164
- }
165
- /** The fully-resolved spec the driver applies mechanically. Structurally
166
- * matches `@agentproto/driver-agent-cli`'s `ResolvedAuthSpec` (each package
167
- * owns its own copy; the object flows across the boundary by shape). */
168
- interface ResolvedAuthSpec {
169
- mode: "subscription" | "api-key";
170
- credential?: string;
171
- setEnv: string;
172
- unsetEnv: string[];
173
- explicit: boolean;
174
- enforce: "always" | "when-configured";
175
- }
176
- /** Where the resolved credential came from — the observable billing axis
177
- * (DECISION 10②), never inferred. */
178
- type CredentialSource = "explicit-config" | "providers-store" | "none";
179
- /**
180
- * The OBSERVABLE echo (DECISION 9③ / 10②) — recorded on the session
181
- * descriptor so a verifier checks the RESOLUTION, never the model's
182
- * self-report. Never carries the raw credential (only its fingerprint).
183
- */
184
- interface AuthEcho {
185
- provider: CatalogProvider;
186
- authMode: "subscription" | "api-key";
187
- credentialSource: CredentialSource;
188
- setEnv: string;
189
- fingerprint?: string;
190
- }
191
- /**
192
- * Thrown when the operator requested a billing mode the adapter can't serve —
193
- * today only `"subscription"` on an adapter with no `authSubscription`. A
194
- * LOUD, distinct failure (DECISION 4②), never a silent downgrade to api-key.
195
- */
196
- declare class AuthResolutionError extends Error {
197
- readonly code = "unsupported_auth_mode";
198
- constructor(message: string);
199
- }
200
- interface ResolveAuthSpecInput {
201
- descriptor: AdapterAuthDescriptor;
202
- /** `input.model ?? adapter default model` — for model-derived provider. */
203
- model?: string;
204
- /** Per-spawn provider pin (`input.auth.provider`). */
205
- requestedProvider?: CatalogProvider;
206
- /** Operator-requested mode; undefined ⇒ ordered preference. */
207
- requestedMode?: "subscription" | "api-key";
208
- /** Operator explicitly configured `auth` (DECISION 5). */
209
- explicit: boolean;
210
- /** Subscription bearer credential, if configured. */
211
- subscriptionCredential?: string;
212
- /** Explicit api-key credential from config, if configured. */
213
- apiKeyConfigCredential?: string;
214
- /** api-key credential from `providers.json` (fetched by the caller). */
215
- apiKeyStoreCredential?: string;
216
- }
217
- /**
218
- * THE billing-auth resolver (DECISIONS 4, 6, 9, 10). Pure: given the adapter
219
- * descriptor + raw config material + (caller-fetched) store key, it decides
220
- * the provider, the mode (ordered — subscription over api-key when a
221
- * subscription credential is present; a requested-but-unsupported mode throws
222
- * `unsupported_auth_mode`), the env var to SET, the derived SCRUB set, and the
223
- * credential + its source. Returns the driver `spec` + the observable `echo`,
224
- * or `undefined` when no provider resolves (⇒ ambient, no injection — never
225
- * guess). NEVER falls back to a default provider/model. Fail-loud on a
226
- * configured-but-missing credential is deferred to the driver's mechanical
227
- * apply (it engages then throws `missing_auth_credential`), so the `explicit`
228
- * / `enforce` signals are carried through on the spec.
229
- */
230
- declare function resolveAuthSpec(input: ResolveAuthSpecInput): {
231
- spec: ResolvedAuthSpec;
232
- echo: AuthEcho;
233
- } | undefined;
234
- /** Manifest-declared AIP-45 option id + type, the minimum an adapter
235
- * resolver needs to expose for `normalizeSkillsOption` below. Mirrors
236
- * `AgentCliOption`'s `id`/`type` fields without importing
237
- * `@agentproto/driver-agent-cli` into the runtime package. */
238
- interface DeclaredAdapterOption {
239
- id: string;
240
- type: "boolean" | "integer" | "string" | "enum";
241
- }
242
- /**
243
- * Fold the resolved `skills` list into `options.skills` using whatever
244
- * shape the adapter's manifest declares for that option id (today, only
245
- * `type: "string"` exists for a skills-shaped option — e.g. hermes'
246
- * comma-joined `--skills a,b`). Adapters with no declared `skills` option
247
- * (e.g. claude-code, which auto-discovers from `~/.claude/skills`) are a
248
- * documented no-op — the effective skills list has nowhere to go, so it's
249
- * dropped rather than guessing a flag the manifest didn't declare.
250
- *
251
- * An `options.skills` already present (from config defaults or the
252
- * explicit call) is respected as-is and never overwritten here.
253
- */
254
- declare function normalizeSkillsOption(skills: string[], options: Record<string, boolean | number | string>, declaredOptions: readonly DeclaredAdapterOption[] | undefined): Record<string, boolean | number | string>;
255
-
256
- export { type AdapterAuthDescriptor as A, type CredentialSource as C, type DeclaredAdapterOption as D, type ResolvedAuthSpec as R, type SpawnDefaultsConfig as S, type AuthEcho as a, AuthResolutionError as b, type DefaultsAdapterAuthConfig as c, type DefaultsAdapterConfig as d, type ResolvedSpawnAuthMaterial as e, type ResolvedSpawnDefaults as f, credentialFingerprint as g, resolveSpawnDefaults as h, normalizeSkillsOption as n, resolveAuthSpec as r };