@asm-agent/contracts 0.8.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.
@@ -0,0 +1,137 @@
1
+ import { Type } from "typebox";
2
+ export const ASM_CONTRACT_NAMESPACE = "ai.aletheion.asm";
3
+ export const ASM_CONTRACT_MAJOR = 1;
4
+ export const ASM_CONTRACT_MINOR = 1;
5
+ const Id = Type.String({ minLength: 1, maxLength: 200 });
6
+ const Timestamp = Type.String({ format: "date-time" });
7
+ const JsonObject = Type.Record(Type.String(), Type.Unknown());
8
+ const Score = Type.Number({ minimum: 0, maximum: 1 });
9
+ const Header = Type.Object({
10
+ namespace: Type.Literal(ASM_CONTRACT_NAMESPACE),
11
+ major: Type.Literal(ASM_CONTRACT_MAJOR),
12
+ minor: Type.Integer({ minimum: 0 }),
13
+ }, { additionalProperties: false });
14
+ export const MemoryContractSchema = Type.Object({
15
+ header: Header,
16
+ memoryId: Id,
17
+ revision: Type.Integer({ minimum: 1 }),
18
+ ownerId: Id,
19
+ projectId: Id,
20
+ sessionId: Type.Optional(Id),
21
+ kind: Type.Union([Type.Literal("observation"), Type.Literal("fact"), Type.Literal("instruction")]),
22
+ content: Type.String({ minLength: 1 }),
23
+ evidenceIds: Type.Array(Id, { uniqueItems: true }),
24
+ createdAt: Timestamp,
25
+ tombstonedAt: Type.Optional(Timestamp),
26
+ metadata: Type.Optional(JsonObject),
27
+ }, { additionalProperties: false, $id: "asm-memory-v1" });
28
+ export const EvidenceContractSchema = Type.Object({
29
+ header: Header,
30
+ evidenceId: Id,
31
+ ownerId: Id,
32
+ projectId: Id,
33
+ sourceType: Type.Union([
34
+ Type.Literal("user"),
35
+ Type.Literal("tool"),
36
+ Type.Literal("document"),
37
+ Type.Literal("system"),
38
+ ]),
39
+ sourceUri: Type.Optional(Type.String({ maxLength: 4096 })),
40
+ digest: Type.String({ pattern: "^[a-f0-9]{64}$" }),
41
+ capturedAt: Timestamp,
42
+ contentType: Type.String({ minLength: 1 }),
43
+ metadata: Type.Optional(JsonObject),
44
+ }, { additionalProperties: false, $id: "asm-evidence-v1" });
45
+ export const RetrievalContractSchema = Type.Object({
46
+ header: Header,
47
+ requestId: Id,
48
+ ownerId: Id,
49
+ projectId: Id,
50
+ sessionId: Type.Optional(Id),
51
+ query: Type.String({ minLength: 1 }),
52
+ limit: Type.Integer({ minimum: 1, maximum: 200 }),
53
+ algorithm: Id,
54
+ candidates: Type.Array(Type.Object({
55
+ memoryId: Id,
56
+ score: Score,
57
+ selected: Type.Boolean(),
58
+ reasonCodes: Type.Array(Id, { uniqueItems: true }),
59
+ }, { additionalProperties: false })),
60
+ startedAt: Timestamp,
61
+ latencyMs: Type.Integer({ minimum: 0 }),
62
+ }, { additionalProperties: false, $id: "asm-retrieval-v1" });
63
+ export const IntentContractSchema = Type.Object({
64
+ header: Header,
65
+ intentId: Id,
66
+ operation: Type.Union([
67
+ Type.Literal("diagnose"),
68
+ Type.Literal("read"),
69
+ Type.Literal("write"),
70
+ Type.Literal("execute"),
71
+ Type.Literal("communicate"),
72
+ Type.Literal("deploy"),
73
+ Type.Literal("purchase"),
74
+ Type.Literal("delete"),
75
+ ]),
76
+ resources: Type.Array(Id, { uniqueItems: true }),
77
+ externalEffect: Type.Boolean(),
78
+ idempotencyKey: Type.Optional(Id),
79
+ requestedAt: Timestamp,
80
+ arguments: JsonObject,
81
+ }, { additionalProperties: false, $id: "asm-intent-v1" });
82
+ export const PolicyContractSchema = Type.Object({
83
+ header: Header,
84
+ decisionId: Id,
85
+ intentId: Id,
86
+ outcome: Type.Union([Type.Literal("allow"), Type.Literal("deny"), Type.Literal("require_approval")]),
87
+ reasonCodes: Type.Array(Id, { minItems: 1, uniqueItems: true }),
88
+ requiredApprovals: Type.Array(Id, { uniqueItems: true }),
89
+ decidedAt: Timestamp,
90
+ policyVersion: Id,
91
+ }, { additionalProperties: false, $id: "asm-policy-v1" });
92
+ export const FeedbackContractSchema = Type.Object({
93
+ header: Header,
94
+ feedbackId: Id,
95
+ targetType: Type.Union([Type.Literal("memory"), Type.Literal("retrieval"), Type.Literal("action")]),
96
+ targetId: Id,
97
+ rating: Type.Union([Type.Literal("positive"), Type.Literal("negative"), Type.Literal("correction")]),
98
+ comment: Type.Optional(Type.String({ maxLength: 8000 })),
99
+ createdAt: Timestamp,
100
+ }, { additionalProperties: false, $id: "asm-feedback-v1" });
101
+ export const StateSnapshotContractSchema = Type.Object({
102
+ header: Header,
103
+ snapshotId: Id,
104
+ sessionId: Id,
105
+ sequence: Type.Integer({ minimum: 0 }),
106
+ state: JsonObject,
107
+ digest: Type.String({ pattern: "^[a-f0-9]{64}$" }),
108
+ createdAt: Timestamp,
109
+ }, { additionalProperties: false, $id: "asm-state-snapshot-v1" });
110
+ export const InferenceManifestContractSchema = Type.Object({
111
+ header: Header,
112
+ manifestId: Id,
113
+ modelId: Id,
114
+ modelVersion: Id,
115
+ backend: Type.Union([
116
+ Type.Literal("deterministic"),
117
+ Type.Literal("vector"),
118
+ Type.Literal("causal_head"),
119
+ Type.Literal("dual_asm"),
120
+ Type.Literal("asm_cm"),
121
+ ]),
122
+ artifactDigest: Type.Optional(Type.String({ pattern: "^[a-f0-9]{64}$" })),
123
+ contractMajors: Type.Record(Id, Type.Integer({ minimum: 1 })),
124
+ parameters: JsonObject,
125
+ createdAt: Timestamp,
126
+ }, { additionalProperties: false, $id: "asm-inference-manifest-v1" });
127
+ export const ASM_CONTRACT_SCHEMAS = {
128
+ memory: MemoryContractSchema,
129
+ evidence: EvidenceContractSchema,
130
+ retrieval: RetrievalContractSchema,
131
+ intent: IntentContractSchema,
132
+ policy: PolicyContractSchema,
133
+ feedback: FeedbackContractSchema,
134
+ stateSnapshot: StateSnapshotContractSchema,
135
+ inferenceManifest: InferenceManifestContractSchema,
136
+ };
137
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,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,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,EAAE;IACX,YAAY,EAAE,EAAE;IAChB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;KACtB,CAAC;IACF,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACzE,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IAC7D,UAAU,EAAE,UAAU;IACtB,SAAS,EAAE,SAAS;CACpB,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,GAAG,EAAE,2BAA2B,EAAE,CACjE,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IACnC,MAAM,EAAE,oBAAoB;IAC5B,QAAQ,EAAE,sBAAsB;IAChC,SAAS,EAAE,uBAAuB;IAClC,MAAM,EAAE,oBAAoB;IAC5B,MAAM,EAAE,oBAAoB;IAC5B,QAAQ,EAAE,sBAAsB;IAChC,aAAa,EAAE,2BAA2B;IAC1C,iBAAiB,EAAE,+BAA+B;CACzC,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\n\nexport const ASM_CONTRACT_NAMESPACE = \"ai.aletheion.asm\" as const;\nexport const ASM_CONTRACT_MAJOR = 1 as const;\nexport const ASM_CONTRACT_MINOR = 1 as const;\n\nconst Id = Type.String({ minLength: 1, maxLength: 200 });\nconst Timestamp = Type.String({ format: \"date-time\" });\nconst JsonObject = Type.Record(Type.String(), Type.Unknown());\nconst Score = Type.Number({ minimum: 0, maximum: 1 });\n\nconst Header = Type.Object(\n\t{\n\t\tnamespace: Type.Literal(ASM_CONTRACT_NAMESPACE),\n\t\tmajor: Type.Literal(ASM_CONTRACT_MAJOR),\n\t\tminor: Type.Integer({ minimum: 0 }),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const MemoryContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tmemoryId: Id,\n\t\trevision: Type.Integer({ minimum: 1 }),\n\t\townerId: Id,\n\t\tprojectId: Id,\n\t\tsessionId: Type.Optional(Id),\n\t\tkind: Type.Union([Type.Literal(\"observation\"), Type.Literal(\"fact\"), Type.Literal(\"instruction\")]),\n\t\tcontent: Type.String({ minLength: 1 }),\n\t\tevidenceIds: Type.Array(Id, { uniqueItems: true }),\n\t\tcreatedAt: Timestamp,\n\t\ttombstonedAt: Type.Optional(Timestamp),\n\t\tmetadata: Type.Optional(JsonObject),\n\t},\n\t{ additionalProperties: false, $id: \"asm-memory-v1\" },\n);\n\nexport const EvidenceContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tevidenceId: Id,\n\t\townerId: Id,\n\t\tprojectId: Id,\n\t\tsourceType: Type.Union([\n\t\t\tType.Literal(\"user\"),\n\t\t\tType.Literal(\"tool\"),\n\t\t\tType.Literal(\"document\"),\n\t\t\tType.Literal(\"system\"),\n\t\t]),\n\t\tsourceUri: Type.Optional(Type.String({ maxLength: 4096 })),\n\t\tdigest: Type.String({ pattern: \"^[a-f0-9]{64}$\" }),\n\t\tcapturedAt: Timestamp,\n\t\tcontentType: Type.String({ minLength: 1 }),\n\t\tmetadata: Type.Optional(JsonObject),\n\t},\n\t{ additionalProperties: false, $id: \"asm-evidence-v1\" },\n);\n\nexport const RetrievalContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\trequestId: Id,\n\t\townerId: Id,\n\t\tprojectId: Id,\n\t\tsessionId: Type.Optional(Id),\n\t\tquery: Type.String({ minLength: 1 }),\n\t\tlimit: Type.Integer({ minimum: 1, maximum: 200 }),\n\t\talgorithm: Id,\n\t\tcandidates: Type.Array(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tmemoryId: Id,\n\t\t\t\t\tscore: Score,\n\t\t\t\t\tselected: Type.Boolean(),\n\t\t\t\t\treasonCodes: Type.Array(Id, { uniqueItems: true }),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t\tstartedAt: Timestamp,\n\t\tlatencyMs: Type.Integer({ minimum: 0 }),\n\t},\n\t{ additionalProperties: false, $id: \"asm-retrieval-v1\" },\n);\n\nexport const IntentContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tintentId: Id,\n\t\toperation: Type.Union([\n\t\t\tType.Literal(\"diagnose\"),\n\t\t\tType.Literal(\"read\"),\n\t\t\tType.Literal(\"write\"),\n\t\t\tType.Literal(\"execute\"),\n\t\t\tType.Literal(\"communicate\"),\n\t\t\tType.Literal(\"deploy\"),\n\t\t\tType.Literal(\"purchase\"),\n\t\t\tType.Literal(\"delete\"),\n\t\t]),\n\t\tresources: Type.Array(Id, { uniqueItems: true }),\n\t\texternalEffect: Type.Boolean(),\n\t\tidempotencyKey: Type.Optional(Id),\n\t\trequestedAt: Timestamp,\n\t\targuments: JsonObject,\n\t},\n\t{ additionalProperties: false, $id: \"asm-intent-v1\" },\n);\n\nexport const PolicyContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tdecisionId: Id,\n\t\tintentId: Id,\n\t\toutcome: Type.Union([Type.Literal(\"allow\"), Type.Literal(\"deny\"), Type.Literal(\"require_approval\")]),\n\t\treasonCodes: Type.Array(Id, { minItems: 1, uniqueItems: true }),\n\t\trequiredApprovals: Type.Array(Id, { uniqueItems: true }),\n\t\tdecidedAt: Timestamp,\n\t\tpolicyVersion: Id,\n\t},\n\t{ additionalProperties: false, $id: \"asm-policy-v1\" },\n);\n\nexport const FeedbackContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tfeedbackId: Id,\n\t\ttargetType: Type.Union([Type.Literal(\"memory\"), Type.Literal(\"retrieval\"), Type.Literal(\"action\")]),\n\t\ttargetId: Id,\n\t\trating: Type.Union([Type.Literal(\"positive\"), Type.Literal(\"negative\"), Type.Literal(\"correction\")]),\n\t\tcomment: Type.Optional(Type.String({ maxLength: 8000 })),\n\t\tcreatedAt: Timestamp,\n\t},\n\t{ additionalProperties: false, $id: \"asm-feedback-v1\" },\n);\n\nexport const StateSnapshotContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tsnapshotId: Id,\n\t\tsessionId: Id,\n\t\tsequence: Type.Integer({ minimum: 0 }),\n\t\tstate: JsonObject,\n\t\tdigest: Type.String({ pattern: \"^[a-f0-9]{64}$\" }),\n\t\tcreatedAt: Timestamp,\n\t},\n\t{ additionalProperties: false, $id: \"asm-state-snapshot-v1\" },\n);\n\nexport const InferenceManifestContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tmanifestId: Id,\n\t\tmodelId: Id,\n\t\tmodelVersion: Id,\n\t\tbackend: Type.Union([\n\t\t\tType.Literal(\"deterministic\"),\n\t\t\tType.Literal(\"vector\"),\n\t\t\tType.Literal(\"causal_head\"),\n\t\t\tType.Literal(\"dual_asm\"),\n\t\t\tType.Literal(\"asm_cm\"),\n\t\t]),\n\t\tartifactDigest: Type.Optional(Type.String({ pattern: \"^[a-f0-9]{64}$\" })),\n\t\tcontractMajors: Type.Record(Id, Type.Integer({ minimum: 1 })),\n\t\tparameters: JsonObject,\n\t\tcreatedAt: Timestamp,\n\t},\n\t{ additionalProperties: false, $id: \"asm-inference-manifest-v1\" },\n);\n\nexport const ASM_CONTRACT_SCHEMAS = {\n\tmemory: MemoryContractSchema,\n\tevidence: EvidenceContractSchema,\n\tretrieval: RetrievalContractSchema,\n\tintent: IntentContractSchema,\n\tpolicy: PolicyContractSchema,\n\tfeedback: FeedbackContractSchema,\n\tstateSnapshot: StateSnapshotContractSchema,\n\tinferenceManifest: InferenceManifestContractSchema,\n} as const;\n\nexport type AsmContractName = keyof typeof ASM_CONTRACT_SCHEMAS;\nexport type MemoryContract = Static<typeof MemoryContractSchema>;\nexport type EvidenceContract = Static<typeof EvidenceContractSchema>;\nexport type RetrievalContract = Static<typeof RetrievalContractSchema>;\nexport type IntentContract = Static<typeof IntentContractSchema>;\nexport type PolicyContract = Static<typeof PolicyContractSchema>;\nexport type FeedbackContract = Static<typeof FeedbackContractSchema>;\nexport type StateSnapshotContract = Static<typeof StateSnapshotContractSchema>;\nexport type InferenceManifestContract = Static<typeof InferenceManifestContractSchema>;\n"]}
@@ -0,0 +1,14 @@
1
+ import { type AsmContractName } from "./schemas.js";
2
+ export interface ContractValidationError {
3
+ path: string;
4
+ message: string;
5
+ }
6
+ export type ContractValidationResult = {
7
+ valid: true;
8
+ } | {
9
+ valid: false;
10
+ errors: ContractValidationError[];
11
+ };
12
+ export declare function validateContract(name: AsmContractName, value: unknown): ContractValidationResult;
13
+ export declare function assertContract(name: AsmContractName, value: unknown): void;
14
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAM1E,MAAM,WAAW,uBAAuB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,wBAAwB,GAAG;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,uBAAuB,EAAE,CAAA;CAAE,CAAC;AAE7G,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,wBAAwB,CAOhG;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAO1E","sourcesContent":["import { Compile, type Validator } from \"typebox/compile\";\nimport { ASM_CONTRACT_SCHEMAS, type AsmContractName } from \"./schemas.js\";\n\nconst validators = Object.fromEntries(\n\tObject.entries(ASM_CONTRACT_SCHEMAS).map(([name, schema]) => [name, Compile(schema)]),\n) as Record<AsmContractName, Validator>;\n\nexport interface ContractValidationError {\n\tpath: string;\n\tmessage: string;\n}\n\nexport type ContractValidationResult = { valid: true } | { valid: false; errors: ContractValidationError[] };\n\nexport function validateContract(name: AsmContractName, value: unknown): ContractValidationResult {\n\tconst validator = validators[name];\n\tif (validator.Check(value)) return { valid: true };\n\treturn {\n\t\tvalid: false,\n\t\terrors: [...validator.Errors(value)].map((error) => ({ path: error.instancePath, message: error.message })),\n\t};\n}\n\nexport function assertContract(name: AsmContractName, value: unknown): void {\n\tconst result = validateContract(name, value);\n\tif (!result.valid) {\n\t\tthrow new Error(\n\t\t\t`Invalid ${name} contract: ${result.errors.map((error) => `${error.path || \"/\"} ${error.message}`).join(\"; \")}`,\n\t\t);\n\t}\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { Compile } from "typebox/compile";
2
+ import { ASM_CONTRACT_SCHEMAS } from "./schemas.js";
3
+ const validators = Object.fromEntries(Object.entries(ASM_CONTRACT_SCHEMAS).map(([name, schema]) => [name, Compile(schema)]));
4
+ export function validateContract(name, value) {
5
+ const validator = validators[name];
6
+ if (validator.Check(value))
7
+ return { valid: true };
8
+ return {
9
+ valid: false,
10
+ errors: [...validator.Errors(value)].map((error) => ({ path: error.instancePath, message: error.message })),
11
+ };
12
+ }
13
+ export function assertContract(name, value) {
14
+ const result = validateContract(name, value);
15
+ if (!result.valid) {
16
+ throw new Error(`Invalid ${name} contract: ${result.errors.map((error) => `${error.path || "/"} ${error.message}`).join("; ")}`);
17
+ }
18
+ }
19
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],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;IACH,CAAC;AAAA,CACD","sourcesContent":["import { Compile, type Validator } from \"typebox/compile\";\nimport { ASM_CONTRACT_SCHEMAS, type AsmContractName } from \"./schemas.js\";\n\nconst validators = Object.fromEntries(\n\tObject.entries(ASM_CONTRACT_SCHEMAS).map(([name, schema]) => [name, Compile(schema)]),\n) as Record<AsmContractName, Validator>;\n\nexport interface ContractValidationError {\n\tpath: string;\n\tmessage: string;\n}\n\nexport type ContractValidationResult = { valid: true } | { valid: false; errors: ContractValidationError[] };\n\nexport function validateContract(name: AsmContractName, value: unknown): ContractValidationResult {\n\tconst validator = validators[name];\n\tif (validator.Check(value)) return { valid: true };\n\treturn {\n\t\tvalid: false,\n\t\terrors: [...validator.Errors(value)].map((error) => ({ path: error.instancePath, message: error.message })),\n\t};\n}\n\nexport function assertContract(name: AsmContractName, value: unknown): void {\n\tconst result = validateContract(name, value);\n\tif (!result.valid) {\n\t\tthrow new Error(\n\t\t\t`Invalid ${name} contract: ${result.errors.map((error) => `${error.path || \"/\"} ${error.message}`).join(\"; \")}`,\n\t\t);\n\t}\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@asm-agent/contracts",
3
+ "version": "0.8.2",
4
+ "description": "Versioned ASM Agent contracts and capability negotiation",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "schemas",
17
+ "python",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "clean": "shx rm -rf dist",
22
+ "build": "tsgo -p tsconfig.build.json",
23
+ "generate": "tsx scripts/generate.ts",
24
+ "test": "vitest --run",
25
+ "prepublishOnly": "npm run clean && npm run generate && npm run build"
26
+ },
27
+ "dependencies": {
28
+ "typebox": "^1.3.9"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^24.3.0",
32
+ "typescript": "^7.0.2",
33
+ "vitest": "^4.1.10"
34
+ },
35
+ "engines": {
36
+ "node": ">=22.8.0"
37
+ },
38
+ "license": "(AGPL-3.0-only OR LicenseRef-ASM-Commercial)",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/AletheionAGI/asm-agent.git",
42
+ "directory": "packages/contracts"
43
+ }
44
+ }
@@ -0,0 +1,170 @@
1
+ # Generated from src/schemas.ts. Do not edit manually.
2
+ from __future__ import annotations
3
+
4
+ from dataclasses import dataclass, field
5
+ from datetime import datetime
6
+ from typing import Any, Literal
7
+
8
+ NAMESPACE = "ai.aletheion.asm"
9
+ MAJOR = 1
10
+ MINOR = 1
11
+
12
+ JsonObject = dict[str, Any]
13
+
14
+ @dataclass(frozen=True, slots=True)
15
+ class Header:
16
+ namespace: Literal["ai.aletheion.asm"] = NAMESPACE
17
+ major: Literal[1] = MAJOR
18
+ minor: int = MINOR
19
+
20
+ def __post_init__(self) -> None:
21
+ if self.namespace != NAMESPACE or self.major != MAJOR or self.minor < 0:
22
+ raise ValueError("unsupported ASM contract header")
23
+
24
+ @dataclass(frozen=True, slots=True)
25
+ class MemoryContract:
26
+ header: Header
27
+ memory_id: str
28
+ revision: int
29
+ owner_id: str
30
+ project_id: str
31
+ kind: Literal["observation", "fact", "instruction"]
32
+ content: str
33
+ evidence_ids: tuple[str, ...]
34
+ created_at: datetime
35
+ session_id: str | None = None
36
+ tombstoned_at: datetime | None = None
37
+ metadata: JsonObject = field(default_factory=dict)
38
+
39
+ @dataclass(frozen=True, slots=True)
40
+ class EvidenceContract:
41
+ header: Header
42
+ evidence_id: str
43
+ owner_id: str
44
+ project_id: str
45
+ source_type: Literal["user", "tool", "document", "system"]
46
+ digest: str
47
+ captured_at: datetime
48
+ content_type: str
49
+ source_uri: str | None = None
50
+ metadata: JsonObject = field(default_factory=dict)
51
+
52
+ @dataclass(frozen=True, slots=True)
53
+ class RetrievalCandidate:
54
+ memory_id: str
55
+ score: float
56
+ selected: bool
57
+ reason_codes: tuple[str, ...]
58
+
59
+ @dataclass(frozen=True, slots=True)
60
+ class RetrievalContract:
61
+ header: Header
62
+ request_id: str
63
+ owner_id: str
64
+ project_id: str
65
+ query: str
66
+ limit: int
67
+ algorithm: str
68
+ candidates: tuple[RetrievalCandidate, ...]
69
+ started_at: datetime
70
+ latency_ms: int
71
+ session_id: str | None = None
72
+
73
+ @dataclass(frozen=True, slots=True)
74
+ class IntentContract:
75
+ header: Header
76
+ intent_id: str
77
+ operation: Literal["diagnose", "read", "write", "execute", "communicate", "deploy", "purchase", "delete"]
78
+ resources: tuple[str, ...]
79
+ external_effect: bool
80
+ requested_at: datetime
81
+ arguments: JsonObject
82
+ idempotency_key: str | None = None
83
+
84
+ @dataclass(frozen=True, slots=True)
85
+ class PolicyContract:
86
+ header: Header
87
+ decision_id: str
88
+ intent_id: str
89
+ outcome: Literal["allow", "deny", "require_approval"]
90
+ reason_codes: tuple[str, ...]
91
+ required_approvals: tuple[str, ...]
92
+ decided_at: datetime
93
+ policy_version: str
94
+
95
+ @dataclass(frozen=True, slots=True)
96
+ class FeedbackContract:
97
+ header: Header
98
+ feedback_id: str
99
+ target_type: Literal["memory", "retrieval", "action"]
100
+ target_id: str
101
+ rating: Literal["positive", "negative", "correction"]
102
+ created_at: datetime
103
+ comment: str | None = None
104
+
105
+ @dataclass(frozen=True, slots=True)
106
+ class StateSnapshotContract:
107
+ header: Header
108
+ snapshot_id: str
109
+ session_id: str
110
+ sequence: int
111
+ state: JsonObject
112
+ digest: str
113
+ created_at: datetime
114
+
115
+ @dataclass(frozen=True, slots=True)
116
+ class InferenceManifestContract:
117
+ header: Header
118
+ manifest_id: str
119
+ model_id: str
120
+ model_version: str
121
+ backend: Literal["deterministic", "vector", "causal_head", "dual_asm", "asm_cm"]
122
+ contract_majors: dict[str, int]
123
+ parameters: JsonObject
124
+ created_at: datetime
125
+ artifact_digest: str | None = None
126
+
127
+ REQUIRED_FIELDS: dict[str, frozenset[str]] = {
128
+ "memory": frozenset({"header", "memoryId", "revision", "ownerId", "projectId", "kind", "content", "evidenceIds", "createdAt"}),
129
+ "evidence": frozenset({"header", "evidenceId", "ownerId", "projectId", "sourceType", "digest", "capturedAt", "contentType"}),
130
+ "retrieval": frozenset({"header", "requestId", "ownerId", "projectId", "query", "limit", "algorithm", "candidates", "startedAt", "latencyMs"}),
131
+ "intent": frozenset({"header", "intentId", "operation", "resources", "externalEffect", "requestedAt", "arguments"}),
132
+ "policy": frozenset({"header", "decisionId", "intentId", "outcome", "reasonCodes", "requiredApprovals", "decidedAt", "policyVersion"}),
133
+ "feedback": frozenset({"header", "feedbackId", "targetType", "targetId", "rating", "createdAt"}),
134
+ "stateSnapshot": frozenset({"header", "snapshotId", "sessionId", "sequence", "state", "digest", "createdAt"}),
135
+ "inferenceManifest": frozenset({"header", "manifestId", "modelId", "modelVersion", "backend", "contractMajors", "parameters", "createdAt"}),
136
+ }
137
+
138
+ OPTIONAL_FIELDS: dict[str, frozenset[str]] = {
139
+ "memory": frozenset({"sessionId", "tombstonedAt", "metadata"}),
140
+ "evidence": frozenset({"sourceUri", "metadata"}),
141
+ "retrieval": frozenset({"sessionId"}),
142
+ "intent": frozenset({"idempotencyKey"}),
143
+ "policy": frozenset(),
144
+ "feedback": frozenset({"comment"}),
145
+ "stateSnapshot": frozenset(),
146
+ "inferenceManifest": frozenset({"artifactDigest"}),
147
+ }
148
+
149
+ def validate_wire_contract(name: str, payload: object) -> None:
150
+ if name not in REQUIRED_FIELDS:
151
+ raise ValueError(f"unknown ASM contract: {name}")
152
+ if not isinstance(payload, dict):
153
+ raise ValueError("ASM contract payload must be an object")
154
+ keys = set(payload)
155
+ missing = REQUIRED_FIELDS[name] - keys
156
+ unknown = keys - REQUIRED_FIELDS[name] - OPTIONAL_FIELDS[name]
157
+ if missing:
158
+ raise ValueError(f"missing fields: {sorted(missing)}")
159
+ if unknown:
160
+ raise ValueError(f"unknown fields: {sorted(unknown)}")
161
+ header = payload.get("header")
162
+ if not isinstance(header, dict):
163
+ raise ValueError("header must be an object")
164
+ if set(header) != {"namespace", "major", "minor"}:
165
+ raise ValueError("invalid header fields")
166
+ if header.get("namespace") != NAMESPACE or header.get("major") != MAJOR:
167
+ raise ValueError("unsupported ASM contract header")
168
+ minor = header.get("minor")
169
+ if not isinstance(minor, int) or isinstance(minor, bool) or minor < 0:
170
+ raise ValueError("header minor must be a non-negative integer")
@@ -0,0 +1,97 @@
1
+ {
2
+ "type": "object",
3
+ "required": [
4
+ "header",
5
+ "evidenceId",
6
+ "ownerId",
7
+ "projectId",
8
+ "sourceType",
9
+ "digest",
10
+ "capturedAt",
11
+ "contentType"
12
+ ],
13
+ "properties": {
14
+ "header": {
15
+ "type": "object",
16
+ "required": [
17
+ "namespace",
18
+ "major",
19
+ "minor"
20
+ ],
21
+ "properties": {
22
+ "namespace": {
23
+ "type": "string",
24
+ "const": "ai.aletheion.asm"
25
+ },
26
+ "major": {
27
+ "type": "number",
28
+ "const": 1
29
+ },
30
+ "minor": {
31
+ "type": "integer",
32
+ "minimum": 0
33
+ }
34
+ },
35
+ "additionalProperties": false
36
+ },
37
+ "evidenceId": {
38
+ "type": "string",
39
+ "minLength": 1,
40
+ "maxLength": 200
41
+ },
42
+ "ownerId": {
43
+ "type": "string",
44
+ "minLength": 1,
45
+ "maxLength": 200
46
+ },
47
+ "projectId": {
48
+ "type": "string",
49
+ "minLength": 1,
50
+ "maxLength": 200
51
+ },
52
+ "sourceType": {
53
+ "anyOf": [
54
+ {
55
+ "type": "string",
56
+ "const": "user"
57
+ },
58
+ {
59
+ "type": "string",
60
+ "const": "tool"
61
+ },
62
+ {
63
+ "type": "string",
64
+ "const": "document"
65
+ },
66
+ {
67
+ "type": "string",
68
+ "const": "system"
69
+ }
70
+ ]
71
+ },
72
+ "sourceUri": {
73
+ "type": "string",
74
+ "maxLength": 4096
75
+ },
76
+ "digest": {
77
+ "type": "string",
78
+ "pattern": "^[a-f0-9]{64}$"
79
+ },
80
+ "capturedAt": {
81
+ "type": "string",
82
+ "format": "date-time"
83
+ },
84
+ "contentType": {
85
+ "type": "string",
86
+ "minLength": 1
87
+ },
88
+ "metadata": {
89
+ "type": "object",
90
+ "patternProperties": {
91
+ "^.*$": {}
92
+ }
93
+ }
94
+ },
95
+ "additionalProperties": false,
96
+ "$id": "asm-evidence-v1"
97
+ }
@@ -0,0 +1,88 @@
1
+ {
2
+ "type": "object",
3
+ "required": [
4
+ "header",
5
+ "feedbackId",
6
+ "targetType",
7
+ "targetId",
8
+ "rating",
9
+ "createdAt"
10
+ ],
11
+ "properties": {
12
+ "header": {
13
+ "type": "object",
14
+ "required": [
15
+ "namespace",
16
+ "major",
17
+ "minor"
18
+ ],
19
+ "properties": {
20
+ "namespace": {
21
+ "type": "string",
22
+ "const": "ai.aletheion.asm"
23
+ },
24
+ "major": {
25
+ "type": "number",
26
+ "const": 1
27
+ },
28
+ "minor": {
29
+ "type": "integer",
30
+ "minimum": 0
31
+ }
32
+ },
33
+ "additionalProperties": false
34
+ },
35
+ "feedbackId": {
36
+ "type": "string",
37
+ "minLength": 1,
38
+ "maxLength": 200
39
+ },
40
+ "targetType": {
41
+ "anyOf": [
42
+ {
43
+ "type": "string",
44
+ "const": "memory"
45
+ },
46
+ {
47
+ "type": "string",
48
+ "const": "retrieval"
49
+ },
50
+ {
51
+ "type": "string",
52
+ "const": "action"
53
+ }
54
+ ]
55
+ },
56
+ "targetId": {
57
+ "type": "string",
58
+ "minLength": 1,
59
+ "maxLength": 200
60
+ },
61
+ "rating": {
62
+ "anyOf": [
63
+ {
64
+ "type": "string",
65
+ "const": "positive"
66
+ },
67
+ {
68
+ "type": "string",
69
+ "const": "negative"
70
+ },
71
+ {
72
+ "type": "string",
73
+ "const": "correction"
74
+ }
75
+ ]
76
+ },
77
+ "comment": {
78
+ "type": "string",
79
+ "maxLength": 8000
80
+ },
81
+ "createdAt": {
82
+ "type": "string",
83
+ "format": "date-time"
84
+ }
85
+ },
86
+ "additionalProperties": false,
87
+ "$id": "asm-feedback-v1"
88
+ }