@0gfoundation/0g-agentdna 0.4.0 → 0.5.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/GUIDE.md +190 -40
- package/OPERATORS.md +164 -0
- package/OPERATORS.zh.md +141 -0
- package/PROVIDERS.md +6 -0
- package/PROVIDERS.zh.md +3 -1
- package/README.md +84 -11
- package/dist/AgentClient.d.ts +374 -26
- package/dist/AgentClient.d.ts.map +1 -1
- package/dist/AgentClient.js +323 -40
- package/dist/AgentClient.js.map +1 -1
- package/dist/AgenticID.d.ts +170 -80
- package/dist/AgenticID.d.ts.map +1 -1
- package/dist/AgenticID.js +300 -42
- package/dist/AgenticID.js.map +1 -1
- package/dist/AttestorClient.d.ts +115 -31
- package/dist/AttestorClient.d.ts.map +1 -1
- package/dist/AttestorClient.js +276 -56
- package/dist/AttestorClient.js.map +1 -1
- package/dist/Credentials.d.ts +574 -0
- package/dist/Credentials.d.ts.map +1 -0
- package/dist/Credentials.js +838 -0
- package/dist/Credentials.js.map +1 -0
- package/dist/Operators.d.ts +60 -0
- package/dist/Operators.d.ts.map +1 -0
- package/dist/Operators.js +38 -0
- package/dist/Operators.js.map +1 -0
- package/dist/Providers.d.ts +13 -0
- package/dist/Providers.d.ts.map +1 -1
- package/dist/Providers.js +20 -1
- package/dist/Providers.js.map +1 -1
- package/dist/Releases.d.ts +51 -0
- package/dist/Releases.d.ts.map +1 -0
- package/dist/Releases.js +72 -0
- package/dist/Releases.js.map +1 -0
- package/dist/ReputationClient.d.ts +47 -3
- package/dist/ReputationClient.d.ts.map +1 -1
- package/dist/ReputationClient.js +204 -78
- package/dist/ReputationClient.js.map +1 -1
- package/dist/ServeProof.d.ts +70 -23
- package/dist/ServeProof.d.ts.map +1 -1
- package/dist/ServeProof.js +94 -35
- package/dist/ServeProof.js.map +1 -1
- package/dist/ServeSession.d.ts +17 -2
- package/dist/ServeSession.d.ts.map +1 -1
- package/dist/ServeSession.js +77 -9
- package/dist/ServeSession.js.map +1 -1
- package/dist/Settings.d.ts +25 -1
- package/dist/Settings.d.ts.map +1 -1
- package/dist/Settings.js +53 -1
- package/dist/Settings.js.map +1 -1
- package/dist/TrustRegistry.d.ts +28 -0
- package/dist/TrustRegistry.d.ts.map +1 -0
- package/dist/TrustRegistry.js +67 -0
- package/dist/TrustRegistry.js.map +1 -0
- package/dist/abi.d.ts +346 -34
- package/dist/abi.d.ts.map +1 -1
- package/dist/abi.js +150 -30
- package/dist/abi.js.map +1 -1
- package/dist/cli/attach.d.ts +79 -0
- package/dist/cli/attach.d.ts.map +1 -0
- package/dist/cli/attach.js +253 -0
- package/dist/cli/attach.js.map +1 -0
- package/dist/cli/commands/cells.d.ts +45 -0
- package/dist/cli/commands/cells.d.ts.map +1 -1
- package/dist/cli/commands/cells.js +77 -0
- package/dist/cli/commands/cells.js.map +1 -1
- package/dist/cli/commands/cred.d.ts +12 -0
- package/dist/cli/commands/cred.d.ts.map +1 -0
- package/dist/cli/commands/cred.js +43 -0
- package/dist/cli/commands/cred.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/doctor.js +44 -35
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/interactive.d.ts +597 -21
- package/dist/cli/commands/interactive.d.ts.map +1 -1
- package/dist/cli/commands/interactive.js +5082 -1323
- package/dist/cli/commands/interactive.js.map +1 -1
- package/dist/cli/commands/list.d.ts +5 -5
- package/dist/cli/commands/list.d.ts.map +1 -1
- package/dist/cli/commands/list.js +21 -26
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/providers.d.ts +4 -0
- package/dist/cli/commands/providers.d.ts.map +1 -1
- package/dist/cli/commands/providers.js +19 -5
- package/dist/cli/commands/providers.js.map +1 -1
- package/dist/cli/commands/releases.d.ts +13 -0
- package/dist/cli/commands/releases.d.ts.map +1 -0
- package/dist/cli/commands/releases.js +65 -0
- package/dist/cli/commands/releases.js.map +1 -0
- package/dist/cli/commands/settings.d.ts +5 -0
- package/dist/cli/commands/settings.d.ts.map +1 -1
- package/dist/cli/commands/settings.js +70 -24
- package/dist/cli/commands/settings.js.map +1 -1
- package/dist/cli/commands/status.d.ts +2 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +22 -19
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/config.d.ts +48 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +114 -5
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/credentials.d.ts +179 -0
- package/dist/cli/credentials.d.ts.map +1 -0
- package/dist/cli/credentials.js +1443 -0
- package/dist/cli/credentials.js.map +1 -0
- package/dist/cli/download.d.ts +21 -0
- package/dist/cli/download.d.ts.map +1 -0
- package/dist/cli/download.js +89 -0
- package/dist/cli/download.js.map +1 -0
- package/dist/cli/env.d.ts +6 -0
- package/dist/cli/env.d.ts.map +1 -1
- package/dist/cli/env.js +18 -6
- package/dist/cli/env.js.map +1 -1
- package/dist/cli/envelope.d.ts +4 -2
- package/dist/cli/envelope.d.ts.map +1 -1
- package/dist/cli/envelope.js +10 -6
- package/dist/cli/envelope.js.map +1 -1
- package/dist/cli/errors.d.ts +45 -1
- package/dist/cli/errors.d.ts.map +1 -1
- package/dist/cli/errors.js +77 -0
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/inference.d.ts.map +1 -1
- package/dist/cli/inference.js +7 -0
- package/dist/cli/inference.js.map +1 -1
- package/dist/cli/inkView.d.ts +341 -0
- package/dist/cli/inkView.d.ts.map +1 -0
- package/dist/cli/inkView.js +1019 -0
- package/dist/cli/inkView.js.map +1 -0
- package/dist/cli/legacy/modelKey.d.ts +24 -0
- package/dist/cli/legacy/modelKey.d.ts.map +1 -0
- package/dist/cli/legacy/modelKey.js +32 -0
- package/dist/cli/legacy/modelKey.js.map +1 -0
- package/dist/cli/livePrompt.d.ts +212 -0
- package/dist/cli/livePrompt.d.ts.map +1 -0
- package/dist/cli/livePrompt.js +576 -0
- package/dist/cli/livePrompt.js.map +1 -0
- package/dist/cli/main.js +206 -72
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/modelkey.d.ts +64 -0
- package/dist/cli/modelkey.d.ts.map +1 -0
- package/dist/cli/modelkey.js +113 -0
- package/dist/cli/modelkey.js.map +1 -0
- package/dist/cli/outboxSync.d.ts +51 -0
- package/dist/cli/outboxSync.d.ts.map +1 -0
- package/dist/cli/outboxSync.js +210 -0
- package/dist/cli/outboxSync.js.map +1 -0
- package/dist/cli/plain.d.ts +46 -0
- package/dist/cli/plain.d.ts.map +1 -0
- package/dist/cli/plain.js +260 -0
- package/dist/cli/plain.js.map +1 -0
- package/dist/cli/proofs.d.ts +5 -0
- package/dist/cli/proofs.d.ts.map +1 -1
- package/dist/cli/proofs.js +20 -0
- package/dist/cli/proofs.js.map +1 -1
- package/dist/cli/ref.d.ts.map +1 -1
- package/dist/cli/ref.js +3 -2
- package/dist/cli/ref.js.map +1 -1
- package/dist/cli/releaseNotice.d.ts +64 -0
- package/dist/cli/releaseNotice.d.ts.map +1 -0
- package/dist/cli/releaseNotice.js +194 -0
- package/dist/cli/releaseNotice.js.map +1 -0
- package/dist/cli/sdk.d.ts +18 -0
- package/dist/cli/sdk.d.ts.map +1 -1
- package/dist/cli/sdk.js +99 -1
- package/dist/cli/sdk.js.map +1 -1
- package/dist/cli/settings.d.ts +87 -6
- package/dist/cli/settings.d.ts.map +1 -1
- package/dist/cli/settings.js +270 -18
- package/dist/cli/settings.js.map +1 -1
- package/dist/cli/textfit.d.ts +28 -0
- package/dist/cli/textfit.d.ts.map +1 -0
- package/dist/cli/textfit.js +111 -0
- package/dist/cli/textfit.js.map +1 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/context.d.ts +26 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -0
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +19 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy/modelKey.d.ts +67 -0
- package/dist/legacy/modelKey.d.ts.map +1 -0
- package/dist/legacy/modelKey.js +80 -0
- package/dist/legacy/modelKey.js.map +1 -0
- package/dist/legacy/serveProofV1.d.ts +56 -0
- package/dist/legacy/serveProofV1.d.ts.map +1 -0
- package/dist/legacy/serveProofV1.js +91 -0
- package/dist/legacy/serveProofV1.js.map +1 -0
- package/dist/provider-catalog.json +3 -2
- package/dist/secretEnv.d.ts +18 -3
- package/dist/secretEnv.d.ts.map +1 -1
- package/dist/secretEnv.js +16 -2
- package/dist/secretEnv.js.map +1 -1
- package/dist/types.d.ts +63 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/viemErrors.d.ts +30 -0
- package/dist/viemErrors.d.ts.map +1 -0
- package/dist/viemErrors.js +36 -0
- package/dist/viemErrors.js.map +1 -0
- package/package.json +5 -1
- package/src/AgentClient.ts +622 -68
- package/src/AgenticID.ts +345 -56
- package/src/AttestorClient.ts +330 -83
- package/src/Credentials.ts +1027 -0
- package/src/Operators.ts +71 -0
- package/src/Providers.ts +20 -0
- package/src/Releases.ts +95 -0
- package/src/ReputationClient.ts +231 -79
- package/src/ServeProof.ts +123 -39
- package/src/ServeSession.ts +91 -9
- package/src/Settings.ts +61 -1
- package/src/TrustRegistry.ts +75 -0
- package/src/abi.ts +153 -30
- package/src/cli/attach.ts +257 -0
- package/src/cli/commands/cells.ts +104 -0
- package/src/cli/commands/cred.ts +44 -0
- package/src/cli/commands/doctor.ts +45 -37
- package/src/cli/commands/interactive.ts +4120 -664
- package/src/cli/commands/list.ts +21 -30
- package/src/cli/commands/providers.ts +17 -4
- package/src/cli/commands/releases.ts +60 -0
- package/src/cli/commands/settings.ts +75 -28
- package/src/cli/commands/status.ts +24 -21
- package/src/cli/config.ts +119 -4
- package/src/cli/credentials.ts +1379 -0
- package/src/cli/download.ts +80 -0
- package/src/cli/env.ts +22 -7
- package/src/cli/envelope.ts +10 -6
- package/src/cli/errors.ts +92 -0
- package/src/cli/inference.ts +8 -1
- package/src/cli/inkView.ts +969 -0
- package/src/cli/legacy/modelKey.ts +35 -0
- package/src/cli/livePrompt.ts +615 -0
- package/src/cli/main.ts +206 -76
- package/src/cli/modelkey.ts +124 -0
- package/src/cli/outboxSync.ts +231 -0
- package/src/cli/plain.ts +260 -0
- package/src/cli/proofs.ts +27 -0
- package/src/cli/ref.ts +5 -4
- package/src/cli/releaseNotice.ts +200 -0
- package/src/cli/sdk.ts +87 -7
- package/src/cli/settings.ts +272 -22
- package/src/cli/textfit.ts +95 -0
- package/src/constants.ts +1 -1
- package/src/context.ts +28 -0
- package/src/index.ts +50 -7
- package/src/legacy/modelKey.ts +80 -0
- package/src/legacy/serveProofV1.ts +124 -0
- package/src/provider-catalog.json +3 -2
- package/src/secretEnv.ts +18 -3
- package/src/types.ts +60 -1
- package/src/viemErrors.ts +39 -0
package/src/index.ts
CHANGED
|
@@ -27,17 +27,20 @@ if (typeof (globalThis as { fetch?: unknown }).fetch !== 'function') {
|
|
|
27
27
|
|
|
28
28
|
// ── Facade + namespaces ──
|
|
29
29
|
export { AgenticID as AgentDNA, AgenticID, AgentApi, AdminApi, ReputationApi } from './AgenticID';
|
|
30
|
-
export type { ContainerStatus, DeployAccepted, WaitLevel } from './AgenticID';
|
|
30
|
+
export type { ContainerStatus, DeployAccepted, WaitLevel, ModelKeyLifecycleOpts } from './AgenticID';
|
|
31
|
+
export { fetchReleases, releaseNoticeOf, agentMigrationOf } from './Releases';
|
|
32
|
+
export type { ReleaseNotice, ReleaseMigration, AgentMigration, MigrationState } from './Releases';
|
|
31
33
|
export { makeAgentClient } from './AgentClient';
|
|
32
34
|
export type {
|
|
33
35
|
AgentClient, AgentServiceEntry, AgentRoute, ChatMessage, ChatCompletion, AgentTask,
|
|
34
|
-
AgentTaskInfo, AgentTaskStop, AgentInbox, AgentInboxMessage, AgentSchedule, AgentEvent,
|
|
36
|
+
AgentActivityInfo, AgentActivityStop, AgentTaskInfo, AgentTaskStop, AgentInbox, AgentInboxMessage, AgentSchedule, AgentEvent,
|
|
37
|
+
ChatImage, ChatNotice, UploadedFile, SteerResult, AgentSession, SessionPromptResult, HarnessTask, HarnessTaskState, HarnessTaskRecord, HarnessTaskSummary, HarnessTaskFeedEvent, CreateTaskOptions, TaskInputResult, SteerState, AgentFile, AgentFileDir,
|
|
35
38
|
} from './AgentClient';
|
|
36
|
-
export { mcpServices } from './AgentClient';
|
|
39
|
+
export { mcpServices, withImages } from './AgentClient';
|
|
37
40
|
export { defaultIData, DEFAULT_PERSONA_INFERENCE, deploymentFactsOf, needsDefaultSettings, storeDefaultSettings } from './AttestorClient';
|
|
38
41
|
export type { DeploymentFacts } from './AttestorClient';
|
|
39
42
|
export type { DefaultIDataParams } from './AttestorClient';
|
|
40
|
-
export type { AgenticIDConfig as AgentDNAConfig, AgenticIDConfig } from './context';
|
|
43
|
+
export type { AgenticIDConfig as AgentDNAConfig, AgenticIDConfig, CredentialMarkRecord } from './context';
|
|
41
44
|
|
|
42
45
|
// ── Namespace implementation classes (advanced / typing) ──
|
|
43
46
|
export { SandboxClient } from './SandboxClient';
|
|
@@ -46,6 +49,8 @@ export type { IntelligentDataResult } from './AgenticIDClient';
|
|
|
46
49
|
export { ReputationClient, MAX_ABS_FEEDBACK_VALUE } from './ReputationClient';
|
|
47
50
|
export { AttestorClient, CLONE_DOMAIN, CLONE_CONTRACT_DOMAIN, DEPLOY_DOMAIN, b64encode } from './AttestorClient';
|
|
48
51
|
export type { CloneParams, DeployParams, IDataInput, DeployCloneResponse } from './AttestorClient';
|
|
52
|
+
export { OPERATOR_DOMAIN, OperatorConflictError, OperatorCheckpointSupersededError } from './Operators';
|
|
53
|
+
export type { OperatorState, OperatorOptions, OperatorCheckpoint, RuntimeBinding } from './Operators';
|
|
49
54
|
// Sealed secret env (issue #166): the inference key sealed to the agent's
|
|
50
55
|
// agentSeal key instead of riding the signed envelope in clear.
|
|
51
56
|
export { SECRET_ENV_SCHEME, SECRET_ENV_VAR, SecretEnvRefusedError, sealSecretEnv } from './secretEnv';
|
|
@@ -64,8 +69,38 @@ export {
|
|
|
64
69
|
sha256Hex,
|
|
65
70
|
modelAdvisory,
|
|
66
71
|
fetchRouterModelIds,
|
|
72
|
+
versionPicksProblem,
|
|
67
73
|
} from './Settings';
|
|
68
|
-
export type { SettingsDoc, ThinkingLevel } from './Settings';
|
|
74
|
+
export type { SettingsDoc, ThinkingLevel, VersionPicks } from './Settings';
|
|
75
|
+
export {
|
|
76
|
+
CredentialsApi,
|
|
77
|
+
CredentialsConflictError,
|
|
78
|
+
CredentialsUnverifiedError,
|
|
79
|
+
credentialSetTypes,
|
|
80
|
+
approvalTypes,
|
|
81
|
+
definitionOf,
|
|
82
|
+
inputOf,
|
|
83
|
+
credentialPlaintext,
|
|
84
|
+
modelKeyName,
|
|
85
|
+
MODEL_KEY_PREFIX,
|
|
86
|
+
CREDENTIALS_DOMAIN_NAME,
|
|
87
|
+
CREDENTIALS_DOMAIN_VERSION,
|
|
88
|
+
} from './Credentials';
|
|
89
|
+
export type {
|
|
90
|
+
CredentialSigner,
|
|
91
|
+
CredentialMCP,
|
|
92
|
+
CredentialInput,
|
|
93
|
+
CredentialDefinition,
|
|
94
|
+
CredentialDocument,
|
|
95
|
+
CredentialPosition,
|
|
96
|
+
TokenRequestTemplate,
|
|
97
|
+
PendingCredentialRequest,
|
|
98
|
+
CredentialInference,
|
|
99
|
+
ModelKeyInUse,
|
|
100
|
+
ModelKeysView,
|
|
101
|
+
LoadedCredentials,
|
|
102
|
+
SealedModelKey,
|
|
103
|
+
} from './Credentials';
|
|
69
104
|
|
|
70
105
|
// ── Reputation: serve-proof transport + verification ──
|
|
71
106
|
export {
|
|
@@ -86,8 +121,13 @@ export {
|
|
|
86
121
|
buildServeProof,
|
|
87
122
|
signServeProof,
|
|
88
123
|
verifyServeProofSignature,
|
|
124
|
+
serveProofLayers,
|
|
125
|
+
SERVE_PROOF_VERSION,
|
|
126
|
+
SERVE_PROOF_V2_TAG,
|
|
89
127
|
} from './ServeProof';
|
|
90
|
-
export type { BuildServeProofHashParams, BuildServeProofSigningHashParams } from './ServeProof';
|
|
128
|
+
export type { BuildServeProofHashParams, BuildServeProofSigningHashParams, ServeProofLayers } from './ServeProof';
|
|
129
|
+
export { TRUST_KINDS, trustRegistryOf, isListed, listedHashes } from './TrustRegistry';
|
|
130
|
+
export type { TrustKind } from './TrustRegistry';
|
|
91
131
|
export { taskHashOf, requestUriOf, requestUriCandidates } from './taskHash';
|
|
92
132
|
|
|
93
133
|
// ── Types ──
|
|
@@ -97,12 +137,14 @@ export type {
|
|
|
97
137
|
Feedback,
|
|
98
138
|
FeedbackSummary,
|
|
99
139
|
ServeData,
|
|
140
|
+
ServeLayers,
|
|
100
141
|
GiveFeedbackParams,
|
|
101
142
|
GiveFeedbackResult,
|
|
102
143
|
TaskReveal,
|
|
103
144
|
AppendResponseParams,
|
|
104
145
|
ReadAllFeedbackParams,
|
|
105
146
|
GetSummaryParams,
|
|
147
|
+
SignatureRecord,
|
|
106
148
|
} from './types';
|
|
107
149
|
|
|
108
150
|
// ── Constants ──
|
|
@@ -120,6 +162,7 @@ export type { ContractAddresses } from './constants';
|
|
|
120
162
|
// ── ABIs (advanced usage) ──
|
|
121
163
|
export {
|
|
122
164
|
agenticIDAbi,
|
|
165
|
+
trustRegistryAbi,
|
|
123
166
|
cloneGateAbi,
|
|
124
167
|
standardCloneAuthorizerAbi,
|
|
125
168
|
canonicalReputationAbi,
|
|
@@ -129,5 +172,5 @@ export {
|
|
|
129
172
|
sandboxServingAbi,
|
|
130
173
|
} from './abi';
|
|
131
174
|
|
|
132
|
-
export { listInferenceProviders, inferenceProvider, routeHash } from './Providers';
|
|
175
|
+
export { listInferenceProviders, inferenceProvider, providerWebSearch, routeHash } from './Providers';
|
|
133
176
|
export type { InferenceProvider, InferenceFormat, InferenceModel, ProviderRegistrySnapshot, ProviderRegistryPin } from './Providers';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file legacy/modelKey.ts
|
|
3
|
+
* @description LEGACY(model-key): model keys sent with the request.
|
|
4
|
+
*
|
|
5
|
+
* The SDK keeps every model key in the agent's credential set
|
|
6
|
+
* (`model.<provider>`). Two kinds of peers from before that need more, and
|
|
7
|
+
* the SDK's part of it is here:
|
|
8
|
+
*
|
|
9
|
+
* - images that read the key only from the create/reset request: a key given
|
|
10
|
+
* to `deploy` / `start` / `reset` / `retry` also rides the request
|
|
11
|
+
* ({@link deployRequestKey}, {@link requestKey}), and so does a key an
|
|
12
|
+
* integrator's server seals ({@link requestSecretEnv});
|
|
13
|
+
* - attestors that take no credential set before the mint: `deploy` stores
|
|
14
|
+
* the key once minted ({@link storeAfterMint}).
|
|
15
|
+
*
|
|
16
|
+
* The request key itself is built where every request is (AttestorClient's
|
|
17
|
+
* `sandboxEnv`, `keyEnv` and `sealApiKey`, with secretEnv.ts); the CLI's part
|
|
18
|
+
* is in cli/legacy/modelKey.ts. Once every image reads model keys from the
|
|
19
|
+
* set and every attestor takes a set before the mint, delete this file and
|
|
20
|
+
* cli/legacy/modelKey.ts, and remove every piece marked LEGACY(model-key)
|
|
21
|
+
* (`git grep -n 'LEGACY(model-key)'`). Deleting the files makes the compiler
|
|
22
|
+
* list the call sites that send the key; the marks find the rest (the
|
|
23
|
+
* request-building code behind them, the options, types and messages that
|
|
24
|
+
* only describe the request copy). The attestor drops the request key
|
|
25
|
+
* (`OWNER_ENV_KEYS`) only after no client sends it any more, this SDK's
|
|
26
|
+
* releases until then included.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import type { DeployAccepted, ModelKeyLifecycleOpts } from '../AgenticID';
|
|
30
|
+
import type { AttestorClient } from '../AttestorClient';
|
|
31
|
+
import { SecretEnvRefusedError, type SecretEnvMode } from '../secretEnv';
|
|
32
|
+
|
|
33
|
+
/** What a start/reset/retry request carries besides the credential set: the key, for images that read only the request. */
|
|
34
|
+
export function requestKey(opts: ModelKeyLifecycleOpts): { apiKey?: string; sealedSecretEnv?: string; secretEnv?: SecretEnvMode } {
|
|
35
|
+
if (opts.sealedModelKey && opts.sealedSecretEnv !== undefined) {
|
|
36
|
+
throw new SecretEnvRefusedError('conflicting_inputs', 'pass sealedModelKey or sealedSecretEnv, not both');
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
apiKey: opts.apiKey,
|
|
40
|
+
sealedSecretEnv: opts.sealedSecretEnv ?? opts.sealedModelKey?.secretEnv,
|
|
41
|
+
secretEnv: opts.secretEnv,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Whether a start/reset/retry request carries the key, for images that read only the request. */
|
|
46
|
+
export function carriesRequestKey(p: { apiKey?: string; sealedSecretEnv?: string }): boolean {
|
|
47
|
+
return !!p.apiKey || p.sealedSecretEnv !== undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The key a deploy's create envelope carries, for images that read only the request. */
|
|
51
|
+
export function deployRequestKey(sandbox: { apiKey?: string; secretEnv?: SecretEnvMode }): { apiKey?: string; mode?: SecretEnvMode } {
|
|
52
|
+
return { apiKey: sandbox.apiKey, mode: sandbox.secretEnv };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** `keepStoredModelKey`: the set holds the key already, and it goes with the request only. */
|
|
56
|
+
export function requestOnly(opts: ModelKeyLifecycleOpts): boolean {
|
|
57
|
+
return !!opts.keepStoredModelKey;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The key as an older image reads it with the request (`sealApiKey`), beside
|
|
62
|
+
* the value `sealModelKey` seals for the set. None when the attestor does
|
|
63
|
+
* not seal request keys: the key then reaches only images that read the set.
|
|
64
|
+
*/
|
|
65
|
+
export async function requestSecretEnv(
|
|
66
|
+
attestor: AttestorClient,
|
|
67
|
+
p: { sealId: `0x${string}`; owner: `0x${string}`; apiKey: string; provider: string; framework?: string; sealedImage?: string },
|
|
68
|
+
): Promise<string | undefined> {
|
|
69
|
+
try {
|
|
70
|
+
return await attestor.sealApiKey(p);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
if (e instanceof SecretEnvRefusedError && e.code === 'scheme_unsupported') return undefined;
|
|
73
|
+
throw e;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** After the mint, for an attestor that took no set before it: the key goes in now. */
|
|
78
|
+
export async function storeAfterMint(accepted: DeployAccepted, store: () => Promise<boolean>): Promise<void> {
|
|
79
|
+
if (!accepted.modelKeyStored) accepted.modelKeyStored = await store();
|
|
80
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file legacy/serveProofV1.ts
|
|
3
|
+
* @description LEGACY(v1): ServeProof v1 — what every image before the
|
|
4
|
+
* layered runtime signs (sealed/LAYERS.md §8, "Compatibility with existing
|
|
5
|
+
* 0g-harness images"): a proof whose envelope carries no `version`.
|
|
6
|
+
*
|
|
7
|
+
* The rest of the SDK speaks v2 and comes here only for a proof without a
|
|
8
|
+
* version: the v1 digest, and the registry's and the batcher's v1 entry
|
|
9
|
+
* points. Once those images are gone, delete this file and every
|
|
10
|
+
* `LEGACY(v1)` mark (`git grep -n 'LEGACY(v1)'`): the compiler lists every
|
|
11
|
+
* call site, each one branch of a version dispatch, and the marks show the
|
|
12
|
+
* places it cannot see — where a proof without a `version` is read as v1, the
|
|
13
|
+
* v1 ABI entries and vectors. A proof without a version is then malformed.
|
|
14
|
+
* The registry keeps its v1 entry points, and nothing here is needed to read
|
|
15
|
+
* the marks v1 proofs left.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
concat,
|
|
20
|
+
encodeFunctionData,
|
|
21
|
+
keccak256,
|
|
22
|
+
pad,
|
|
23
|
+
toHex,
|
|
24
|
+
type Account,
|
|
25
|
+
type Address,
|
|
26
|
+
type Chain,
|
|
27
|
+
type Hash,
|
|
28
|
+
type Hex,
|
|
29
|
+
type WalletClient,
|
|
30
|
+
} from 'viem';
|
|
31
|
+
import { feedbackBatcherAbi, verifiedFeedbackAbi } from '../abi';
|
|
32
|
+
import type { FeedbackArgs } from '../ReputationClient';
|
|
33
|
+
import type { ServeProof, TaskReveal } from '../types';
|
|
34
|
+
|
|
35
|
+
/** The fields the v1 preimage covers (BuildServeProofHashParams without a version). */
|
|
36
|
+
interface ServeProofV1Fields {
|
|
37
|
+
chainId: bigint;
|
|
38
|
+
verifyingContract: Address;
|
|
39
|
+
submitter: Address;
|
|
40
|
+
agentId: bigint;
|
|
41
|
+
timestamp: bigint;
|
|
42
|
+
deadline: bigint;
|
|
43
|
+
taskHash: Hash;
|
|
44
|
+
dataHashes: Hash[];
|
|
45
|
+
frameworkHash: Hash;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The v1 inner hash, exactly as the registry's `_serveProofHash`:
|
|
50
|
+
*
|
|
51
|
+
* ```solidity
|
|
52
|
+
* keccak256(abi.encode(
|
|
53
|
+
* block.chainid, identityRegistry, submitter, agentId, timestamp,
|
|
54
|
+
* deadline, taskHash, keccak256(abi.encodePacked(dataHashes)),
|
|
55
|
+
* frameworkHash))
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* Every field is a static 32-byte word (uint256, a left-padded address,
|
|
59
|
+
* bytes32), so abi.encode is a plain concatenation.
|
|
60
|
+
*/
|
|
61
|
+
export function serveProofHashV1(p: ServeProofV1Fields): Hash {
|
|
62
|
+
const packedDataHashes: Hex = p.dataHashes.length > 0 ? concat(p.dataHashes as readonly Hex[]) : '0x';
|
|
63
|
+
return keccak256(concat([
|
|
64
|
+
pad(toHex(p.chainId), { size: 32 }),
|
|
65
|
+
pad(p.verifyingContract as Hex, { size: 32 }),
|
|
66
|
+
pad(p.submitter as Hex, { size: 32 }),
|
|
67
|
+
pad(toHex(p.agentId), { size: 32 }),
|
|
68
|
+
pad(toHex(p.timestamp), { size: 32 }),
|
|
69
|
+
pad(toHex(p.deadline), { size: 32 }),
|
|
70
|
+
pad(p.taskHash as Hex, { size: 32 }),
|
|
71
|
+
pad(keccak256(packedDataHashes), { size: 32 }),
|
|
72
|
+
pad(p.frameworkHash as Hex, { size: 32 }),
|
|
73
|
+
]));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The eight on-chain fields of a v1 proof. The envelope's `validator` is not
|
|
77
|
+
* one of them (ABI encoding would drop an undeclared key anyway; this keeps
|
|
78
|
+
* the intent explicit). */
|
|
79
|
+
function v1Tuple(proof: ServeProof) {
|
|
80
|
+
return {
|
|
81
|
+
agentId: proof.agentId,
|
|
82
|
+
submitter: proof.submitter,
|
|
83
|
+
timestamp: proof.timestamp,
|
|
84
|
+
deadline: proof.deadline,
|
|
85
|
+
taskHash: proof.taskHash,
|
|
86
|
+
dataHashes: proof.dataHashes,
|
|
87
|
+
frameworkHash: proof.frameworkHash,
|
|
88
|
+
signature: proof.signature,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** `attestFeedback`, or `attestFeedbackWithTask` with a task, for a v1 proof. */
|
|
93
|
+
export function attestV1(
|
|
94
|
+
wallet: WalletClient,
|
|
95
|
+
tx: { address: Address; account: Account; chain: Chain },
|
|
96
|
+
agentId: bigint,
|
|
97
|
+
feedbackIndex: bigint,
|
|
98
|
+
proof: ServeProof,
|
|
99
|
+
task?: TaskReveal,
|
|
100
|
+
): Promise<Hash> {
|
|
101
|
+
return task
|
|
102
|
+
? wallet.writeContract({
|
|
103
|
+
...tx,
|
|
104
|
+
abi: verifiedFeedbackAbi,
|
|
105
|
+
functionName: 'attestFeedbackWithTask',
|
|
106
|
+
args: [agentId, feedbackIndex, v1Tuple(proof), task],
|
|
107
|
+
})
|
|
108
|
+
: wallet.writeContract({
|
|
109
|
+
...tx,
|
|
110
|
+
abi: verifiedFeedbackAbi,
|
|
111
|
+
functionName: 'attestFeedback',
|
|
112
|
+
args: [agentId, feedbackIndex, v1Tuple(proof)],
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** FeedbackBatcher calldata for a v1 proof: `giveFeedbackAndAttest`. An empty
|
|
117
|
+
* `task.method` routes to plain attestFeedback. */
|
|
118
|
+
export function batchCallV1(feedback: FeedbackArgs, proof: ServeProof, task: TaskReveal): Hex {
|
|
119
|
+
return encodeFunctionData({
|
|
120
|
+
abi: feedbackBatcherAbi,
|
|
121
|
+
functionName: 'giveFeedbackAndAttest',
|
|
122
|
+
args: [...feedback, v1Tuple(proof), task],
|
|
123
|
+
});
|
|
124
|
+
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"anthropic": "https://router-api.0g.ai"
|
|
10
10
|
},
|
|
11
11
|
"modelCatalog": "https://router-api.0g.ai/v1/models",
|
|
12
|
+
"webSearch": "0g-router",
|
|
12
13
|
"compatibility": {
|
|
13
14
|
"requiresStringContent": true,
|
|
14
15
|
"supportsStore": false,
|
|
@@ -18,6 +19,6 @@
|
|
|
18
19
|
"maxTokensField": "max_tokens"
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
|
-
{ "id": "openai", "name": "OpenAI", "native": true, "formats": ["openai"] },
|
|
22
|
-
{ "id": "anthropic", "name": "Anthropic", "native": true, "formats": ["anthropic"] }
|
|
22
|
+
{ "id": "openai", "name": "OpenAI", "native": true, "formats": ["openai"], "webSearch": "openai" },
|
|
23
|
+
{ "id": "anthropic", "name": "Anthropic", "native": true, "formats": ["anthropic"], "webSearch": "anthropic" }
|
|
23
24
|
]
|
package/src/secretEnv.ts
CHANGED
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
* agent's agentSeal public key, so it never appears in clear in the envelope
|
|
5
5
|
* the owner's wallet signs (issue #166).
|
|
6
6
|
*
|
|
7
|
+
* LEGACY(model-key): model keys go into the agent's credential set
|
|
8
|
+
* (Credentials.ts; an integrator's with `sealModelKey`). The secret env is the
|
|
9
|
+
* copy sent with the request for images that read only that
|
|
10
|
+
* (legacy/modelKey.ts), and its parts here go with it: the scheme and its
|
|
11
|
+
* variable, {@link SecretEnvMode}, `sealSecretEnv`, `checkSealedSecretEnv` and
|
|
12
|
+
* the request-only refusal codes. What stays: {@link eciesEncrypt}, which the
|
|
13
|
+
* credential set seals with; {@link SecretEnvRefusedError}, which the
|
|
14
|
+
* credential set's checks throw too; the agentSeal key checks
|
|
15
|
+
* (`parseAgentSealPubkey`, `publicKeyToAddress`).
|
|
16
|
+
*
|
|
7
17
|
* The sandbox "create" envelope is signed with EIP-191 `personal_sign`, and a
|
|
8
18
|
* wallet shows that message verbatim. With the key in `env.API_KEY`, the
|
|
9
19
|
* prompt displayed it, and every hop that relays the envelope (an
|
|
@@ -35,13 +45,14 @@ import { sha256 } from '@noble/hashes/sha2';
|
|
|
35
45
|
import { gcm } from '@noble/ciphers/aes';
|
|
36
46
|
import { getAddress, hexToBytes, keccak256, toHex, type Address, type Hex } from 'viem';
|
|
37
47
|
|
|
38
|
-
/** `GET /config` value that says this attestor's sealed images open a secret env. */
|
|
48
|
+
/** LEGACY(model-key): `GET /config` value that says this attestor's sealed images open a secret env. */
|
|
39
49
|
export const SECRET_ENV_SCHEME = 'agent-seal-ecies-v1';
|
|
40
|
-
/**
|
|
50
|
+
/** LEGACY(model-key): the container env var that carries the sealed secret env. */
|
|
41
51
|
export const SECRET_ENV_VAR = 'SEAL_SECRET_ENV';
|
|
42
52
|
|
|
43
53
|
/**
|
|
44
|
-
*
|
|
54
|
+
* LEGACY(model-key): how `start` / `reset` / `retry` / `deploy` deliver the
|
|
55
|
+
* request copy of the inference key:
|
|
45
56
|
* - `'auto'` (default): sealed to the agent when the attestor advertises
|
|
46
57
|
* `secret_env_scheme` and the agent exists already; otherwise in clear
|
|
47
58
|
* (older attestors, and a one-shot `deploy` with `sandbox`, whose agent
|
|
@@ -173,6 +184,8 @@ function randomValidPriv(): Uint8Array {
|
|
|
173
184
|
}
|
|
174
185
|
|
|
175
186
|
/**
|
|
187
|
+
* LEGACY(model-key): the request copy of a key.
|
|
188
|
+
*
|
|
176
189
|
* Seal `env` for one agent. `agentSealPubkey` is the agent's agentSeal public
|
|
177
190
|
* key (hex, compressed or uncompressed); `owner` is the address that will sign
|
|
178
191
|
* the envelope (the container requires it to be the agent's on-chain owner).
|
|
@@ -227,6 +240,8 @@ function fromBase64(s: string): Uint8Array {
|
|
|
227
240
|
const MIN_PLAINTEXT = 70;
|
|
228
241
|
|
|
229
242
|
/**
|
|
243
|
+
* LEGACY(model-key): the request copy of a key.
|
|
244
|
+
*
|
|
230
245
|
* Check that `value` has the shape `sealSecretEnv` produces (standard base64
|
|
231
246
|
* of `ephemeralPub(65) ‖ nonce(16) ‖ tag(16) ‖ ct`, with a valid ephemeral
|
|
232
247
|
* point) and return it trimmed. The SDK cannot decrypt it, so this does not
|
package/src/types.ts
CHANGED
|
@@ -70,12 +70,25 @@ export interface ServeProof {
|
|
|
70
70
|
taskHash: `0x${string}`;
|
|
71
71
|
/** Hashes of the data involved in the service */
|
|
72
72
|
dataHashes: `0x${string}`[];
|
|
73
|
-
/** Hash of the agent framework version */
|
|
73
|
+
/** Hash of the agent framework version: the image hash (base) */
|
|
74
74
|
frameworkHash: `0x${string}`;
|
|
75
75
|
/** agentSeal signature: EIP-191 version 0x00 (data with intended validator
|
|
76
76
|
* = the VerifiedFeedbackRegistry proxy) over the proof's abi.encode hash —
|
|
77
77
|
* see buildServeProofSigningHash. NOT personal_sign. */
|
|
78
78
|
signature: `0x${string}`;
|
|
79
|
+
/** 2 for a versioned proof, which also signs the four fields below;
|
|
80
|
+
* LEGACY(v1): absent for v1, what images before the layered runtime sign.
|
|
81
|
+
* It picks the digest and the registry entry point (sealed/LAYERS.md §7). */
|
|
82
|
+
version?: number;
|
|
83
|
+
/** v2: sha256 of the sealed program the loader verified and ran. */
|
|
84
|
+
sealedHash?: `0x${string}`;
|
|
85
|
+
/** v2: sha256 of the official harness version running. */
|
|
86
|
+
harnessHash?: `0x${string}`;
|
|
87
|
+
/** v2: where sealed's inference proxy forwarded model calls; '' when the
|
|
88
|
+
* framework dials its provider itself. */
|
|
89
|
+
inferenceURL?: string;
|
|
90
|
+
/** v2: the model name the inference proxy sent, the owner's setting. */
|
|
91
|
+
model?: string;
|
|
79
92
|
/** The VerifiedFeedbackRegistry the sealed proxy signed this proof for, as
|
|
80
93
|
* echoed in the X-Agent-Proof envelope. Diagnostics only: unsigned, NOT part
|
|
81
94
|
* of the on-chain ServeProof tuple (the registry uses its own address), and
|
|
@@ -173,6 +186,17 @@ export interface ServeData {
|
|
|
173
186
|
frameworkHash: `0x${string}`;
|
|
174
187
|
}
|
|
175
188
|
|
|
189
|
+
/**
|
|
190
|
+
* The layers a verified entry's ServeProof named (v2): the sealed program and
|
|
191
|
+
* the official harness version. Zero hashes for an entry attested with a v1
|
|
192
|
+
* proof.
|
|
193
|
+
* @struct
|
|
194
|
+
*/
|
|
195
|
+
export interface ServeLayers {
|
|
196
|
+
sealedHash: `0x${string}`;
|
|
197
|
+
harnessHash: `0x${string}`;
|
|
198
|
+
}
|
|
199
|
+
|
|
176
200
|
/**
|
|
177
201
|
* Parameters for registering an agent.
|
|
178
202
|
*/
|
|
@@ -355,3 +379,38 @@ export interface GetSummaryParams {
|
|
|
355
379
|
/** Second tag filter. Default: no filter. */
|
|
356
380
|
tag2?: string;
|
|
357
381
|
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* One record of what an agent's sign socket did: a signature it made, or a
|
|
385
|
+
* request a rule refused (`result: "refused"`, with `reason`). Which fields
|
|
386
|
+
* are set depends on `kind`. Read with `AgenticID.signatures`.
|
|
387
|
+
*/
|
|
388
|
+
export interface SignatureRecord {
|
|
389
|
+
/** Record number; pass the last one seen as `after` to read only newer ones. */
|
|
390
|
+
seq: number;
|
|
391
|
+
/** When, RFC 3339. */
|
|
392
|
+
ts: string;
|
|
393
|
+
kind: 'personal_sign' | 'typed_data' | 'transaction';
|
|
394
|
+
result: 'signed' | 'refused';
|
|
395
|
+
/** Why a rule refused it. */
|
|
396
|
+
reason?: string;
|
|
397
|
+
/** personal_sign: the EIP-191 hash, the message length in bytes, and its start when it is text. */
|
|
398
|
+
msg_hash?: string;
|
|
399
|
+
length?: number;
|
|
400
|
+
text?: string;
|
|
401
|
+
/** typed_data: the EIP-712 digest, the primary type and the domain fields set. */
|
|
402
|
+
digest?: string;
|
|
403
|
+
primary_type?: string;
|
|
404
|
+
domain?: { name?: string; version?: string; chain_id?: string; verifying_contract?: string };
|
|
405
|
+
/** transaction: what was signed. `create` marks a contract creation (no `to`). */
|
|
406
|
+
tx_hash?: string;
|
|
407
|
+
chain_id?: string;
|
|
408
|
+
to?: string;
|
|
409
|
+
create?: boolean;
|
|
410
|
+
/** Wei, decimal. */
|
|
411
|
+
value?: string;
|
|
412
|
+
nonce?: number;
|
|
413
|
+
/** The calldata's first four bytes, and its length in bytes. */
|
|
414
|
+
selector?: string;
|
|
415
|
+
data_len?: number;
|
|
416
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file viemErrors.ts
|
|
3
|
+
* @description viem errors found by name along the cause chain. Not by
|
|
4
|
+
* `instanceof`: viem ships separate ESM and CommonJS builds, and an error
|
|
5
|
+
* made by one copy is no instance of the other's class — a caller's client,
|
|
6
|
+
* or a test stub, on the ESM build would slip past this CommonJS build's
|
|
7
|
+
* checks.
|
|
8
|
+
*
|
|
9
|
+
* LEGACY(pre-1.4.0): every caller tells a deployment from before AgenticID
|
|
10
|
+
* 1.4.0 / FeedbackBatcher v5 by a revert (trustRegistryOf, the batcher
|
|
11
|
+
* probe); the file goes with them.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** A viem error's fields this SDK reads. */
|
|
15
|
+
export interface ViemErrorLike {
|
|
16
|
+
name: string;
|
|
17
|
+
/** ContractFunctionRevertedError: the decoded custom error, when the ABI has it. */
|
|
18
|
+
data?: { errorName?: string };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The first error along `e`'s cause chain whose name is one of `names`. */
|
|
22
|
+
export function findViemError(e: unknown, names: readonly string[]): ViemErrorLike | null {
|
|
23
|
+
let x = e as { name?: unknown; cause?: unknown } | null | undefined;
|
|
24
|
+
for (let depth = 0; x && typeof x === 'object' && depth < 16; depth++) {
|
|
25
|
+
if (typeof x.name === 'string' && names.includes(x.name)) return x as ViemErrorLike;
|
|
26
|
+
x = x.cause as typeof x;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Whether `e` is the contract refusing the call — the node said it
|
|
32
|
+
* reverted (JSON-RPC code 3, or "execution reverted": viem's
|
|
33
|
+
* ExecutionRevertedError), or it returned no data at all — as opposed to a
|
|
34
|
+
* call that got no answer, or an answer that is no revert. A
|
|
35
|
+
* ContractFunctionRevertedError alone proves nothing: viem also wraps a
|
|
36
|
+
* node's internal error (-32603) in one. */
|
|
37
|
+
export function isContractRevert(e: unknown): boolean {
|
|
38
|
+
return !!findViemError(e, ['ExecutionRevertedError', 'ContractFunctionZeroDataError']);
|
|
39
|
+
}
|