@inneranimalmedia/agentsam-sdk 2.1.0 → 2.2.1
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/README.md +27 -15
- package/docs/CAPABILITIES.md +93 -0
- package/docs/CLI_SHELL.md +10 -1
- package/docs/RELEASES.md +2 -1
- package/docs/portable-knowledge.md +4 -4
- package/package.json +7 -1
- package/packages/identity/package.json +1 -1
- package/packages/identity/src/frontend/auth-portal/README.md +1 -1
- package/packages/identity/src/index.js +2 -0
- package/protocol/capabilities/capability-manifest.schema.json +36 -0
- package/protocol/capabilities/manifest.json +179 -0
- package/protocol/capabilities/repository-audit-input.schema.json +14 -0
- package/protocol/capabilities/repository-audit.schema.json +30 -0
- package/protocol/capabilities/repository-snapshot-input.schema.json +11 -0
- package/protocol/capabilities/repository-snapshot.schema.json +20 -0
- package/protocol/knowledge/chunk.schema.json +15 -73
- package/protocol/knowledge/document.schema.json +10 -48
- package/protocol/knowledge/index-config.schema.json +2 -2
- package/protocol/knowledge/repository.schema.json +11 -52
- package/protocol/knowledge/retrieval-query.schema.json +13 -63
- package/protocol/knowledge/source.schema.json +9 -43
- package/protocol/presets/catalog.json +48 -0
- package/python/agentsam_sdk/knowledge/models.py +19 -7
- package/python/agentsam_sdk/repository/__main__.py +2 -2
- package/python/tests/test_knowledge_models.py +6 -2
- package/src/agent/capability-adapter.js +50 -0
- package/src/agent/index.js +2 -0
- package/src/agent/repository-audit.js +188 -0
- package/src/capabilities/index.js +7 -0
- package/src/capabilities/manifest.js +22 -0
- package/src/capabilities/repository-snapshot.js +180 -0
- package/src/cli.js +56 -39
- package/src/commands/deploy.js +0 -1
- package/src/commands/knowledge.js +5 -6
- package/src/commands/product.js +119 -0
- package/src/commands/shell.js +253 -0
- package/src/index.js +9 -0
- package/src/knowledge/config.js +12 -6
- package/src/knowledge/contracts.js +1 -1
- package/src/knowledge/engine.js +1 -1
- package/src/knowledge/service/server.js +2 -2
- package/src/lib/git-context.js +3 -1
- package/src/lib/slash-commands.js +2 -1
- package/src/presets/index.js +20 -0
- package/src/repository/index.js +4 -0
- package/test/agent-capabilities.test.mjs +67 -0
- package/test/capabilities.test.mjs +84 -0
- package/test/portable-context.test.mjs +11 -1
- package/test/shell.test.mjs +60 -0
- package/test/smoke.mjs +2 -2
|
@@ -4,79 +4,21 @@
|
|
|
4
4
|
"type": "object",
|
|
5
5
|
"additionalProperties": false,
|
|
6
6
|
"title": "Chunk",
|
|
7
|
-
"required": [
|
|
8
|
-
"chunk_id",
|
|
9
|
-
"document_id",
|
|
10
|
-
"workspace_id",
|
|
11
|
-
"content",
|
|
12
|
-
"ordinal",
|
|
13
|
-
"content_hash"
|
|
14
|
-
],
|
|
7
|
+
"required": ["chunk_id", "document_id", "content", "ordinal", "content_hash"],
|
|
15
8
|
"properties": {
|
|
16
|
-
"chunk_id": {
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
"minimum": 0
|
|
31
|
-
},
|
|
32
|
-
"content_hash": {
|
|
33
|
-
"type": "string"
|
|
34
|
-
},
|
|
35
|
-
"token_count": {
|
|
36
|
-
"type": [
|
|
37
|
-
"integer",
|
|
38
|
-
"null"
|
|
39
|
-
],
|
|
40
|
-
"minimum": 0
|
|
41
|
-
},
|
|
42
|
-
"repository_full_name": {
|
|
43
|
-
"type": [
|
|
44
|
-
"string",
|
|
45
|
-
"null"
|
|
46
|
-
]
|
|
47
|
-
},
|
|
48
|
-
"ref": {
|
|
49
|
-
"type": [
|
|
50
|
-
"string",
|
|
51
|
-
"null"
|
|
52
|
-
]
|
|
53
|
-
},
|
|
54
|
-
"commit_sha": {
|
|
55
|
-
"type": [
|
|
56
|
-
"string",
|
|
57
|
-
"null"
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
|
-
"path": {
|
|
61
|
-
"type": [
|
|
62
|
-
"string",
|
|
63
|
-
"null"
|
|
64
|
-
]
|
|
65
|
-
},
|
|
66
|
-
"symbol": {
|
|
67
|
-
"type": [
|
|
68
|
-
"string",
|
|
69
|
-
"null"
|
|
70
|
-
]
|
|
71
|
-
},
|
|
72
|
-
"heading_path": {
|
|
73
|
-
"type": "array",
|
|
74
|
-
"items": {
|
|
75
|
-
"type": "string"
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
"metadata": {
|
|
79
|
-
"type": "object"
|
|
80
|
-
}
|
|
9
|
+
"chunk_id": { "type": "string" },
|
|
10
|
+
"document_id": { "type": "string" },
|
|
11
|
+
"workspace_id": { "type": "string", "deprecated": true, "description": "Legacy compatibility metadata only." },
|
|
12
|
+
"content": { "type": "string" },
|
|
13
|
+
"ordinal": { "type": "integer", "minimum": 0 },
|
|
14
|
+
"content_hash": { "type": "string" },
|
|
15
|
+
"token_count": { "type": ["integer", "null"], "minimum": 0 },
|
|
16
|
+
"repository_full_name": { "type": ["string", "null"] },
|
|
17
|
+
"ref": { "type": ["string", "null"] },
|
|
18
|
+
"commit_sha": { "type": ["string", "null"] },
|
|
19
|
+
"path": { "type": ["string", "null"] },
|
|
20
|
+
"symbol": { "type": ["string", "null"] },
|
|
21
|
+
"heading_path": { "type": "array", "items": { "type": "string" } },
|
|
22
|
+
"metadata": { "type": "object" }
|
|
81
23
|
}
|
|
82
24
|
}
|
|
@@ -4,54 +4,16 @@
|
|
|
4
4
|
"type": "object",
|
|
5
5
|
"additionalProperties": false,
|
|
6
6
|
"title": "Document",
|
|
7
|
-
"required": [
|
|
8
|
-
"document_id",
|
|
9
|
-
"source_id",
|
|
10
|
-
"workspace_id",
|
|
11
|
-
"content_hash",
|
|
12
|
-
"media_type"
|
|
13
|
-
],
|
|
7
|
+
"required": ["document_id", "source_id", "content_hash", "media_type"],
|
|
14
8
|
"properties": {
|
|
15
|
-
"document_id": {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
"
|
|
24
|
-
"type": "string",
|
|
25
|
-
"minLength": 1
|
|
26
|
-
},
|
|
27
|
-
"content_hash": {
|
|
28
|
-
"type": "string",
|
|
29
|
-
"minLength": 1
|
|
30
|
-
},
|
|
31
|
-
"media_type": {
|
|
32
|
-
"type": "string",
|
|
33
|
-
"minLength": 1
|
|
34
|
-
},
|
|
35
|
-
"title": {
|
|
36
|
-
"type": [
|
|
37
|
-
"string",
|
|
38
|
-
"null"
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
"path": {
|
|
42
|
-
"type": [
|
|
43
|
-
"string",
|
|
44
|
-
"null"
|
|
45
|
-
]
|
|
46
|
-
},
|
|
47
|
-
"text": {
|
|
48
|
-
"type": [
|
|
49
|
-
"string",
|
|
50
|
-
"null"
|
|
51
|
-
]
|
|
52
|
-
},
|
|
53
|
-
"metadata": {
|
|
54
|
-
"type": "object"
|
|
55
|
-
}
|
|
9
|
+
"document_id": { "type": "string", "minLength": 1 },
|
|
10
|
+
"source_id": { "type": "string", "minLength": 1 },
|
|
11
|
+
"workspace_id": { "type": "string", "minLength": 1, "deprecated": true, "description": "Legacy compatibility metadata only." },
|
|
12
|
+
"content_hash": { "type": "string", "minLength": 1 },
|
|
13
|
+
"media_type": { "type": "string", "minLength": 1 },
|
|
14
|
+
"title": { "type": ["string", "null"] },
|
|
15
|
+
"path": { "type": ["string", "null"] },
|
|
16
|
+
"text": { "type": ["string", "null"] },
|
|
17
|
+
"metadata": { "type": "object" }
|
|
56
18
|
}
|
|
57
19
|
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"title": "Portable index configuration v1",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"additionalProperties": false,
|
|
7
|
-
"required": ["version", "repository_id", "
|
|
7
|
+
"required": ["version", "repository_id", "scope", "chunking", "embedding", "storage"],
|
|
8
8
|
"properties": {
|
|
9
9
|
"version": { "const": 1 },
|
|
10
10
|
"repository_id": { "type": "string", "minLength": 1 },
|
|
11
|
-
"workspace_id": { "type": "string", "minLength": 1 },
|
|
11
|
+
"workspace_id": { "type": "string", "minLength": 1, "deprecated": true, "description": "Legacy compatibility metadata. New portable configs are repository-scoped and must not require this field." },
|
|
12
12
|
"scope": {
|
|
13
13
|
"type": "object", "additionalProperties": false, "required": ["name", "include"],
|
|
14
14
|
"properties": {
|
|
@@ -4,58 +4,17 @@
|
|
|
4
4
|
"type": "object",
|
|
5
5
|
"additionalProperties": false,
|
|
6
6
|
"title": "RepositoryDescriptor",
|
|
7
|
-
"required": [
|
|
8
|
-
"repository_id",
|
|
9
|
-
"full_name",
|
|
10
|
-
"workspace_id",
|
|
11
|
-
"default_branch"
|
|
12
|
-
],
|
|
7
|
+
"required": ["repository_id", "full_name", "default_branch"],
|
|
13
8
|
"properties": {
|
|
14
|
-
"repository_id": {
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
"default_branch": {
|
|
25
|
-
"type": "string"
|
|
26
|
-
},
|
|
27
|
-
"product_ids": {
|
|
28
|
-
"type": "array",
|
|
29
|
-
"items": {
|
|
30
|
-
"type": "string"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"indexed_refs": {
|
|
34
|
-
"type": "array",
|
|
35
|
-
"items": {
|
|
36
|
-
"type": "string"
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"enabled_lanes": {
|
|
40
|
-
"type": "array",
|
|
41
|
-
"items": {
|
|
42
|
-
"type": "string"
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
"include": {
|
|
46
|
-
"type": "array",
|
|
47
|
-
"items": {
|
|
48
|
-
"type": "string"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"exclude": {
|
|
52
|
-
"type": "array",
|
|
53
|
-
"items": {
|
|
54
|
-
"type": "string"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"metadata": {
|
|
58
|
-
"type": "object"
|
|
59
|
-
}
|
|
9
|
+
"repository_id": { "type": "string" },
|
|
10
|
+
"full_name": { "type": "string", "pattern": "^[^/]+/[^/]+$" },
|
|
11
|
+
"workspace_id": { "type": "string", "deprecated": true, "description": "Legacy compatibility metadata only." },
|
|
12
|
+
"default_branch": { "type": "string" },
|
|
13
|
+
"product_ids": { "type": "array", "items": { "type": "string" } },
|
|
14
|
+
"indexed_refs": { "type": "array", "items": { "type": "string" } },
|
|
15
|
+
"enabled_lanes": { "type": "array", "items": { "type": "string" } },
|
|
16
|
+
"include": { "type": "array", "items": { "type": "string" } },
|
|
17
|
+
"exclude": { "type": "array", "items": { "type": "string" } },
|
|
18
|
+
"metadata": { "type": "object" }
|
|
60
19
|
}
|
|
61
20
|
}
|
|
@@ -4,69 +4,19 @@
|
|
|
4
4
|
"type": "object",
|
|
5
5
|
"additionalProperties": false,
|
|
6
6
|
"title": "RetrievalQuery",
|
|
7
|
-
"required": [
|
|
8
|
-
"text",
|
|
9
|
-
"workspace_id"
|
|
10
|
-
],
|
|
7
|
+
"required": ["text"],
|
|
11
8
|
"properties": {
|
|
12
|
-
"text": {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"product_ids": {
|
|
27
|
-
"type": "array",
|
|
28
|
-
"items": {
|
|
29
|
-
"type": "string"
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"refs": {
|
|
33
|
-
"type": "array",
|
|
34
|
-
"items": {
|
|
35
|
-
"type": "string"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"intent": {
|
|
39
|
-
"type": "string",
|
|
40
|
-
"default": "auto"
|
|
41
|
-
},
|
|
42
|
-
"lanes": {
|
|
43
|
-
"type": "array",
|
|
44
|
-
"items": {
|
|
45
|
-
"type": "string"
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"top_k": {
|
|
49
|
-
"type": "integer",
|
|
50
|
-
"minimum": 1,
|
|
51
|
-
"maximum": 100,
|
|
52
|
-
"default": 12
|
|
53
|
-
},
|
|
54
|
-
"token_budget": {
|
|
55
|
-
"type": "integer",
|
|
56
|
-
"minimum": 256,
|
|
57
|
-
"default": 8000
|
|
58
|
-
},
|
|
59
|
-
"require_current_ref": {
|
|
60
|
-
"type": "boolean",
|
|
61
|
-
"default": true
|
|
62
|
-
},
|
|
63
|
-
"include_archived": {
|
|
64
|
-
"type": "boolean",
|
|
65
|
-
"default": false
|
|
66
|
-
},
|
|
67
|
-
"explain": {
|
|
68
|
-
"type": "boolean",
|
|
69
|
-
"default": true
|
|
70
|
-
}
|
|
9
|
+
"text": { "type": "string", "minLength": 1 },
|
|
10
|
+
"workspace_id": { "type": "string", "minLength": 1, "deprecated": true, "description": "Legacy compatibility metadata only; repository selection is explicit through repository identity." },
|
|
11
|
+
"repositories": { "type": "array", "items": { "type": "string" } },
|
|
12
|
+
"product_ids": { "type": "array", "items": { "type": "string" } },
|
|
13
|
+
"refs": { "type": "array", "items": { "type": "string" } },
|
|
14
|
+
"intent": { "type": "string", "default": "auto" },
|
|
15
|
+
"lanes": { "type": "array", "items": { "type": "string" } },
|
|
16
|
+
"top_k": { "type": "integer", "minimum": 1, "maximum": 100, "default": 12 },
|
|
17
|
+
"token_budget": { "type": "integer", "minimum": 256, "default": 8000 },
|
|
18
|
+
"require_current_ref": { "type": "boolean", "default": true },
|
|
19
|
+
"include_archived": { "type": "boolean", "default": false },
|
|
20
|
+
"explain": { "type": "boolean", "default": true }
|
|
71
21
|
}
|
|
72
22
|
}
|
|
@@ -4,49 +4,15 @@
|
|
|
4
4
|
"type": "object",
|
|
5
5
|
"additionalProperties": false,
|
|
6
6
|
"title": "Source",
|
|
7
|
-
"required": [
|
|
8
|
-
"source_id",
|
|
9
|
-
"source_type",
|
|
10
|
-
"workspace_id",
|
|
11
|
-
"uri"
|
|
12
|
-
],
|
|
7
|
+
"required": ["source_id", "source_type", "uri"],
|
|
13
8
|
"properties": {
|
|
14
|
-
"source_id": {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
"workspace_id": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"minLength": 1
|
|
25
|
-
},
|
|
26
|
-
"uri": {
|
|
27
|
-
"type": "string",
|
|
28
|
-
"minLength": 1
|
|
29
|
-
},
|
|
30
|
-
"repository_full_name": {
|
|
31
|
-
"type": [
|
|
32
|
-
"string",
|
|
33
|
-
"null"
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
"ref": {
|
|
37
|
-
"type": [
|
|
38
|
-
"string",
|
|
39
|
-
"null"
|
|
40
|
-
]
|
|
41
|
-
},
|
|
42
|
-
"commit_sha": {
|
|
43
|
-
"type": [
|
|
44
|
-
"string",
|
|
45
|
-
"null"
|
|
46
|
-
]
|
|
47
|
-
},
|
|
48
|
-
"metadata": {
|
|
49
|
-
"type": "object"
|
|
50
|
-
}
|
|
9
|
+
"source_id": { "type": "string", "minLength": 1 },
|
|
10
|
+
"source_type": { "type": "string", "minLength": 1 },
|
|
11
|
+
"workspace_id": { "type": "string", "minLength": 1, "deprecated": true, "description": "Legacy compatibility metadata only." },
|
|
12
|
+
"uri": { "type": "string", "minLength": 1 },
|
|
13
|
+
"repository_full_name": { "type": ["string", "null"] },
|
|
14
|
+
"ref": { "type": ["string", "null"] },
|
|
15
|
+
"commit_sha": { "type": ["string", "null"] },
|
|
16
|
+
"metadata": { "type": "object" }
|
|
51
17
|
}
|
|
52
18
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": 1,
|
|
3
|
+
"presets": {
|
|
4
|
+
"fullstack": {
|
|
5
|
+
"id": "fullstack",
|
|
6
|
+
"version": 1,
|
|
7
|
+
"lane": "fullstack",
|
|
8
|
+
"description": "Local-first application with AgentSam runtime, repository primitives, knowledge, and delivery hooks.",
|
|
9
|
+
"features": ["agent", "knowledge"],
|
|
10
|
+
"capabilities": ["scaffold.create", "repository.snapshot", "knowledge.index", "knowledge.search", "security.scan", "deploy.receipt"],
|
|
11
|
+
"defaults": { "database": "sqlite", "assets": "local", "deploy": "local" }
|
|
12
|
+
},
|
|
13
|
+
"cms": {
|
|
14
|
+
"id": "cms",
|
|
15
|
+
"version": 1,
|
|
16
|
+
"lane": "cms",
|
|
17
|
+
"description": "Content-oriented application starting from local CMS primitives with explicit auth/deploy opt-ins.",
|
|
18
|
+
"features": ["cms", "knowledge"],
|
|
19
|
+
"capabilities": ["scaffold.create", "repository.snapshot", "knowledge.index", "knowledge.search", "site.scrape", "deploy.receipt"],
|
|
20
|
+
"defaults": { "database": "sqlite", "assets": "local", "deploy": "local" }
|
|
21
|
+
},
|
|
22
|
+
"prototype": {
|
|
23
|
+
"id": "prototype",
|
|
24
|
+
"version": 1,
|
|
25
|
+
"lane": "fullstack",
|
|
26
|
+
"description": "Small local prototype with the minimum deterministic AgentSam runtime.",
|
|
27
|
+
"features": ["agent"],
|
|
28
|
+
"capabilities": ["scaffold.create", "repository.snapshot", "security.scan"],
|
|
29
|
+
"defaults": { "database": "sqlite", "assets": "local", "deploy": "local" }
|
|
30
|
+
},
|
|
31
|
+
"data": {
|
|
32
|
+
"id": "data",
|
|
33
|
+
"version": 1,
|
|
34
|
+
"lane": "data",
|
|
35
|
+
"description": "Data-oriented local application with repository knowledge and explicit production storage graduation.",
|
|
36
|
+
"features": ["knowledge"],
|
|
37
|
+
"capabilities": ["scaffold.create", "repository.snapshot", "knowledge.index", "knowledge.search", "security.scan"],
|
|
38
|
+
"defaults": { "database": "sqlite", "assets": "local", "deploy": "local" }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"addons": {
|
|
42
|
+
"agent": { "id": "agent", "capabilities": ["scaffold.create"], "description": "AgentSam local runtime selection." },
|
|
43
|
+
"auth": { "id": "auth", "capabilities": ["identity.init"], "description": "Identity package selection; use `agentsam identity init` when a standalone auth app scaffold is required." },
|
|
44
|
+
"cms": { "id": "cms", "capabilities": ["site.scrape"], "description": "CMS/content feature selection." },
|
|
45
|
+
"knowledge": { "id": "knowledge", "capabilities": ["knowledge.index", "knowledge.search"], "description": "Portable repository indexing and retrieval." },
|
|
46
|
+
"deploy-cloudflare": { "id": "deploy-cloudflare", "capabilities": ["deploy.receipt"], "description": "Select Cloudflare as the intended deploy target; provisioning remains explicit at deploy time." }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,40 +1,46 @@
|
|
|
1
|
-
"""Provider-neutral contracts for indexing and retrieval.
|
|
1
|
+
"""Provider-neutral contracts for indexing and retrieval.
|
|
2
|
+
|
|
3
|
+
Portable knowledge is repository-scoped. ``workspace_id`` remains optional compatibility
|
|
4
|
+
metadata only; it is never required to identify repository knowledge.
|
|
5
|
+
"""
|
|
2
6
|
|
|
3
7
|
from __future__ import annotations
|
|
4
8
|
|
|
5
9
|
from dataclasses import dataclass, field
|
|
6
|
-
from typing import Any, Mapping
|
|
10
|
+
from typing import Any, Mapping
|
|
7
11
|
|
|
8
12
|
JsonMap = Mapping[str, Any]
|
|
9
13
|
|
|
14
|
+
|
|
10
15
|
@dataclass(frozen=True, slots=True)
|
|
11
16
|
class Source:
|
|
12
17
|
source_id: str
|
|
13
18
|
source_type: str
|
|
14
|
-
workspace_id: str
|
|
15
19
|
uri: str
|
|
16
20
|
repository_full_name: str | None = None
|
|
17
21
|
ref: str | None = None
|
|
18
22
|
commit_sha: str | None = None
|
|
23
|
+
workspace_id: str | None = None
|
|
19
24
|
metadata: JsonMap = field(default_factory=dict)
|
|
20
25
|
|
|
26
|
+
|
|
21
27
|
@dataclass(frozen=True, slots=True)
|
|
22
28
|
class Document:
|
|
23
29
|
document_id: str
|
|
24
30
|
source_id: str
|
|
25
|
-
workspace_id: str
|
|
26
31
|
content_hash: str
|
|
27
32
|
media_type: str
|
|
28
33
|
title: str | None = None
|
|
29
34
|
path: str | None = None
|
|
30
35
|
text: str | None = None
|
|
36
|
+
workspace_id: str | None = None
|
|
31
37
|
metadata: JsonMap = field(default_factory=dict)
|
|
32
38
|
|
|
39
|
+
|
|
33
40
|
@dataclass(frozen=True, slots=True)
|
|
34
41
|
class Chunk:
|
|
35
42
|
chunk_id: str
|
|
36
43
|
document_id: str
|
|
37
|
-
workspace_id: str
|
|
38
44
|
content: str
|
|
39
45
|
ordinal: int
|
|
40
46
|
content_hash: str
|
|
@@ -45,25 +51,27 @@ class Chunk:
|
|
|
45
51
|
path: str | None = None
|
|
46
52
|
symbol: str | None = None
|
|
47
53
|
heading_path: tuple[str, ...] = ()
|
|
54
|
+
workspace_id: str | None = None
|
|
48
55
|
metadata: JsonMap = field(default_factory=dict)
|
|
49
56
|
|
|
57
|
+
|
|
50
58
|
@dataclass(frozen=True, slots=True)
|
|
51
59
|
class RepositoryDescriptor:
|
|
52
60
|
repository_id: str
|
|
53
61
|
full_name: str
|
|
54
|
-
workspace_id: str
|
|
55
62
|
default_branch: str
|
|
56
63
|
product_ids: tuple[str, ...] = ()
|
|
57
64
|
indexed_refs: tuple[str, ...] = ()
|
|
58
65
|
enabled_lanes: tuple[str, ...] = ("code", "docs")
|
|
59
66
|
include: tuple[str, ...] = ()
|
|
60
67
|
exclude: tuple[str, ...] = ()
|
|
68
|
+
workspace_id: str | None = None
|
|
61
69
|
metadata: JsonMap = field(default_factory=dict)
|
|
62
70
|
|
|
71
|
+
|
|
63
72
|
@dataclass(frozen=True, slots=True)
|
|
64
73
|
class RetrievalQuery:
|
|
65
74
|
text: str
|
|
66
|
-
workspace_id: str
|
|
67
75
|
repositories: tuple[str, ...] = ()
|
|
68
76
|
product_ids: tuple[str, ...] = ()
|
|
69
77
|
refs: tuple[str, ...] = ()
|
|
@@ -74,6 +82,8 @@ class RetrievalQuery:
|
|
|
74
82
|
require_current_ref: bool = True
|
|
75
83
|
include_archived: bool = False
|
|
76
84
|
explain: bool = True
|
|
85
|
+
workspace_id: str | None = None
|
|
86
|
+
|
|
77
87
|
|
|
78
88
|
@dataclass(frozen=True, slots=True)
|
|
79
89
|
class RetrievalHit:
|
|
@@ -92,6 +102,7 @@ class RetrievalHit:
|
|
|
92
102
|
stale: bool = False
|
|
93
103
|
metadata: JsonMap = field(default_factory=dict)
|
|
94
104
|
|
|
105
|
+
|
|
95
106
|
@dataclass(frozen=True, slots=True)
|
|
96
107
|
class ContextPack:
|
|
97
108
|
query_id: str
|
|
@@ -101,6 +112,7 @@ class ContextPack:
|
|
|
101
112
|
confidence: str = "unknown"
|
|
102
113
|
diagnostics: JsonMap = field(default_factory=dict)
|
|
103
114
|
|
|
115
|
+
|
|
104
116
|
@dataclass(frozen=True, slots=True)
|
|
105
117
|
class IngestReceipt:
|
|
106
118
|
run_id: str
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from agentsam_sdk.repository.
|
|
1
|
+
from agentsam_sdk.repository.intelligence.cli import main_cli
|
|
2
2
|
|
|
3
|
-
raise SystemExit(
|
|
3
|
+
raise SystemExit(main_cli())
|
|
@@ -12,10 +12,14 @@ class KnowledgeContractsTest(unittest.TestCase):
|
|
|
12
12
|
return {"run_id": "run", "source_id": payload["source_id"], "status": "succeeded"}
|
|
13
13
|
return {"query_id": "query", "hits": [{"chunk_id": "chunk", "content": "code", "score": 1, "lane": "code"}]}
|
|
14
14
|
client = KnowledgeClient(Transport())
|
|
15
|
-
query = RetrievalQuery(text="function"
|
|
15
|
+
query = RetrievalQuery(text="function")
|
|
16
16
|
self.assertEqual(asyncio.run(client.retrieve(query)).hits[0].content, "code")
|
|
17
17
|
self.assertEqual(asyncio.run(client.index("source")).status, "succeeded")
|
|
18
|
-
self.assertEqual(Source("s", "repository", "
|
|
18
|
+
self.assertEqual(Source("s", "repository", "file:///repo").source_id, "s")
|
|
19
|
+
|
|
20
|
+
def test_workspace_is_optional_compatibility_metadata(self):
|
|
21
|
+
query = RetrievalQuery(text="function", workspace_id="legacy-workspace")
|
|
22
|
+
self.assertEqual(query.workspace_id, "legacy-workspace")
|
|
19
23
|
|
|
20
24
|
|
|
21
25
|
if __name__ == "__main__":
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getCapability, listCapabilities } from '../capabilities/manifest.js';
|
|
2
|
+
import { repositorySnapshot } from '../capabilities/repository-snapshot.js';
|
|
3
|
+
import { runRepositoryAudit } from './repository-audit.js';
|
|
4
|
+
|
|
5
|
+
export function createCapabilityAdapter({ handlers = {}, reasoner } = {}) {
|
|
6
|
+
const executable = new Map([
|
|
7
|
+
['repository.snapshot', (input) => repositorySnapshot(input)],
|
|
8
|
+
...Object.entries(handlers),
|
|
9
|
+
]);
|
|
10
|
+
if (typeof reasoner === 'function') {
|
|
11
|
+
executable.set('repository.audit', (input = {}) => runRepositoryAudit({ ...input, reasoner }));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function describe(id) {
|
|
15
|
+
const capability = getCapability(id);
|
|
16
|
+
if (!capability) throw new Error(`unknown_capability:${id}`);
|
|
17
|
+
return capability;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return Object.freeze({
|
|
21
|
+
list(options = {}) {
|
|
22
|
+
return listCapabilities(options);
|
|
23
|
+
},
|
|
24
|
+
describe,
|
|
25
|
+
toolDescriptors({ domain, kind, includeUnavailable = false } = {}) {
|
|
26
|
+
return listCapabilities({ domain, kind }).filter((row) => includeUnavailable || executable.has(row.id)).map((row) => ({
|
|
27
|
+
name: row.id,
|
|
28
|
+
description: row.description,
|
|
29
|
+
input_schema: row.input_schema || null,
|
|
30
|
+
side_effects: row.side_effects,
|
|
31
|
+
deterministic: row.deterministic,
|
|
32
|
+
model_required: row.model_required,
|
|
33
|
+
}));
|
|
34
|
+
},
|
|
35
|
+
canInvoke(id) {
|
|
36
|
+
return executable.has(String(id || '').trim());
|
|
37
|
+
},
|
|
38
|
+
async invoke(id, input = {}) {
|
|
39
|
+
const capability = describe(id);
|
|
40
|
+
const handler = executable.get(capability.id);
|
|
41
|
+
if (!handler) throw new Error(`capability_handler_unavailable:${capability.id}`);
|
|
42
|
+
const value = await handler(input);
|
|
43
|
+
return {
|
|
44
|
+
capability_id: capability.id,
|
|
45
|
+
capability_version: capability.version,
|
|
46
|
+
result: value,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|