@inneranimalmedia/agentsam-sdk 2.6.0 → 2.6.2
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/docs/AUTH_IDENTITY_CONTRACT.md +25 -27
- package/docs/PLATFORM_RUNTIME_EVENTS.md +48 -0
- package/docs/RELEASES.md +7 -7
- package/docs/SDK_WORKER.md +4 -3
- package/docs/SOURCE_ARCHITECTURE.md +58 -0
- package/docs/TEST_TIERS.md +26 -0
- package/migrations/runtime/0001_cli_runtime.sql +298 -0
- package/package.json +28 -7
- package/packages/agentsam-repository/README.md +15 -0
- package/packages/agentsam-repository/package.json +25 -0
- package/packages/agentsam-repository/src/contracts.js +113 -0
- package/packages/agentsam-repository/src/index.js +3 -0
- package/{src/lib → packages/agentsam-repository/src}/merkle/cloudflare-persistence.js +14 -24
- package/{src/lib → packages/agentsam-repository/src}/merkle/index.js +1 -0
- package/{src/lib → packages/agentsam-repository/src}/merkle/persistence.js +6 -4
- package/{src/lib → packages/agentsam-repository/src}/merkle/policy.js +1 -0
- package/packages/agentsam-repository/test/contracts.test.mjs +40 -0
- package/packages/agentsam-repository/test/git-context.test.mjs +24 -0
- package/{test/merkle.test.mjs → packages/agentsam-repository/test/merkle-core.test.mjs} +2 -32
- package/{test → packages/agentsam-repository/test}/merkle-persistence.test.mjs +11 -6
- package/packages/identity/package.json +2 -2
- package/packages/identity/src/contracts/auth-config.js +23 -40
- package/packages/identity/tests/auth-config.test.mjs +14 -23
- package/protocol/COMPANY_REPOSITORY_GRAPH_V1.md +91 -0
- package/protocol/MERKLE_PERSISTENCE_V1.md +2 -0
- package/protocol/MERKLE_PERSISTENCE_V2.md +40 -0
- package/protocol/repository/repository-contract.schema.json +24 -0
- package/protocol/repository/repository-dependency.schema.json +24 -0
- package/protocol/repository/repository-identity.schema.json +17 -0
- package/protocol/rpc/v1/common.proto +16 -0
- package/protocol/rpc/v1/errors.proto +35 -0
- package/protocol/rpc/v1/knowledge.proto +77 -0
- package/services/knowledge/package-lock.json +333 -0
- package/services/knowledge/package.json +5 -1
- package/src/agent/responses-runner.js +63 -35
- package/src/capabilities/repository-snapshot.js +3 -3
- package/src/cli.js +36 -29
- package/src/commands/account-auth.js +1 -1
- package/src/commands/context-economics.js +17 -2
- package/src/commands/context.js +1 -1
- package/src/commands/db.js +20 -3
- package/src/commands/deploy.js +2 -2
- package/src/commands/env.js +90 -0
- package/src/commands/knowledge.js +12 -4
- package/src/commands/merkle-persist.js +30 -11
- package/src/commands/merkle.js +1 -1
- package/src/commands/models.js +123 -65
- package/src/commands/ollama.js +26 -0
- package/src/commands/preferences.js +53 -26
- package/src/commands/providers.js +308 -0
- package/src/commands/shell.js +240 -48
- package/src/commands/tunnel.js +8 -8
- package/src/commands/whoami.js +42 -21
- package/src/errors/contract.js +236 -0
- package/src/errors/diagnostic.js +1 -0
- package/src/errors/index.js +14 -0
- package/src/index.js +13 -1
- package/src/knowledge/service/auth.js +13 -0
- package/src/knowledge/service/grpc-client.js +115 -0
- package/src/knowledge/service/grpc-codec.js +237 -0
- package/src/knowledge/service/grpc-server.js +83 -0
- package/src/knowledge/service/job-engine.js +248 -0
- package/src/knowledge/service/server.js +87 -135
- package/src/knowledge/source.js +1 -1
- package/src/lib/account-session.js +94 -25
- package/src/lib/auth.js +314 -51
- package/src/lib/cli-preferences.js +31 -4
- package/src/lib/core-client.js +75 -30
- package/src/lib/deploy-receipt/index.js +2 -2
- package/src/lib/detect-context.js +14 -16
- package/src/lib/knowledge-docker.js +6 -3
- package/src/lib/local-sessions.js +23 -2
- package/src/lib/local-status.js +1 -1
- package/src/lib/project-config.js +1 -1
- package/src/lib/provider-credentials.js +230 -14
- package/src/lib/slash-commands.js +5 -3
- package/src/local/migrations.js +93 -0
- package/src/local/runtime-store.js +141 -0
- package/src/local/sqlite.js +2 -0
- package/src/local-pty/server.js +113 -51
- package/src/models/discovery.js +327 -0
- package/src/providers/anthropic-messages.js +192 -0
- package/src/providers/cloudflare-chat.js +183 -0
- package/src/providers/factory.js +69 -0
- package/src/providers/gemini-generate-content.js +208 -0
- package/src/providers/index.js +5 -0
- package/src/providers/ollama-chat.js +148 -0
- package/src/providers/openai-responses.js +226 -75
- package/src/repository/index.js +14 -2
- package/src/rpc/generated/common_grpc_pb.js +1 -0
- package/src/rpc/generated/common_pb.js +536 -0
- package/src/rpc/generated/errors_grpc_pb.js +1 -0
- package/src/rpc/generated/errors_pb.js +482 -0
- package/src/rpc/generated/knowledge_grpc_pb.js +135 -0
- package/src/rpc/generated/knowledge_pb.js +2168 -0
- package/src/rpc/generated/package.json +3 -0
- package/src/security/trust-boundary.js +2 -2
- package/src/telemetry/events.js +4 -1
- package/src/ui/cli/activity.js +76 -0
- package/src/ui/cli/compaction.js +15 -0
- package/src/ui/cli/footer.js +39 -0
- package/src/ui/cli/help.js +194 -0
- package/src/ui/cli/plan.js +20 -0
- package/src/ui/cli/runtime-events.js +110 -0
- package/src/ui/cli/waiting.js +16 -0
- package/src/ui/merkle/render.js +1 -1
- package/test/account-session.test.mjs +48 -11
- package/test/apps-scaffold-contract.test.mjs +43 -0
- package/test/cli/preferences-runtime.test.mjs +11 -0
- package/test/cli/runtime-ui.test.mjs +74 -0
- package/test/error-diagnostics.test.mjs +57 -1
- package/test/fixtures/knowledge-rpc-worker.mjs +16 -0
- package/test/integration/cli-help.test.mjs +37 -0
- package/test/integration/knowledge-rpc.test.mjs +112 -0
- package/test/integration/merkle-cli.test.mjs +61 -0
- package/test/integration/merkle-persistence-identity.test.mjs +48 -0
- package/test/integration/provider-env-cli.test.mjs +49 -0
- package/test/integration/provider-factory.test.mjs +197 -0
- package/test/integration/repository-company-graph.test.mjs +90 -0
- package/test/integration/runtime-migrations.test.mjs +82 -0
- package/test/knowledge-service.test.mjs +5 -0
- package/test/knowledge.test.mjs +16 -0
- package/test/live/terminal-transport.live.test.mjs +24 -0
- package/test/local-sessions.test.mjs +7 -1
- package/test/models.test.mjs +101 -4
- package/test/ollama.test.mjs +21 -0
- package/test/portable-context.test.mjs +1 -1
- package/test/provider-credentials.test.mjs +45 -1
- package/test/release-hygiene.test.mjs +13 -5
- package/test/responses-runner.test.mjs +3 -1
- package/test/sdk-worker-contract.test.mjs +5 -1
- package/test/shell.test.mjs +50 -8
- package/test/smoke.mjs +2 -1
- package/test/terminal/local-pty.mock.test.mjs +151 -0
- package/test/whoami-resume.test.mjs +6 -5
- package/src/lib/prompt-byok.js +0 -57
- package/src/lib/save-sdk-token.js +0 -19
- /package/{src/lib → packages/agentsam-repository/src}/git-context.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/diff.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/filemeta.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/git-ignore.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/hash.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/semantic.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/snapshot.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/tree.js +0 -0
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Canonical AgentSam identity/auth environment contract.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Canonical variables:
|
|
8
|
-
* IAM_OAUTH_ISSUER public authorization-server authority (issuer)
|
|
9
|
-
* IAM_CLIENT_ID OAuth client id
|
|
10
|
-
* IAM_CLIENT_SECRET OAuth client secret
|
|
11
|
-
* IAM_ORIGIN deprecated alias of IAM_OAUTH_ISSUER (migration window)
|
|
12
|
-
* AGENTSAM_SDK_KEY account/delegated sdk_* bearer
|
|
13
|
-
* AGENTSAM_BRIDGE_KEY machine/integration credential
|
|
14
|
-
*
|
|
15
|
-
* Migration-only fallbacks:
|
|
16
|
-
* IAM_ORIGIN -> IAM_OAUTH_ISSUER
|
|
17
|
-
* AGENTSAM_SDK_TOKEN -> AGENTSAM_SDK_KEY
|
|
4
|
+
* Browser login sessions and reusable API credentials are intentionally
|
|
5
|
+
* separate: login sessions are opaque, machine-local session state while
|
|
6
|
+
* AGENTSAM_API_KEY is an explicit delegated account credential.
|
|
18
7
|
*/
|
|
19
8
|
|
|
20
9
|
export const DEFAULT_IAM_OAUTH_ISSUER = 'https://inneranimalmedia.com';
|
|
@@ -26,17 +15,12 @@ export const AGENTSAM_AUTH_ENV = Object.freeze({
|
|
|
26
15
|
iamOrigin: 'IAM_ORIGIN',
|
|
27
16
|
iamClientId: 'IAM_CLIENT_ID',
|
|
28
17
|
iamClientSecret: 'IAM_CLIENT_SECRET',
|
|
29
|
-
|
|
18
|
+
apiKey: 'AGENTSAM_API_KEY',
|
|
30
19
|
bridgeKey: 'AGENTSAM_BRIDGE_KEY',
|
|
31
20
|
});
|
|
32
21
|
|
|
33
|
-
export const AGENTSAM_AUTH_LEGACY_ENV = Object.freeze({
|
|
34
|
-
iamOrigin: 'IAM_ORIGIN',
|
|
35
|
-
sdkKey: 'AGENTSAM_SDK_TOKEN',
|
|
36
|
-
});
|
|
37
|
-
|
|
38
22
|
export const AGENTSAM_AUTH_CONTRACT = Object.freeze({
|
|
39
|
-
version:
|
|
23
|
+
version: 2,
|
|
40
24
|
authority: 'agentsam-sdk',
|
|
41
25
|
iam: Object.freeze({
|
|
42
26
|
issuer: AGENTSAM_AUTH_ENV.iamIssuer,
|
|
@@ -44,24 +28,23 @@ export const AGENTSAM_AUTH_CONTRACT = Object.freeze({
|
|
|
44
28
|
clientId: AGENTSAM_AUTH_ENV.iamClientId,
|
|
45
29
|
clientSecret: AGENTSAM_AUTH_ENV.iamClientSecret,
|
|
46
30
|
}),
|
|
47
|
-
|
|
48
|
-
env: AGENTSAM_AUTH_ENV.
|
|
49
|
-
tokenPrefix: '
|
|
31
|
+
apiKey: Object.freeze({
|
|
32
|
+
env: AGENTSAM_AUTH_ENV.apiKey,
|
|
33
|
+
tokenPrefix: 'aak_',
|
|
50
34
|
authorizationScheme: 'Bearer',
|
|
51
35
|
subject: 'account/delegated',
|
|
52
|
-
durableStore: '
|
|
36
|
+
durableStore: 'agentsam_api_credentials',
|
|
37
|
+
}),
|
|
38
|
+
browserSession: Object.freeze({
|
|
39
|
+
storage: '~/.agentsam/auth/session.json',
|
|
40
|
+
subject: 'interactive/user',
|
|
41
|
+
reusableApiCredential: false,
|
|
53
42
|
}),
|
|
54
43
|
bridge: Object.freeze({
|
|
55
44
|
env: AGENTSAM_AUTH_ENV.bridgeKey,
|
|
56
45
|
subject: 'machine/integration',
|
|
57
|
-
sdkTokenType: 'integration',
|
|
58
46
|
userAuth: false,
|
|
59
47
|
}),
|
|
60
|
-
compatibility: Object.freeze({
|
|
61
|
-
iamOriginFallback: AGENTSAM_AUTH_LEGACY_ENV.iamOrigin,
|
|
62
|
-
iamIssuerCanonical: AGENTSAM_AUTH_ENV.iamIssuer,
|
|
63
|
-
sdkKeyFallback: AGENTSAM_AUTH_LEGACY_ENV.sdkKey,
|
|
64
|
-
}),
|
|
65
48
|
});
|
|
66
49
|
|
|
67
50
|
function clean(value) {
|
|
@@ -84,24 +67,24 @@ export function resolveIamOrigin(env = {}, explicit = '') {
|
|
|
84
67
|
return resolveIamIssuer(env, explicit);
|
|
85
68
|
}
|
|
86
69
|
|
|
87
|
-
/** Resolve
|
|
88
|
-
export function
|
|
89
|
-
return clean(explicit || env?.
|
|
70
|
+
/** Resolve the reusable delegated account API credential. */
|
|
71
|
+
export function resolveApiKey(env = {}, explicit = '') {
|
|
72
|
+
return clean(explicit || env?.AGENTSAM_API_KEY);
|
|
90
73
|
}
|
|
91
74
|
|
|
92
|
-
/** Resolve machine/integration bridge credential. No
|
|
75
|
+
/** Resolve machine/integration bridge credential. No account API-key alias is accepted. */
|
|
93
76
|
export function resolveBridgeKey(env = {}, explicit = '') {
|
|
94
77
|
return clean(explicit || env?.AGENTSAM_BRIDGE_KEY);
|
|
95
78
|
}
|
|
96
79
|
|
|
97
|
-
export function
|
|
98
|
-
return clean(value).startsWith(AGENTSAM_AUTH_CONTRACT.
|
|
80
|
+
export function isApiKey(value) {
|
|
81
|
+
return clean(value).startsWith(AGENTSAM_AUTH_CONTRACT.apiKey.tokenPrefix);
|
|
99
82
|
}
|
|
100
83
|
|
|
101
|
-
/** Build the public bearer header for an
|
|
102
|
-
export function
|
|
84
|
+
/** Build the public bearer header for an AgentSam account API key. */
|
|
85
|
+
export function buildApiAuthorizationHeaders(key, headers = {}) {
|
|
103
86
|
const resolved = clean(key);
|
|
104
|
-
if (!
|
|
87
|
+
if (!isApiKey(resolved)) throw new Error('AGENTSAM_API_KEY_required');
|
|
105
88
|
return {
|
|
106
89
|
...headers,
|
|
107
90
|
Authorization: `Bearer ${resolved}`,
|
|
@@ -2,10 +2,10 @@ import assert from 'node:assert/strict';
|
|
|
2
2
|
import { describe, it } from 'node:test';
|
|
3
3
|
import {
|
|
4
4
|
AGENTSAM_AUTH_CONTRACT,
|
|
5
|
-
|
|
5
|
+
buildApiAuthorizationHeaders,
|
|
6
|
+
resolveApiKey,
|
|
6
7
|
resolveBridgeKey,
|
|
7
8
|
resolveIamOrigin,
|
|
8
|
-
resolveSdkKey,
|
|
9
9
|
} from '../src/contracts/auth-config.js';
|
|
10
10
|
|
|
11
11
|
describe('auth configuration contract', () => {
|
|
@@ -20,42 +20,33 @@ describe('auth configuration contract', () => {
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it('accepts IAM_ORIGIN as migration-only fallback', () => {
|
|
23
|
-
assert.equal(
|
|
24
|
-
resolveIamOrigin({ IAM_ORIGIN: 'https://legacy.example.test/' }),
|
|
25
|
-
'https://legacy.example.test',
|
|
26
|
-
);
|
|
23
|
+
assert.equal(resolveIamOrigin({ IAM_ORIGIN: 'https://legacy.example.test/' }), 'https://legacy.example.test');
|
|
27
24
|
});
|
|
28
25
|
|
|
29
26
|
it('defaults issuer when neither IAM_OAUTH_ISSUER nor IAM_ORIGIN exists', () => {
|
|
30
27
|
assert.equal(resolveIamOrigin({}), 'https://inneranimalmedia.com');
|
|
31
28
|
});
|
|
32
29
|
|
|
33
|
-
it('
|
|
34
|
-
assert.equal(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
AGENTSAM_SDK_TOKEN: 'sdk_old',
|
|
38
|
-
}),
|
|
39
|
-
'sdk_new',
|
|
40
|
-
);
|
|
41
|
-
assert.equal(resolveSdkKey({ AGENTSAM_SDK_TOKEN: 'sdk_old' }), 'sdk_old');
|
|
30
|
+
it('resolves only AGENTSAM_API_KEY for delegated account API auth', () => {
|
|
31
|
+
assert.equal(resolveApiKey({ AGENTSAM_API_KEY: 'aak_new' }), 'aak_new');
|
|
32
|
+
assert.equal(resolveApiKey({ AGENTSAM_SDK_KEY: 'sdk_old' }), '');
|
|
33
|
+
assert.equal(AGENTSAM_AUTH_CONTRACT.apiKey.durableStore, 'agentsam_api_credentials');
|
|
42
34
|
});
|
|
43
35
|
|
|
44
|
-
it('never aliases bridge machine trust to
|
|
36
|
+
it('never aliases bridge machine trust to an account API key', () => {
|
|
45
37
|
assert.equal(
|
|
46
|
-
resolveBridgeKey({ AGENTSAM_BRIDGE_KEY: 'bridge_machine',
|
|
38
|
+
resolveBridgeKey({ AGENTSAM_BRIDGE_KEY: 'bridge_machine', AGENTSAM_API_KEY: 'aak_user' }),
|
|
47
39
|
'bridge_machine',
|
|
48
40
|
);
|
|
49
|
-
assert.equal(resolveBridgeKey({
|
|
41
|
+
assert.equal(resolveBridgeKey({ AGENTSAM_API_KEY: 'aak_user' }), '');
|
|
50
42
|
assert.equal(AGENTSAM_AUTH_CONTRACT.bridge.userAuth, false);
|
|
51
|
-
assert.equal(AGENTSAM_AUTH_CONTRACT.bridge.sdkTokenType, 'integration');
|
|
52
43
|
});
|
|
53
44
|
|
|
54
|
-
it('builds Bearer authorization only for
|
|
55
|
-
assert.deepEqual(
|
|
45
|
+
it('builds Bearer authorization only for aak_ API keys', () => {
|
|
46
|
+
assert.deepEqual(buildApiAuthorizationHeaders('aak_abc', { Accept: 'application/json' }), {
|
|
56
47
|
Accept: 'application/json',
|
|
57
|
-
Authorization: 'Bearer
|
|
48
|
+
Authorization: 'Bearer aak_abc',
|
|
58
49
|
});
|
|
59
|
-
assert.throws(() =>
|
|
50
|
+
assert.throws(() => buildApiAuthorizationHeaders('bridge_machine'), /AGENTSAM_API_KEY_required/);
|
|
60
51
|
});
|
|
61
52
|
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# AgentSam Company Repository Graph v1
|
|
2
|
+
|
|
3
|
+
This protocol defines the portable vocabulary for company-wide repository identity, public contracts, dependency edges, and Merkle evidence. It does not make the SDK a global database.
|
|
4
|
+
|
|
5
|
+
## Authority split
|
|
6
|
+
|
|
7
|
+
- `agentsam-sdk` defines schemas, enums, builders, Merkle formats, and receipt semantics.
|
|
8
|
+
- The authenticated host owns `account_id` and persists the operational graph.
|
|
9
|
+
- `code_repositories` is the canonical repository registry.
|
|
10
|
+
- `agentsam_repository_contracts` records what a repository provides.
|
|
11
|
+
- `agentsam_repository_dependencies` records what a repository consumes and the policy attached to that edge.
|
|
12
|
+
- `agentsam_fs_merkle_snapshots` indexes exact repository states; full manifests may live in object storage.
|
|
13
|
+
- Deployment and deployment-health tables record whether a source state reached production and whether it remains healthy.
|
|
14
|
+
- MCP may expose graph queries; ExecOS may emit execution evidence. Neither becomes the ownership authority.
|
|
15
|
+
|
|
16
|
+
## Ownership law
|
|
17
|
+
|
|
18
|
+
Persisted company graph records use `account_id` as ownership SSOT. `tenant_id`, `workspace_id`, `user_id`, and `owner_user_id` are not part of this protocol.
|
|
19
|
+
|
|
20
|
+
Portable repository identity is deliberately different: a checked-in repository identity must not embed an account identifier. The host binds its stable `repository_id` to an authenticated `account_id` in the registry.
|
|
21
|
+
|
|
22
|
+
## Canonical repository identity
|
|
23
|
+
|
|
24
|
+
A Git remote is evidence, not authority. The SDK must not derive the canonical `repository_id` from `owner/repo`, a checkout path, a workspace, or a provider URL. Persistence callers provide the `repository_id` from the host registry.
|
|
25
|
+
|
|
26
|
+
## Graph levels
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
code_repositories
|
|
30
|
+
repository identity / company role
|
|
31
|
+
|
|
|
32
|
+
+-- agentsam_repository_contracts
|
|
33
|
+
| what this repository provides
|
|
34
|
+
|
|
|
35
|
+
+-- agentsam_repository_dependencies
|
|
36
|
+
what this repository consumes
|
|
37
|
+
|
|
|
38
|
+
+-- Merkle / AST / Git evidence
|
|
39
|
+
|
|
|
40
|
+
+-- deployments / deployment health
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`codebase_dep_edges` remains an intra-repository code graph. `agentsam_repository_dependencies` is a cross-repository company graph. They are not interchangeable.
|
|
44
|
+
|
|
45
|
+
## Contract records
|
|
46
|
+
|
|
47
|
+
Contract types are:
|
|
48
|
+
|
|
49
|
+
`api | schema | runtime | cli | event | receipt | package`
|
|
50
|
+
|
|
51
|
+
Statuses are:
|
|
52
|
+
|
|
53
|
+
`active | deprecated | retired`
|
|
54
|
+
|
|
55
|
+
A contract record carries a stable `contract_key`, explicit version, manifest path when one exists, and `contract_hash`. The hash is the semantic identity consumers can pin independently of a Git branch name.
|
|
56
|
+
|
|
57
|
+
## Dependency records
|
|
58
|
+
|
|
59
|
+
Dependency types are:
|
|
60
|
+
|
|
61
|
+
`runtime | build | contract | package | deploy | tool | data`
|
|
62
|
+
|
|
63
|
+
Criticality is:
|
|
64
|
+
|
|
65
|
+
`informational | compatible | strict | critical`
|
|
66
|
+
|
|
67
|
+
Failure policy is:
|
|
68
|
+
|
|
69
|
+
`warn | block_certification | block_deploy | degrade`
|
|
70
|
+
|
|
71
|
+
The dependency graph supplies the meaning a Merkle tree cannot infer by itself: who consumes a changed contract and what should happen if the requirement is violated.
|
|
72
|
+
|
|
73
|
+
## Merkle persistence v2
|
|
74
|
+
|
|
75
|
+
Company persistence uses:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
account_id + repository_id + snapshot_id
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Object keys are:
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
agentsam_fs_merkle_snapshots/<account_id>/<repository_id>/<snapshot_id>.json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The content root, metadata root, and policy hash remain separate authorities. A future contract/dependency aggregate root may be layered above these records without changing the content Merkle format.
|
|
88
|
+
|
|
89
|
+
## Certification
|
|
90
|
+
|
|
91
|
+
Version 1 intentionally does not require a separate certifications table. A host can derive an initial certification decision from repository identity, contract hashes, dependency requirements, Merkle roots, verification results, deployments, and deployment health. A persistent certification ledger can be added when there is a real need to preserve compatibility statements across an exact set of repository roots.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# AgentSam Merkle Persistence v1
|
|
2
2
|
|
|
3
|
+
> Superseded for current company persistence by `MERKLE_PERSISTENCE_V2.md`. V1 is retained only as the historical contract shipped before the account/repository hard cut.
|
|
4
|
+
|
|
3
5
|
Persistence is a host concern layered on top of the portable Merkle protocol. The SDK exposes the canonical table name, storage prefix, logical asset binding, storage-key helper, and portable SQL schema without owning a customer's database or cloud credentials.
|
|
4
6
|
|
|
5
7
|
## Authority split
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# AgentSam Merkle Persistence v2
|
|
2
|
+
|
|
3
|
+
Persistence is a host concern layered on top of the portable Merkle protocol. Version 2 hard-cuts persisted ownership to `account_id + repository_id` and removes user/workspace/tenant ownership aliases.
|
|
4
|
+
|
|
5
|
+
## Authority split
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
root_hash = filesystem/content authority
|
|
9
|
+
metadata_root = semantic/index authority
|
|
10
|
+
policy_hash = capture-scope authority
|
|
11
|
+
account_id = authenticated ownership authority
|
|
12
|
+
repository_id = canonical repository-registry identity
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
A checkout path, workspace, or user identity must never become `repository_id`. For registered Git repositories, the SDK may derive the canonical provider identity directly from the Git remote (for example `github:owner/repo`), matching the `code_repositories.id` convention; local repositories may fall back to the committed project manifest.
|
|
16
|
+
|
|
17
|
+
The optional searchable index table remains `agentsam_fs_merkle_snapshots`. Full manifests may be stored under the provider-neutral object prefix `agentsam_fs_merkle_snapshots/`.
|
|
18
|
+
|
|
19
|
+
Typical keys are:
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
agentsam_fs_merkle_snapshots/<account_id>/<repository_id>/<snapshot_id>.json
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The hosting application chooses physical storage and database bindings. The SDK never owns cloud credentials and never invents account or repository authority.
|
|
26
|
+
|
|
27
|
+
## CLI publication
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
agentsam login
|
|
31
|
+
agentsam merkle snapshot . --semantic --out .agentsam/merkle.json
|
|
32
|
+
agentsam merkle persist .agentsam/merkle.json \
|
|
33
|
+
--wrangler-config path/to/wrangler.toml \
|
|
34
|
+
--capture-kind deploy \
|
|
35
|
+
--deployment-id "$DEPLOYMENT_ID"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The CLI reads `account_id` from the authenticated local AgentSam session and resolves `repository_id` from Git/provider identity, with the committed project manifest as fallback for local repositories. Programmatic hosts still pass authenticated `account_id + repository_id` directly to `buildMerklePersistencePlan`. For non-deploy captures, execution provenance remains required through a connection or runtime lease. `--dry-run` emits the exact storage/index plan without writes; `--r2-only` uploads the manifest without a D1 index write.
|
|
39
|
+
|
|
40
|
+
Version 1 used `owner_user_id` / `repo_id` and is superseded for current company persistence.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.inneranimalmedia.com/agentsam/repository/repository-contract.schema.json",
|
|
4
|
+
"title": "AgentSam Repository Contract Record",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["schema_version", "id", "account_id", "repository_id", "contract_key", "contract_version", "contract_type", "name", "contract_hash", "status"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"schema_version": { "const": 1 },
|
|
10
|
+
"id": { "type": "string", "minLength": 1 },
|
|
11
|
+
"account_id": { "type": "string", "minLength": 1 },
|
|
12
|
+
"repository_id": { "type": "string", "minLength": 1 },
|
|
13
|
+
"contract_key": { "type": "string", "minLength": 1 },
|
|
14
|
+
"contract_version": { "type": "string", "minLength": 1 },
|
|
15
|
+
"contract_type": { "enum": ["api", "schema", "runtime", "cli", "event", "receipt", "package"] },
|
|
16
|
+
"name": { "type": "string", "minLength": 1 },
|
|
17
|
+
"description": { "type": ["string", "null"] },
|
|
18
|
+
"manifest_path": { "type": ["string", "null"] },
|
|
19
|
+
"contract_hash": { "type": "string", "minLength": 1 },
|
|
20
|
+
"status": { "enum": ["active", "deprecated", "retired"] },
|
|
21
|
+
"created_at": { "type": ["integer", "null"], "minimum": 0 },
|
|
22
|
+
"updated_at": { "type": ["integer", "null"], "minimum": 0 }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.inneranimalmedia.com/agentsam/repository/repository-dependency.schema.json",
|
|
4
|
+
"title": "AgentSam Repository Dependency Record",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["schema_version", "id", "account_id", "source_repository_id", "target_repository_id", "dependency_type", "criticality", "failure_policy"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"schema_version": { "const": 1 },
|
|
10
|
+
"id": { "type": "string", "minLength": 1 },
|
|
11
|
+
"account_id": { "type": "string", "minLength": 1 },
|
|
12
|
+
"source_repository_id": { "type": "string", "minLength": 1 },
|
|
13
|
+
"target_repository_id": { "type": "string", "minLength": 1 },
|
|
14
|
+
"dependency_type": { "enum": ["runtime", "build", "contract", "package", "deploy", "tool", "data"] },
|
|
15
|
+
"contract_id": { "type": ["string", "null"] },
|
|
16
|
+
"criticality": { "enum": ["informational", "compatible", "strict", "critical"] },
|
|
17
|
+
"required_version": { "type": ["string", "null"] },
|
|
18
|
+
"required_contract_hash": { "type": ["string", "null"] },
|
|
19
|
+
"failure_policy": { "enum": ["warn", "block_certification", "block_deploy", "degrade"] },
|
|
20
|
+
"description": { "type": ["string", "null"] },
|
|
21
|
+
"created_at": { "type": ["integer", "null"], "minimum": 0 },
|
|
22
|
+
"updated_at": { "type": ["integer", "null"], "minimum": 0 }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.inneranimalmedia.com/agentsam/repository/repository-identity.schema.json",
|
|
4
|
+
"title": "AgentSam Repository Identity",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["schema_version", "repository_id", "full_name", "role", "default_branch", "status"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"schema_version": { "const": 1 },
|
|
10
|
+
"repository_id": { "type": "string", "minLength": 1 },
|
|
11
|
+
"full_name": { "type": "string", "minLength": 1 },
|
|
12
|
+
"role": { "type": "string", "minLength": 1 },
|
|
13
|
+
"default_branch": { "type": "string", "minLength": 1 },
|
|
14
|
+
"canonical_url": { "type": ["string", "null"] },
|
|
15
|
+
"status": { "enum": ["active", "archived", "disabled"] }
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package agentsam.knowledge.v1;
|
|
4
|
+
|
|
5
|
+
// Numeric values intentionally match google.rpc.Code / gRPC canonical status codes.
|
|
6
|
+
enum ErrorCode {
|
|
7
|
+
ERROR_CODE_OK = 0;
|
|
8
|
+
ERROR_CODE_CANCELLED = 1;
|
|
9
|
+
ERROR_CODE_UNKNOWN = 2;
|
|
10
|
+
ERROR_CODE_INVALID_ARGUMENT = 3;
|
|
11
|
+
ERROR_CODE_DEADLINE_EXCEEDED = 4;
|
|
12
|
+
ERROR_CODE_NOT_FOUND = 5;
|
|
13
|
+
ERROR_CODE_ALREADY_EXISTS = 6;
|
|
14
|
+
ERROR_CODE_PERMISSION_DENIED = 7;
|
|
15
|
+
ERROR_CODE_RESOURCE_EXHAUSTED = 8;
|
|
16
|
+
ERROR_CODE_FAILED_PRECONDITION = 9;
|
|
17
|
+
ERROR_CODE_ABORTED = 10;
|
|
18
|
+
ERROR_CODE_OUT_OF_RANGE = 11;
|
|
19
|
+
ERROR_CODE_UNIMPLEMENTED = 12;
|
|
20
|
+
ERROR_CODE_INTERNAL = 13;
|
|
21
|
+
ERROR_CODE_UNAVAILABLE = 14;
|
|
22
|
+
ERROR_CODE_DATA_LOSS = 15;
|
|
23
|
+
ERROR_CODE_UNAUTHENTICATED = 16;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
message ErrorDetail {
|
|
27
|
+
ErrorCode code = 1;
|
|
28
|
+
string message = 2;
|
|
29
|
+
bool retryable = 3;
|
|
30
|
+
string reason = 4;
|
|
31
|
+
optional uint32 http_status = 5;
|
|
32
|
+
optional uint32 retry_after_ms = 6;
|
|
33
|
+
optional string provider = 7;
|
|
34
|
+
optional string provider_code = 8;
|
|
35
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package agentsam.knowledge.v1;
|
|
4
|
+
|
|
5
|
+
import "google/protobuf/timestamp.proto";
|
|
6
|
+
import "common.proto";
|
|
7
|
+
import "errors.proto";
|
|
8
|
+
|
|
9
|
+
service KnowledgeService {
|
|
10
|
+
rpc ListRepositories(ListRepositoriesRequest) returns (ListRepositoriesResponse);
|
|
11
|
+
rpc SubmitJob(SubmitJobRequest) returns (Job);
|
|
12
|
+
rpc GetJob(GetJobRequest) returns (Job);
|
|
13
|
+
rpc WatchJob(WatchJobRequest) returns (stream JobEvent);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
message ListRepositoriesRequest {}
|
|
17
|
+
|
|
18
|
+
message ListRepositoriesResponse {
|
|
19
|
+
repeated RepositoryRef repositories = 1;
|
|
20
|
+
bool embeddings_enabled = 2;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
enum JobOperation {
|
|
24
|
+
JOB_OPERATION_UNSPECIFIED = 0;
|
|
25
|
+
JOB_OPERATION_INDEX = 1;
|
|
26
|
+
JOB_OPERATION_PLAN = 2;
|
|
27
|
+
JOB_OPERATION_SEARCH = 3;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
enum JobStatus {
|
|
31
|
+
JOB_STATUS_UNSPECIFIED = 0;
|
|
32
|
+
JOB_STATUS_QUEUED = 1;
|
|
33
|
+
JOB_STATUS_RUNNING = 2;
|
|
34
|
+
JOB_STATUS_COMPLETED = 3;
|
|
35
|
+
JOB_STATUS_FAILED = 4;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
message SubmitJobRequest {
|
|
39
|
+
string repository = 1;
|
|
40
|
+
JobOperation operation = 2;
|
|
41
|
+
optional string scope = 3;
|
|
42
|
+
StringList include = 4;
|
|
43
|
+
StringList exclude = 5;
|
|
44
|
+
optional bool embed = 6;
|
|
45
|
+
optional bool semantic = 7;
|
|
46
|
+
optional string query = 8;
|
|
47
|
+
optional uint32 top_k = 9;
|
|
48
|
+
optional uint32 token_budget = 10;
|
|
49
|
+
optional string generation_id = 11;
|
|
50
|
+
optional uint32 max_inputs = 12;
|
|
51
|
+
optional uint32 max_characters = 13;
|
|
52
|
+
optional string idempotency_key = 14;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
message GetJobRequest {
|
|
56
|
+
JobId job_id = 1;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
message WatchJobRequest {
|
|
60
|
+
JobId job_id = 1;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
message Job {
|
|
64
|
+
JobId id = 1;
|
|
65
|
+
JobStatus status = 2;
|
|
66
|
+
uint32 attempts = 3;
|
|
67
|
+
google.protobuf.Timestamp created_at = 4;
|
|
68
|
+
google.protobuf.Timestamp updated_at = 5;
|
|
69
|
+
string result_json = 6;
|
|
70
|
+
ErrorDetail failure = 7;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
message JobEvent {
|
|
74
|
+
Job job = 1;
|
|
75
|
+
google.protobuf.Timestamp observed_at = 2;
|
|
76
|
+
uint64 sequence = 3;
|
|
77
|
+
}
|