@tangle-network/cli-agent-registry 0.0.0-stage → 0.15.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 +11 -0
- package/README.md +175 -2
- package/dist/backend-types-CNo_Zj_K.mjs +36 -0
- package/dist/backend-types-DRmLR1e0.d.mts +47 -0
- package/dist/backend-types.d.mts +2 -0
- package/dist/backend-types.mjs +2 -0
- package/dist/cli-auth-bundle-C6DtK7GX.mjs +95 -0
- package/dist/cli-auth-bundle-CwAaH0Ap.d.mts +51 -0
- package/dist/cli-auth-bundle.d.mts +2 -0
- package/dist/cli-auth-bundle.mjs +2 -0
- package/dist/cli-auth-placeholder.d.mts +54 -0
- package/dist/cli-auth-placeholder.mjs +200 -0
- package/dist/cli-backend-auth-env.d.mts +6 -0
- package/dist/cli-backend-auth-env.mjs +44 -0
- package/dist/default-backend.d.mts +24 -0
- package/dist/default-backend.mjs +31 -0
- package/dist/harness-D1fTxnDD.mjs +199 -0
- package/dist/harness-contracts-BZoECCMc.mjs +1076 -0
- package/dist/host-contracts.d.mts +30 -0
- package/dist/host-contracts.json +422 -0
- package/dist/host-contracts.mjs +63 -0
- package/dist/index.d.mts +1397 -0
- package/dist/index.mjs +151 -0
- package/dist/local-cli-auth.d.mts +14 -0
- package/dist/local-cli-auth.mjs +31 -0
- package/dist/native-session-contracts.d.mts +349 -0
- package/dist/native-session-contracts.mjs +40 -0
- package/dist/servable-models.d.mts +103 -0
- package/dist/servable-models.mjs +131 -0
- package/dist/session-contract-BhzcbPRW.d.mts +97 -0
- package/dist/session-contract.d.mts +2 -0
- package/dist/session-contract.mjs +142 -0
- package/dist/spec-CcvTM7-j.d.mts +346 -0
- package/dist/specs-BBF55TnM.mjs +735 -0
- package/dist/specs.d.mts +72 -0
- package/dist/specs.mjs +3 -0
- package/package.json +87 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright (c) 2025 Tangle Network
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are proprietary
|
|
6
|
+
and confidential. No part of this Software may be reproduced, distributed, or
|
|
7
|
+
transmitted in any form or by any means, including photocopying, recording, or
|
|
8
|
+
other electronic or mechanical methods, without the prior written permission of
|
|
9
|
+
Tangle Network.
|
|
10
|
+
|
|
11
|
+
For licensing inquiries, contact: hello@tangle.tools
|
package/README.md
CHANGED
|
@@ -1,3 +1,176 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @tangle-network/cli-agent-registry
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CLI harness descriptors, capabilities, model wiring, and local credential discovery.
|
|
4
|
+
Use the narrowest entrypoint for the runtime:
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { getSpec } from "@tangle-network/cli-agent-registry/specs";
|
|
8
|
+
import {
|
|
9
|
+
describeLocalCliAuthExpectation,
|
|
10
|
+
discoverLocalCliAuthFiles,
|
|
11
|
+
} from "@tangle-network/cli-agent-registry/local-cli-auth";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`/specs` and `/backend-types` are browser-safe. `/local-cli-auth` reads the host
|
|
15
|
+
filesystem and is Node-only. Workspace consumers use the same built declarations
|
|
16
|
+
as published consumers; build the registry before checking or bundling a consumer.
|
|
17
|
+
|
|
18
|
+
Credential discovery follows `CODEX_HOME`, `CLAUDE_CONFIG_DIR` and Claude's
|
|
19
|
+
`CLAUDE_SECURESTORAGE_CONFIG_DIR`; secure storage does not move settings files.
|
|
20
|
+
Pass `{ credentialOnly: true }` to read only the native credential file, without
|
|
21
|
+
settings. An explicit `homeDir` isolates discovery from ambient environment
|
|
22
|
+
overrides unless `env` is also supplied. Returned contents are sensitive raw files,
|
|
23
|
+
not proof of a valid OAuth subscription. Callers own consent and native login
|
|
24
|
+
validation before enrollment. This filesystem reader does not read macOS Keychain.
|
|
25
|
+
|
|
26
|
+
## Native HOME layouts (0.15)
|
|
27
|
+
|
|
28
|
+
`CliDirLayout.configAllow` accepts strings or `{ path, kind: "symlink" }` rules.
|
|
29
|
+
Consumers must narrow an entry before calling string methods and apply its kind
|
|
30
|
+
constraint. The maintained Orchestrator classifier does both; arbitrary external
|
|
31
|
+
string-only consumers require migration. `mergeCliDirLayout` keeps its four keys,
|
|
32
|
+
key order and fresh default-plus-addition arrays.
|
|
33
|
+
|
|
34
|
+
Codex's known cache and plugin trees and coordination files are preserved as
|
|
35
|
+
auxiliary source bytes. Only its four generated arg0 symlink aliases are named
|
|
36
|
+
configuration; regular files at those names and unknown siblings remain held.
|
|
37
|
+
Credential exclusions, native-store identity and conservation still apply.
|
|
38
|
+
|
|
39
|
+
## Host registry export
|
|
40
|
+
|
|
41
|
+
`host-contracts.json` is the generated data-only projection of the canonical
|
|
42
|
+
`harness-contracts/` session stores, store environment, CLI versions and model
|
|
43
|
+
environment names. Non-JavaScript Git consumers can pin this committed file by
|
|
44
|
+
commit and hash. Build emits its byte-identical package copy in `dist`; the public
|
|
45
|
+
`/host-contracts.json` export resolves there, and prepack rejects drift in either copy.
|
|
46
|
+
The real CLI/Python
|
|
47
|
+
boundary check is `node tests/host-contracts.integration.mjs`.
|
|
48
|
+
|
|
49
|
+
The `/host-contracts` entry also exports `HOST_CONTRACTS`. Host-only `cursor-cli`
|
|
50
|
+
and the Cursor CLI declaration describes its native on-disk stores; it does not
|
|
51
|
+
register sandbox backends, change Cursor SDK's unsupported status, or establish
|
|
52
|
+
sandbox recovery conformance. Per-store `env` selects its base-directory override;
|
|
53
|
+
`xdg` supplies a lower-priority XDG base. `session.storeEnv` declares each override's
|
|
54
|
+
default home-relative base; append the remaining suffix of `store.root`.
|
|
55
|
+
|
|
56
|
+
## Identity, availability and implementation
|
|
57
|
+
|
|
58
|
+
Interface describes recognized identities, including historical ones. This
|
|
59
|
+
installation declares its backend vocabulary positively; importing it must not
|
|
60
|
+
require every harness subsequently recognized by Interface. `BackendType` derives
|
|
61
|
+
from the local declaration. Accepted IDs are unchanged. Removing an executable
|
|
62
|
+
must not invalidate saved identities.
|
|
63
|
+
|
|
64
|
+
`createAdapterRegistry(selectedSpecs)` owns an independent factory map and snapshots
|
|
65
|
+
its wiring requirements. Each selected executable descriptor requires a factory and
|
|
66
|
+
its native-session contract (or the existing explicit unsupported classification).
|
|
67
|
+
Duplicate descriptors and duplicate factory registration fail; the explicit test
|
|
68
|
+
override remains. Later descriptor mutation cannot weaken those requirements.
|
|
69
|
+
|
|
70
|
+
Existing module-level methods use a default registry over `CLI_AGENT_SPECS`, so
|
|
71
|
+
current consumers retain their requirements. Registration does not authorize execution:
|
|
72
|
+
callers must resolve an admitted descriptor and enforce capabilities. Unregistering a
|
|
73
|
+
selected factory still fails startup; it is not a way to drain live sessions. The
|
|
74
|
+
sidecar's all-provider import composition still needs a selected deployment manifest.
|
|
75
|
+
|
|
76
|
+
## Adapter-owned profile semantics
|
|
77
|
+
|
|
78
|
+
`CliProviderAdapterBase` no longer guesses native profile behavior from a storage
|
|
79
|
+
path or owns Pi's private instruction-directory calculation. A subclass explicitly
|
|
80
|
+
supplies `profileHarness` and, when needed, `profileAgentDirectory`. Claude Code,
|
|
81
|
+
Codex, OpenCode, Kimi, NanoClaw, Pi, Hermes and OpenClaw declare their existing
|
|
82
|
+
profile semantics; Pi resolves its own native private directory.
|
|
83
|
+
|
|
84
|
+
Custom base subclasses using portable profile lowering must declare their identity.
|
|
85
|
+
Ordinary execution without a profile remains available without this declaration.
|
|
86
|
+
Secret concurrent-profile revisions and managed quotes are separate trusted
|
|
87
|
+
implementation capabilities: OpenCode explicitly opts into the existing transports.
|
|
88
|
+
Neither a caller's config key nor the provider name grants them. Native-session,
|
|
89
|
+
private-root, secret-handling and budget checks remain in place.
|
|
90
|
+
|
|
91
|
+
### System laws
|
|
92
|
+
|
|
93
|
+
- `tests/adapter-removal.contract.test.ts`: selected descriptors require factories,
|
|
94
|
+
omitted descriptors do not, registries are isolated, duplicate descriptors fail,
|
|
95
|
+
and mutation cannot change the captured requirements.
|
|
96
|
+
- `../sdk-provider-cli-base/tests/profile-ownership-process.test.ts`: a real Node
|
|
97
|
+
child observes materialized profiles and private instruction placement; unsupported
|
|
98
|
+
profiles fail before spawn; ordinary execution needs no implicit profile support;
|
|
99
|
+
names/config keys do not grant managed quotes. Node is a process fixture, not a
|
|
100
|
+
claimed substitute for a native coding harness.
|
|
101
|
+
- Native conformance is separately bound to pinned CLI versions, declared session
|
|
102
|
+
contracts and adapter/shared-runner source. Stale receipts fail; never edit their
|
|
103
|
+
hashes to manufacture proof.
|
|
104
|
+
|
|
105
|
+
## Executed validation
|
|
106
|
+
|
|
107
|
+
Foundation proof: Actions **38684058864**, artifact **11948704158**, commit
|
|
108
|
+
`64bb4f84358990dbd85d64aaf97eb73985f0a964`. Affected builds/typechecks passed;
|
|
109
|
+
**122 registry tests and 355 runtime-contract tests passed**.
|
|
110
|
+
|
|
111
|
+
Expanded proof: Actions **38687071248**, artifact **11950383351**, commit
|
|
112
|
+
`559f2550daa698ddb648ec6470aec477aff84a71`:
|
|
113
|
+
|
|
114
|
+
- The sidecar dependency closure builds.
|
|
115
|
+
- All provider packages and the registry pass typechecking.
|
|
116
|
+
- All 14 provider suites plus the shared base pass: **1,502 tests**, with 65 skipped.
|
|
117
|
+
- Runtime-contract tests: **355 passed**.
|
|
118
|
+
- Registry: **121 passed, 1 failed**. The failure correctly names four stale native
|
|
119
|
+
receipts after the shared-base change: Claude Code, Codex, OpenCode and Pi.
|
|
120
|
+
|
|
121
|
+
### Native qualification: not passed
|
|
122
|
+
|
|
123
|
+
Two native attempts built the pinned CLI image, then failed connecting to the local
|
|
124
|
+
Sandbox shim before any harness execution. No fresh passing receipt was produced.
|
|
125
|
+
|
|
126
|
+
- Actions **38687071248**, artifact **11950938690**, source
|
|
127
|
+
`559f2550daa698ddb648ec6470aec477aff84a71`: fetch failure, exit 1; owned-container
|
|
128
|
+
cleanup passed.
|
|
129
|
+
- Actions **38688402352**, artifact **11951190503**, source
|
|
130
|
+
`d640034db5ee590c9851daa0049c32d6a3e4c160`: the same attempt with bounded transport
|
|
131
|
+
cause diagnostics reports `UND_ERR_CONNECT_TIMEOUT` for all four requests.
|
|
132
|
+
Exit 1; owned-container cleanup passed. Only test-driver diagnostics changed.
|
|
133
|
+
- Actions **38688973460**, artifact **11951770808**: an isolated network diagnostic
|
|
134
|
+
confirms that the Docker bridge gateway is not a local address in the runner's
|
|
135
|
+
network namespace. The runner's own loopback server answers, but the gateway
|
|
136
|
+
probes do not. No proxy environment is involved. A successful diagnostic job is
|
|
137
|
+
not a successful native qualification.
|
|
138
|
+
|
|
139
|
+
The driver assumes that its host-side shim and Docker bridge share a reachable
|
|
140
|
+
network context. This runner does not satisfy that assumption. Co-locate the test
|
|
141
|
+
services with the Docker network and expose the client endpoint explicitly, or use
|
|
142
|
+
an appropriate co-located runner, before repeating native qualification. Do not
|
|
143
|
+
weaken TLS, network isolation, receipt checks or production controls to force a pass.
|
|
144
|
+
All temporary branch-only proof/diagnostic workflows were removed after these runs.
|
|
145
|
+
No production endpoint or real model was used. Later documentation and workflow
|
|
146
|
+
cleanup commits are not retroactively included in the source commits named above.
|
|
147
|
+
|
|
148
|
+
## Exact remaining work
|
|
149
|
+
|
|
150
|
+
- [ ] Repair the native proof's runner/network topology; obtain genuine passing
|
|
151
|
+
receipts for the changed runner; rerun the registry/invariant gate.
|
|
152
|
+
- [ ] Select sidecar implementation imports, API catalog admission and image/CLI
|
|
153
|
+
dependencies from one explicit deployment manifest. Registry omission is not
|
|
154
|
+
physical package or executable removal.
|
|
155
|
+
- [ ] Supply real start/resume availability to app admission and pickers; preserve
|
|
156
|
+
old IDs/history; do not pre-coerce saved or explicit requested IDs.
|
|
157
|
+
- [ ] Consolidate remaining per-harness profile/MCP/hooks, auth, invocation, session
|
|
158
|
+
and packaging facts with their owners. Replace the app's duplicated profile
|
|
159
|
+
support table. Common-base inference removal is done, not this entire step.
|
|
160
|
+
- [ ] Declare ACP's selected backing dependency, including its current Hermes
|
|
161
|
+
default; reject missing/retired backings before launch while preserving the
|
|
162
|
+
closed command allowlist and credential isolation.
|
|
163
|
+
- [ ] Consolidate agent-runtime's local invocation and native usage readers with
|
|
164
|
+
their owners; keep historical codecs usable without installed executables.
|
|
165
|
+
- [ ] Physically omit each adapter package/CLI in turn and prove remaining startup,
|
|
166
|
+
cancellation/resume, readable history and secret isolation.
|
|
167
|
+
- [ ] Complete sidecar typecheck and real HTTP/UI/packed-consumer coverage for the
|
|
168
|
+
selected catalog; update the maintained owner/roadmap indexes.
|
|
169
|
+
- [ ] Independent review, final-head checks, merge, package publication/cohort
|
|
170
|
+
adoption and authorized served verification through maintained automation.
|
|
171
|
+
|
|
172
|
+
Continue the same PRs: agent-container **#10961**, agent-sdk **#498**, agent-app
|
|
173
|
+
**#1116**. Their documents retain the executed evidence and remaining adoption.
|
|
174
|
+
Agent-runtime and Braid have no implementation PR from this attempt; change Braid
|
|
175
|
+
only where shared-contract adoption requires it. No production harness is retired
|
|
176
|
+
merely because its implementation was refactored.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region ../runtime-contracts/dist/backend-types.js
|
|
3
|
+
/** This distribution's backend vocabulary. Gemini is only a backing transport, not a direct backend. */
|
|
4
|
+
const BACKEND_TYPE = {
|
|
5
|
+
OPENCODE: "opencode",
|
|
6
|
+
CLAUDE_CODE: "claude-code",
|
|
7
|
+
KIMI_CODE: "kimi-code",
|
|
8
|
+
CODEX: "codex",
|
|
9
|
+
AMP: "amp",
|
|
10
|
+
FACTORY_DROIDS: "factory-droids",
|
|
11
|
+
PI: "pi",
|
|
12
|
+
PRIME: "prime",
|
|
13
|
+
HERMES: "hermes",
|
|
14
|
+
OPENCLAW: "openclaw",
|
|
15
|
+
NANOCLAW: "nanoclaw",
|
|
16
|
+
ACP: "acp",
|
|
17
|
+
CURSOR: "cursor",
|
|
18
|
+
GROK: "grok",
|
|
19
|
+
CLI_BASE: "cli-base"
|
|
20
|
+
};
|
|
21
|
+
/** Stable declaration order; registry tests check the shipped spec composition. */
|
|
22
|
+
const ALL_BACKEND_TYPES = Object.values(BACKEND_TYPE);
|
|
23
|
+
const backendTypeSchema = z.enum(ALL_BACKEND_TYPES);
|
|
24
|
+
z.string().regex(/^[A-Za-z0-9_.:@-]{1,256}$/);
|
|
25
|
+
const BACKEND_TYPE_SET = new Set(ALL_BACKEND_TYPES);
|
|
26
|
+
function isBackendType(value) {
|
|
27
|
+
return BACKEND_TYPE_SET.has(value);
|
|
28
|
+
}
|
|
29
|
+
function parseBackendType(value) {
|
|
30
|
+
if (!isBackendType(value)) throw new Error(`Unknown backend type "${value}". Expected one of: ${ALL_BACKEND_TYPES.join(", ")}`);
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { parseBackendType as a, isBackendType as i, BACKEND_TYPE as n, backendTypeSchema as r, ALL_BACKEND_TYPES as t };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=backend-types-CNo_Zj_K.mjs.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region ../runtime-contracts/dist/backend-types.d.ts
|
|
4
|
+
/** This distribution's backend vocabulary. Gemini is only a backing transport, not a direct backend. */
|
|
5
|
+
declare const BACKEND_TYPE: {
|
|
6
|
+
readonly OPENCODE: "opencode";
|
|
7
|
+
readonly CLAUDE_CODE: "claude-code";
|
|
8
|
+
readonly KIMI_CODE: "kimi-code";
|
|
9
|
+
readonly CODEX: "codex";
|
|
10
|
+
readonly AMP: "amp";
|
|
11
|
+
readonly FACTORY_DROIDS: "factory-droids";
|
|
12
|
+
readonly PI: "pi";
|
|
13
|
+
readonly PRIME: "prime";
|
|
14
|
+
readonly HERMES: "hermes";
|
|
15
|
+
readonly OPENCLAW: "openclaw";
|
|
16
|
+
readonly NANOCLAW: "nanoclaw";
|
|
17
|
+
readonly ACP: "acp";
|
|
18
|
+
readonly CURSOR: "cursor";
|
|
19
|
+
readonly GROK: "grok";
|
|
20
|
+
readonly CLI_BASE: "cli-base";
|
|
21
|
+
};
|
|
22
|
+
/** Derived from the local declaration, not the complement of the upstream enum. */
|
|
23
|
+
type BackendType = (typeof BACKEND_TYPE)[keyof typeof BACKEND_TYPE];
|
|
24
|
+
/** Stable declaration order; registry tests check the shipped spec composition. */
|
|
25
|
+
declare const ALL_BACKEND_TYPES: [BackendType, ...BackendType[]];
|
|
26
|
+
declare const backendTypeSchema: z.ZodEnum<{
|
|
27
|
+
"claude-code": "claude-code";
|
|
28
|
+
nanoclaw: "nanoclaw";
|
|
29
|
+
codex: "codex";
|
|
30
|
+
opencode: "opencode";
|
|
31
|
+
"kimi-code": "kimi-code";
|
|
32
|
+
pi: "pi";
|
|
33
|
+
prime: "prime";
|
|
34
|
+
hermes: "hermes";
|
|
35
|
+
openclaw: "openclaw";
|
|
36
|
+
amp: "amp";
|
|
37
|
+
"factory-droids": "factory-droids";
|
|
38
|
+
cursor: "cursor";
|
|
39
|
+
grok: "grok";
|
|
40
|
+
acp: "acp";
|
|
41
|
+
"cli-base": "cli-base";
|
|
42
|
+
}>;
|
|
43
|
+
declare function isBackendType(value: string): value is BackendType;
|
|
44
|
+
declare function parseBackendType(value: string): BackendType;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { isBackendType as a, backendTypeSchema as i, BACKEND_TYPE as n, parseBackendType as o, BackendType as r, ALL_BACKEND_TYPES as t };
|
|
47
|
+
//# sourceMappingURL=backend-types-DRmLR1e0.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as isBackendType, i as backendTypeSchema, n as BACKEND_TYPE, o as parseBackendType, r as BackendType, t as ALL_BACKEND_TYPES } from "./backend-types-DRmLR1e0.mjs";
|
|
2
|
+
export { ALL_BACKEND_TYPES, BACKEND_TYPE, BackendType, backendTypeSchema, isBackendType, parseBackendType };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { l as getSpec } from "./specs-BBF55TnM.mjs";
|
|
2
|
+
import "@tangle-network/agent-interface";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region ../runtime-contracts/dist/public-profile-request.js
|
|
5
|
+
const cliAuthReferenceSchema = z.strictObject({
|
|
6
|
+
account: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9@._+-]{0,127}$/),
|
|
7
|
+
secretEnv: z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}$/),
|
|
8
|
+
format: z.enum([
|
|
9
|
+
"token",
|
|
10
|
+
"bundle",
|
|
11
|
+
"files"
|
|
12
|
+
])
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/cli-auth-bundle.ts
|
|
16
|
+
const DEFAULT_MODE = 384;
|
|
17
|
+
const AUTH_BUNDLE_PATHS = Object.freeze({
|
|
18
|
+
codex: ".codex/auth.json",
|
|
19
|
+
"claude-code": ".claude/.credentials.json"
|
|
20
|
+
});
|
|
21
|
+
/** Convert a native credential JSON bundle without reading host credentials. */
|
|
22
|
+
function materializeCliAuthBundle(backendType, rawBundle) {
|
|
23
|
+
if (backendType !== "codex" && backendType !== "claude-code") throw new Error("CLI auth bundle is not supported for the selected backend");
|
|
24
|
+
if (typeof rawBundle !== "string") throw new Error("CLI auth bundle must be a JSON object");
|
|
25
|
+
let value;
|
|
26
|
+
try {
|
|
27
|
+
value = JSON.parse(rawBundle);
|
|
28
|
+
} catch {
|
|
29
|
+
throw new Error("CLI auth bundle must be a JSON object");
|
|
30
|
+
}
|
|
31
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("CLI auth bundle must be a JSON object");
|
|
32
|
+
return [{
|
|
33
|
+
path: AUTH_BUNDLE_PATHS[backendType],
|
|
34
|
+
content: rawBundle,
|
|
35
|
+
mode: DEFAULT_MODE
|
|
36
|
+
}];
|
|
37
|
+
}
|
|
38
|
+
const CLI_AUTH_REFERENCE_ENV_VAR = "AGENT_INTERNAL_CLI_AUTH_REF";
|
|
39
|
+
const cliAuthFilesSchema = z.array(z.object({
|
|
40
|
+
path: z.string().min(1).max(4096).refine((value) => !value.startsWith("/") && !/^[A-Za-z]:/.test(value) && !/[\\\0]/.test(value) && value.split("/").every((part) => part !== "" && part !== "." && part !== "..")),
|
|
41
|
+
content: z.string().max(1024 * 1024),
|
|
42
|
+
mode: z.number().int().min(0).max(448).refine((mode) => (mode & 63) === 0).optional()
|
|
43
|
+
}).strict()).min(1).max(128);
|
|
44
|
+
function assertCliAuthReferenceSupported(backendType, model) {
|
|
45
|
+
if (model.cliAuth === void 0) return void 0;
|
|
46
|
+
const parsedReference = cliAuthReferenceSchema.safeParse(model.cliAuth);
|
|
47
|
+
if (!parsedReference.success) throw new Error("Invalid native authentication reference");
|
|
48
|
+
const reference = parsedReference.data;
|
|
49
|
+
if (model.authMode === "api-key" || model.apiKey !== void 0 || model.apiKeyEnv !== void 0 || model.baseUrl !== void 0 || model.authFiles !== void 0) throw new Error("cliAuth cannot be combined with API credentials, baseUrl, or inline authFiles");
|
|
50
|
+
const spec = getSpec(backendType);
|
|
51
|
+
if (!spec?.hasCliAuth) throw new Error(`Native CLI authentication is unsupported by ${backendType}`);
|
|
52
|
+
if (reference.format === "token" && !spec.envVars.oauthToken) throw new Error(`Native subscription tokens are unsupported by ${backendType}`);
|
|
53
|
+
if (reference.format === "bundle" && backendType !== "codex" && backendType !== "claude-code") throw new Error(`Native credential bundles are unsupported by ${backendType}`);
|
|
54
|
+
return reference;
|
|
55
|
+
}
|
|
56
|
+
/** Resolve only the selected injected secret, without copying it into a public config. */
|
|
57
|
+
function resolveCliAuthReference(backendType, model, environment) {
|
|
58
|
+
const reference = assertCliAuthReferenceSupported(backendType, model);
|
|
59
|
+
if (!reference) return void 0;
|
|
60
|
+
const value = environment[reference.secretEnv];
|
|
61
|
+
if (typeof value !== "string" || value.trim().length === 0) throw new Error(`Missing native credential environment variable: ${reference.secretEnv}`);
|
|
62
|
+
if (reference.format === "token") {
|
|
63
|
+
const tokenEnv = getSpec(backendType)?.envVars.oauthToken;
|
|
64
|
+
if (!tokenEnv) throw new Error(`Native subscription tokens are unsupported by ${backendType}`);
|
|
65
|
+
if (/\s/.test(value) || value.startsWith("{") || value.startsWith("[")) throw new Error("Native token authentication requires a raw token, not a credential wrapper");
|
|
66
|
+
return {
|
|
67
|
+
reference,
|
|
68
|
+
authFiles: [],
|
|
69
|
+
tokenEnvironment: { [tokenEnv]: value }
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (reference.format === "bundle") return {
|
|
73
|
+
reference,
|
|
74
|
+
authFiles: materializeCliAuthBundle(backendType, value),
|
|
75
|
+
tokenEnvironment: {}
|
|
76
|
+
};
|
|
77
|
+
let parsed;
|
|
78
|
+
try {
|
|
79
|
+
parsed = JSON.parse(value);
|
|
80
|
+
} catch {
|
|
81
|
+
throw new Error("Native authFiles secret must contain a JSON array of auth files");
|
|
82
|
+
}
|
|
83
|
+
const files = cliAuthFilesSchema.safeParse(parsed);
|
|
84
|
+
if (!files.success) throw new Error("Native authFiles secret must contain a JSON array of auth files");
|
|
85
|
+
if (backendType === "codex" && (files.data.length !== 1 || files.data[0]?.path !== AUTH_BUNDLE_PATHS.codex || files.data[0]?.content.trim().length === 0)) throw new Error("Codex native auth files require only .codex/auth.json");
|
|
86
|
+
return {
|
|
87
|
+
reference,
|
|
88
|
+
authFiles: files.data,
|
|
89
|
+
tokenEnvironment: {}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
export { materializeCliAuthBundle as a, cliAuthFilesSchema as i, CLI_AUTH_REFERENCE_ENV_VAR as n, resolveCliAuthReference as o, assertCliAuthReferenceSupported as r, cliAuthReferenceSchema as s, AUTH_BUNDLE_PATHS as t };
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=cli-auth-bundle-C6DtK7GX.mjs.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region ../runtime-contracts/dist/public-profile-request.d.ts
|
|
4
|
+
declare const cliAuthReferenceSchema: z.ZodObject<{
|
|
5
|
+
account: z.ZodString;
|
|
6
|
+
secretEnv: z.ZodString;
|
|
7
|
+
format: z.ZodEnum<{
|
|
8
|
+
files: "files";
|
|
9
|
+
token: "token";
|
|
10
|
+
bundle: "bundle";
|
|
11
|
+
}>;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
/** A supplied account binding label, not a verified native account principal. */
|
|
14
|
+
type CliAuthReference = z.infer<typeof cliAuthReferenceSchema>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/cli-auth-bundle.d.ts
|
|
17
|
+
type LocalCliAuthFile = {
|
|
18
|
+
path: string;
|
|
19
|
+
content: string;
|
|
20
|
+
mode?: number;
|
|
21
|
+
};
|
|
22
|
+
declare const AUTH_BUNDLE_PATHS: Readonly<{
|
|
23
|
+
readonly codex: ".codex/auth.json";
|
|
24
|
+
readonly "claude-code": ".claude/.credentials.json";
|
|
25
|
+
}>;
|
|
26
|
+
/** Convert a native credential JSON bundle without reading host credentials. */
|
|
27
|
+
declare function materializeCliAuthBundle(backendType: string, rawBundle: string): LocalCliAuthFile[];
|
|
28
|
+
declare const CLI_AUTH_REFERENCE_ENV_VAR = "AGENT_INTERNAL_CLI_AUTH_REF";
|
|
29
|
+
type CliAuthMaterial = {
|
|
30
|
+
reference: CliAuthReference;
|
|
31
|
+
authFiles: LocalCliAuthFile[];
|
|
32
|
+
tokenEnvironment: Record<string, string>;
|
|
33
|
+
};
|
|
34
|
+
declare const cliAuthFilesSchema: z.ZodArray<z.ZodObject<{
|
|
35
|
+
path: z.ZodString;
|
|
36
|
+
content: z.ZodString;
|
|
37
|
+
mode: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
declare function assertCliAuthReferenceSupported(backendType: string, model: {
|
|
40
|
+
cliAuth?: CliAuthReference;
|
|
41
|
+
authMode?: string;
|
|
42
|
+
apiKey?: string;
|
|
43
|
+
apiKeyEnv?: string;
|
|
44
|
+
baseUrl?: string;
|
|
45
|
+
authFiles?: LocalCliAuthFile[];
|
|
46
|
+
}): CliAuthReference | undefined;
|
|
47
|
+
/** Resolve only the selected injected secret, without copying it into a public config. */
|
|
48
|
+
declare function resolveCliAuthReference(backendType: string, model: Parameters<typeof assertCliAuthReferenceSupported>[1], environment: Readonly<Record<string, string | undefined>>): CliAuthMaterial | undefined;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { assertCliAuthReferenceSupported as a, resolveCliAuthReference as c, LocalCliAuthFile as i, CliAuthReference as l, CLI_AUTH_REFERENCE_ENV_VAR as n, cliAuthFilesSchema as o, CliAuthMaterial as r, materializeCliAuthBundle as s, AUTH_BUNDLE_PATHS as t, cliAuthReferenceSchema as u };
|
|
51
|
+
//# sourceMappingURL=cli-auth-bundle-CwAaH0Ap.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as assertCliAuthReferenceSupported, c as resolveCliAuthReference, i as LocalCliAuthFile, l as CliAuthReference, n as CLI_AUTH_REFERENCE_ENV_VAR, o as cliAuthFilesSchema, r as CliAuthMaterial, s as materializeCliAuthBundle, t as AUTH_BUNDLE_PATHS, u as cliAuthReferenceSchema } from "./cli-auth-bundle-CwAaH0Ap.mjs";
|
|
2
|
+
export { AUTH_BUNDLE_PATHS, CLI_AUTH_REFERENCE_ENV_VAR, CliAuthMaterial, CliAuthReference, LocalCliAuthFile, assertCliAuthReferenceSupported, cliAuthFilesSchema, cliAuthReferenceSchema, materializeCliAuthBundle, resolveCliAuthReference };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as materializeCliAuthBundle, i as cliAuthFilesSchema, n as CLI_AUTH_REFERENCE_ENV_VAR, o as resolveCliAuthReference, r as assertCliAuthReferenceSupported, s as cliAuthReferenceSchema, t as AUTH_BUNDLE_PATHS } from "./cli-auth-bundle-C6DtK7GX.mjs";
|
|
2
|
+
export { AUTH_BUNDLE_PATHS, CLI_AUTH_REFERENCE_ENV_VAR, assertCliAuthReferenceSupported, cliAuthFilesSchema, cliAuthReferenceSchema, materializeCliAuthBundle, resolveCliAuthReference };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { l as CliAuthReference, r as CliAuthMaterial } from "./cli-auth-bundle-CwAaH0Ap.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/cli-auth-placeholder.d.ts
|
|
5
|
+
declare const metadataSchema: z.ZodObject<{
|
|
6
|
+
accountId: z.ZodOptional<z.ZodString>;
|
|
7
|
+
planType: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
8
|
+
free: "free";
|
|
9
|
+
plus: "plus";
|
|
10
|
+
pro: "pro";
|
|
11
|
+
business: "business";
|
|
12
|
+
enterprise: "enterprise";
|
|
13
|
+
edu: "edu";
|
|
14
|
+
team: "team";
|
|
15
|
+
}>, z.ZodEnum<{
|
|
16
|
+
free: "free";
|
|
17
|
+
pro: "pro";
|
|
18
|
+
enterprise: "enterprise";
|
|
19
|
+
team: "team";
|
|
20
|
+
max: "max";
|
|
21
|
+
}>]>>;
|
|
22
|
+
accessTokenExpiresAt: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
hasRefreshToken: z.ZodBoolean;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
/** Routing/display hints only; these fields do not verify an account principal. */
|
|
26
|
+
type CliAuthPlaceholderMetadata = z.infer<typeof metadataSchema>;
|
|
27
|
+
type PlaceholderInput = {
|
|
28
|
+
backendType: string;
|
|
29
|
+
reference: CliAuthReference; /** The existing egress owner supplies this sandbox's declared-slot token. */
|
|
30
|
+
placeholder: string; /** CLI compatibility timestamp, never an assertion of provider validity. */
|
|
31
|
+
now: Date;
|
|
32
|
+
metadata: CliAuthPlaceholderMetadata;
|
|
33
|
+
};
|
|
34
|
+
/** Build sandbox-safe native material without accepting any provider token. */
|
|
35
|
+
declare function buildCliAuthPlaceholderMaterial(input: PlaceholderInput): CliAuthMaterial;
|
|
36
|
+
/**
|
|
37
|
+
* TRUSTED OWNER ONLY. The explicit proxyAccessToken result must reach only the
|
|
38
|
+
* host's existing egress holder. Only nativeMaterial may enter the sandbox.
|
|
39
|
+
* The uploaded bundle, ID token and refresh token are never returned.
|
|
40
|
+
*/
|
|
41
|
+
declare function resolveCliAuthPlaceholder(input: {
|
|
42
|
+
backendType: string;
|
|
43
|
+
reference: CliAuthReference;
|
|
44
|
+
secretValue: string;
|
|
45
|
+
placeholder: string;
|
|
46
|
+
now: Date;
|
|
47
|
+
}): {
|
|
48
|
+
proxyAccessToken: string;
|
|
49
|
+
nativeMaterial: CliAuthMaterial;
|
|
50
|
+
metadata: CliAuthPlaceholderMetadata;
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { CliAuthPlaceholderMetadata, buildCliAuthPlaceholderMaterial, resolveCliAuthPlaceholder };
|
|
54
|
+
//# sourceMappingURL=cli-auth-placeholder.d.mts.map
|