@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.
- package/README.md +10 -0
- package/dist/fakes.d.ts +14 -0
- package/dist/fakes.d.ts.map +1 -0
- package/dist/fakes.js +45 -0
- package/dist/fakes.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/negotiation.d.ts +26 -0
- package/dist/negotiation.d.ts.map +1 -0
- package/dist/negotiation.js +68 -0
- package/dist/negotiation.js.map +1 -0
- package/dist/schemas.d.ts +266 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +137 -0
- package/dist/schemas.js.map +1 -0
- package/dist/validation.d.ts +14 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +19 -0
- package/dist/validation.js.map +1 -0
- package/package.json +44 -0
- package/python/__pycache__/asm_contracts.cpython-314.pyc +0 -0
- package/python/asm_contracts.py +170 -0
- package/schemas/evidence.schema.json +97 -0
- package/schemas/feedback.schema.json +88 -0
- package/schemas/inferenceManifest.schema.json +102 -0
- package/schemas/intent.schema.json +107 -0
- package/schemas/memory.schema.json +108 -0
- package/schemas/policy.schema.json +94 -0
- package/schemas/retrieval.schema.json +121 -0
- package/schemas/stateSnapshot.schema.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# `@asm-agent/contracts`
|
|
2
|
+
|
|
3
|
+
The TypeBox definitions in `src/schemas.ts` are the canonical source for ASM
|
|
4
|
+
Agent wire contracts. `npm run generate` emits portable JSON Schema and Python
|
|
5
|
+
dataclass representations. Generated files must not be edited manually.
|
|
6
|
+
|
|
7
|
+
Major versions are compatibility boundaries. Minor versions are negotiated to
|
|
8
|
+
the highest mutually supported value, and optional behavior additionally
|
|
9
|
+
requires a named capability. Peers must not send fields from a newer minor
|
|
10
|
+
until that minor and its capability have both been negotiated.
|
package/dist/fakes.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MemoryContract, RetrievalContract } from "./schemas.js";
|
|
2
|
+
export declare class DeterministicMemoryFake {
|
|
3
|
+
private readonly records;
|
|
4
|
+
put(memory: MemoryContract): void;
|
|
5
|
+
get(memoryId: string): MemoryContract | undefined;
|
|
6
|
+
retrieve(input: {
|
|
7
|
+
requestId: string;
|
|
8
|
+
ownerId: string;
|
|
9
|
+
projectId: string;
|
|
10
|
+
query: string;
|
|
11
|
+
limit: number;
|
|
12
|
+
}): RetrievalContract;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=fakes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakes.d.ts","sourceRoot":"","sources":["../src/fakes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtE,qBAAa,uBAAuB;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqC;IAE7D,GAAG,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAEhC;IAED,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAGhD;IAED,QAAQ,CAAC,KAAK,EAAE;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACd,GAAG,iBAAiB,CA+BpB;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { MemoryContract, RetrievalContract } from \"./schemas.js\";\n\nexport class DeterministicMemoryFake {\n\tprivate readonly records = new Map<string, MemoryContract>();\n\n\tput(memory: MemoryContract): void {\n\t\tthis.records.set(memory.memoryId, structuredClone(memory));\n\t}\n\n\tget(memoryId: string): MemoryContract | undefined {\n\t\tconst record = this.records.get(memoryId);\n\t\treturn record ? structuredClone(record) : undefined;\n\t}\n\n\tretrieve(input: {\n\t\trequestId: string;\n\t\townerId: string;\n\t\tprojectId: string;\n\t\tquery: string;\n\t\tlimit: number;\n\t}): RetrievalContract {\n\t\tconst queryTerms = new Set(input.query.toLowerCase().split(/\\s+/).filter(Boolean));\n\t\tconst candidates = [...this.records.values()]\n\t\t\t.filter(\n\t\t\t\t(record) =>\n\t\t\t\t\trecord.ownerId === input.ownerId && record.projectId === input.projectId && !record.tombstonedAt,\n\t\t\t)\n\t\t\t.map((record) => {\n\t\t\t\tconst terms = record.content.toLowerCase().split(/\\s+/).filter(Boolean);\n\t\t\t\tconst matches = terms.filter((term) => queryTerms.has(term)).length;\n\t\t\t\treturn { record, score: terms.length === 0 ? 0 : matches / terms.length };\n\t\t\t})\n\t\t\t.sort((left, right) => right.score - left.score || left.record.memoryId.localeCompare(right.record.memoryId))\n\t\t\t.slice(0, input.limit);\n\t\treturn {\n\t\t\theader: { namespace: \"ai.aletheion.asm\", major: 1, minor: 0 },\n\t\t\trequestId: input.requestId,\n\t\t\townerId: input.ownerId,\n\t\t\tprojectId: input.projectId,\n\t\t\tquery: input.query,\n\t\t\tlimit: input.limit,\n\t\t\talgorithm: \"deterministic-lexical-v1\",\n\t\t\tcandidates: candidates.map(({ record, score }) => ({\n\t\t\t\tmemoryId: record.memoryId,\n\t\t\t\tscore,\n\t\t\t\tselected: score > 0,\n\t\t\t\treasonCodes: score > 0 ? [\"term_overlap\"] : [\"no_overlap\"],\n\t\t\t})),\n\t\t\tstartedAt: deterministicTimestamp(input.requestId),\n\t\t\tlatencyMs: 0,\n\t\t};\n\t}\n}\n\nfunction deterministicTimestamp(seed: string): string {\n\tconst seconds = Number.parseInt(createHash(\"sha256\").update(seed).digest(\"hex\").slice(0, 8), 16);\n\treturn new Date(seconds * 1000).toISOString();\n}\n"]}
|
package/dist/fakes.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
export class DeterministicMemoryFake {
|
|
3
|
+
records = new Map();
|
|
4
|
+
put(memory) {
|
|
5
|
+
this.records.set(memory.memoryId, structuredClone(memory));
|
|
6
|
+
}
|
|
7
|
+
get(memoryId) {
|
|
8
|
+
const record = this.records.get(memoryId);
|
|
9
|
+
return record ? structuredClone(record) : undefined;
|
|
10
|
+
}
|
|
11
|
+
retrieve(input) {
|
|
12
|
+
const queryTerms = new Set(input.query.toLowerCase().split(/\s+/).filter(Boolean));
|
|
13
|
+
const candidates = [...this.records.values()]
|
|
14
|
+
.filter((record) => record.ownerId === input.ownerId && record.projectId === input.projectId && !record.tombstonedAt)
|
|
15
|
+
.map((record) => {
|
|
16
|
+
const terms = record.content.toLowerCase().split(/\s+/).filter(Boolean);
|
|
17
|
+
const matches = terms.filter((term) => queryTerms.has(term)).length;
|
|
18
|
+
return { record, score: terms.length === 0 ? 0 : matches / terms.length };
|
|
19
|
+
})
|
|
20
|
+
.sort((left, right) => right.score - left.score || left.record.memoryId.localeCompare(right.record.memoryId))
|
|
21
|
+
.slice(0, input.limit);
|
|
22
|
+
return {
|
|
23
|
+
header: { namespace: "ai.aletheion.asm", major: 1, minor: 0 },
|
|
24
|
+
requestId: input.requestId,
|
|
25
|
+
ownerId: input.ownerId,
|
|
26
|
+
projectId: input.projectId,
|
|
27
|
+
query: input.query,
|
|
28
|
+
limit: input.limit,
|
|
29
|
+
algorithm: "deterministic-lexical-v1",
|
|
30
|
+
candidates: candidates.map(({ record, score }) => ({
|
|
31
|
+
memoryId: record.memoryId,
|
|
32
|
+
score,
|
|
33
|
+
selected: score > 0,
|
|
34
|
+
reasonCodes: score > 0 ? ["term_overlap"] : ["no_overlap"],
|
|
35
|
+
})),
|
|
36
|
+
startedAt: deterministicTimestamp(input.requestId),
|
|
37
|
+
latencyMs: 0,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function deterministicTimestamp(seed) {
|
|
42
|
+
const seconds = Number.parseInt(createHash("sha256").update(seed).digest("hex").slice(0, 8), 16);
|
|
43
|
+
return new Date(seconds * 1000).toISOString();
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=fakes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakes.js","sourceRoot":"","sources":["../src/fakes.ts"],"names":[],"mappings":"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","sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { MemoryContract, RetrievalContract } from \"./schemas.js\";\n\nexport class DeterministicMemoryFake {\n\tprivate readonly records = new Map<string, MemoryContract>();\n\n\tput(memory: MemoryContract): void {\n\t\tthis.records.set(memory.memoryId, structuredClone(memory));\n\t}\n\n\tget(memoryId: string): MemoryContract | undefined {\n\t\tconst record = this.records.get(memoryId);\n\t\treturn record ? structuredClone(record) : undefined;\n\t}\n\n\tretrieve(input: {\n\t\trequestId: string;\n\t\townerId: string;\n\t\tprojectId: string;\n\t\tquery: string;\n\t\tlimit: number;\n\t}): RetrievalContract {\n\t\tconst queryTerms = new Set(input.query.toLowerCase().split(/\\s+/).filter(Boolean));\n\t\tconst candidates = [...this.records.values()]\n\t\t\t.filter(\n\t\t\t\t(record) =>\n\t\t\t\t\trecord.ownerId === input.ownerId && record.projectId === input.projectId && !record.tombstonedAt,\n\t\t\t)\n\t\t\t.map((record) => {\n\t\t\t\tconst terms = record.content.toLowerCase().split(/\\s+/).filter(Boolean);\n\t\t\t\tconst matches = terms.filter((term) => queryTerms.has(term)).length;\n\t\t\t\treturn { record, score: terms.length === 0 ? 0 : matches / terms.length };\n\t\t\t})\n\t\t\t.sort((left, right) => right.score - left.score || left.record.memoryId.localeCompare(right.record.memoryId))\n\t\t\t.slice(0, input.limit);\n\t\treturn {\n\t\t\theader: { namespace: \"ai.aletheion.asm\", major: 1, minor: 0 },\n\t\t\trequestId: input.requestId,\n\t\t\townerId: input.ownerId,\n\t\t\tprojectId: input.projectId,\n\t\t\tquery: input.query,\n\t\t\tlimit: input.limit,\n\t\t\talgorithm: \"deterministic-lexical-v1\",\n\t\t\tcandidates: candidates.map(({ record, score }) => ({\n\t\t\t\tmemoryId: record.memoryId,\n\t\t\t\tscore,\n\t\t\t\tselected: score > 0,\n\t\t\t\treasonCodes: score > 0 ? [\"term_overlap\"] : [\"no_overlap\"],\n\t\t\t})),\n\t\t\tstartedAt: deterministicTimestamp(input.requestId),\n\t\t\tlatencyMs: 0,\n\t\t};\n\t}\n}\n\nfunction deterministicTimestamp(seed: string): string {\n\tconst seconds = Number.parseInt(createHash(\"sha256\").update(seed).digest(\"hex\").slice(0, 8), 16);\n\treturn new Date(seconds * 1000).toISOString();\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DeterministicMemoryFake } from "./fakes.js";
|
|
2
|
+
export { ASM_CAPABILITIES, type AsmCapability, type AsmNegotiationResult, type AsmPeerHello, type ContractVersionRange, DEFAULT_ASM_HELLO, type NegotiatedContractVersion, negotiateAsmContracts, requireNegotiatedCapability, } from "./negotiation.js";
|
|
3
|
+
export { ASM_CONTRACT_MAJOR, ASM_CONTRACT_MINOR, ASM_CONTRACT_NAMESPACE, ASM_CONTRACT_SCHEMAS, type AsmContractName, type EvidenceContract, EvidenceContractSchema, type FeedbackContract, FeedbackContractSchema, type InferenceManifestContract, InferenceManifestContractSchema, type IntentContract, IntentContractSchema, type MemoryContract, MemoryContractSchema, type PolicyContract, PolicyContractSchema, type RetrievalContract, RetrievalContractSchema, type StateSnapshotContract, StateSnapshotContractSchema, } from "./schemas.js";
|
|
4
|
+
export { assertContract, type ContractValidationError, type ContractValidationResult, validateContract, } from "./validation.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EACN,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,iBAAiB,EACjB,KAAK,yBAAyB,EAC9B,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,yBAAyB,EAC9B,+BAA+B,EAC/B,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,2BAA2B,GAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,cAAc,EACd,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,gBAAgB,GAChB,MAAM,iBAAiB,CAAC","sourcesContent":["export { DeterministicMemoryFake } from \"./fakes.js\";\nexport {\n\tASM_CAPABILITIES,\n\ttype AsmCapability,\n\ttype AsmNegotiationResult,\n\ttype AsmPeerHello,\n\ttype ContractVersionRange,\n\tDEFAULT_ASM_HELLO,\n\ttype NegotiatedContractVersion,\n\tnegotiateAsmContracts,\n\trequireNegotiatedCapability,\n} from \"./negotiation.js\";\nexport {\n\tASM_CONTRACT_MAJOR,\n\tASM_CONTRACT_MINOR,\n\tASM_CONTRACT_NAMESPACE,\n\tASM_CONTRACT_SCHEMAS,\n\ttype AsmContractName,\n\ttype EvidenceContract,\n\tEvidenceContractSchema,\n\ttype FeedbackContract,\n\tFeedbackContractSchema,\n\ttype InferenceManifestContract,\n\tInferenceManifestContractSchema,\n\ttype IntentContract,\n\tIntentContractSchema,\n\ttype MemoryContract,\n\tMemoryContractSchema,\n\ttype PolicyContract,\n\tPolicyContractSchema,\n\ttype RetrievalContract,\n\tRetrievalContractSchema,\n\ttype StateSnapshotContract,\n\tStateSnapshotContractSchema,\n} from \"./schemas.js\";\nexport {\n\tassertContract,\n\ttype ContractValidationError,\n\ttype ContractValidationResult,\n\tvalidateContract,\n} from \"./validation.js\";\n"]}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DeterministicMemoryFake } from "./fakes.js";
|
|
2
|
+
export { ASM_CAPABILITIES, DEFAULT_ASM_HELLO, negotiateAsmContracts, requireNegotiatedCapability, } from "./negotiation.js";
|
|
3
|
+
export { ASM_CONTRACT_MAJOR, ASM_CONTRACT_MINOR, ASM_CONTRACT_NAMESPACE, ASM_CONTRACT_SCHEMAS, EvidenceContractSchema, FeedbackContractSchema, InferenceManifestContractSchema, IntentContractSchema, MemoryContractSchema, PolicyContractSchema, RetrievalContractSchema, StateSnapshotContractSchema, } from "./schemas.js";
|
|
4
|
+
export { assertContract, validateContract, } from "./validation.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EACN,gBAAgB,EAKhB,iBAAiB,EAEjB,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EAGpB,sBAAsB,EAEtB,sBAAsB,EAEtB,+BAA+B,EAE/B,oBAAoB,EAEpB,oBAAoB,EAEpB,oBAAoB,EAEpB,uBAAuB,EAEvB,2BAA2B,GAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,cAAc,EAGd,gBAAgB,GAChB,MAAM,iBAAiB,CAAC","sourcesContent":["export { DeterministicMemoryFake } from \"./fakes.js\";\nexport {\n\tASM_CAPABILITIES,\n\ttype AsmCapability,\n\ttype AsmNegotiationResult,\n\ttype AsmPeerHello,\n\ttype ContractVersionRange,\n\tDEFAULT_ASM_HELLO,\n\ttype NegotiatedContractVersion,\n\tnegotiateAsmContracts,\n\trequireNegotiatedCapability,\n} from \"./negotiation.js\";\nexport {\n\tASM_CONTRACT_MAJOR,\n\tASM_CONTRACT_MINOR,\n\tASM_CONTRACT_NAMESPACE,\n\tASM_CONTRACT_SCHEMAS,\n\ttype AsmContractName,\n\ttype EvidenceContract,\n\tEvidenceContractSchema,\n\ttype FeedbackContract,\n\tFeedbackContractSchema,\n\ttype InferenceManifestContract,\n\tInferenceManifestContractSchema,\n\ttype IntentContract,\n\tIntentContractSchema,\n\ttype MemoryContract,\n\tMemoryContractSchema,\n\ttype PolicyContract,\n\tPolicyContractSchema,\n\ttype RetrievalContract,\n\tRetrievalContractSchema,\n\ttype StateSnapshotContract,\n\tStateSnapshotContractSchema,\n} from \"./schemas.js\";\nexport {\n\tassertContract,\n\ttype ContractValidationError,\n\ttype ContractValidationResult,\n\tvalidateContract,\n} from \"./validation.js\";\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type AsmContractName } from "./schemas.js";
|
|
2
|
+
export declare const ASM_CAPABILITIES: readonly ["memory.read", "memory.write", "evidence.read", "retrieval.query", "intent.parse", "intent.route", "policy.decide", "policy.approval", "execution.idempotent", "feedback.write", "state.snapshot", "inference.manifest"];
|
|
3
|
+
export type AsmCapability = (typeof ASM_CAPABILITIES)[number];
|
|
4
|
+
export interface ContractVersionRange {
|
|
5
|
+
major: number;
|
|
6
|
+
minMinor: number;
|
|
7
|
+
maxMinor: number;
|
|
8
|
+
}
|
|
9
|
+
export interface AsmPeerHello {
|
|
10
|
+
protocol: "asm-contracts";
|
|
11
|
+
protocolVersion: 1;
|
|
12
|
+
contracts: Partial<Record<AsmContractName, readonly ContractVersionRange[]>>;
|
|
13
|
+
capabilities: readonly AsmCapability[];
|
|
14
|
+
}
|
|
15
|
+
export interface NegotiatedContractVersion {
|
|
16
|
+
major: number;
|
|
17
|
+
minor: number;
|
|
18
|
+
}
|
|
19
|
+
export interface AsmNegotiationResult {
|
|
20
|
+
contracts: Partial<Record<AsmContractName, NegotiatedContractVersion>>;
|
|
21
|
+
capabilities: AsmCapability[];
|
|
22
|
+
}
|
|
23
|
+
export declare const DEFAULT_ASM_HELLO: AsmPeerHello;
|
|
24
|
+
export declare function negotiateAsmContracts(local: AsmPeerHello, remote: AsmPeerHello): AsmNegotiationResult;
|
|
25
|
+
export declare function requireNegotiatedCapability(result: AsmNegotiationResult, contract: AsmContractName, capability: AsmCapability): NegotiatedContractVersion;
|
|
26
|
+
//# sourceMappingURL=negotiation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negotiation.d.ts","sourceRoot":"","sources":["../src/negotiation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAE5F,eAAO,MAAM,gBAAgB,oOAanB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,MAAM,WAAW,oBAAoB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,eAAe,CAAC;IAC1B,eAAe,EAAE,CAAC,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,oBAAoB,EAAE,CAAC,CAAC,CAAC;IAC7E,YAAY,EAAE,SAAS,aAAa,EAAE,CAAC;CACvC;AAED,MAAM,WAAW,yBAAyB;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACpC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC,CAAC;IACvE,YAAY,EAAE,aAAa,EAAE,CAAC;CAC9B;AAED,eAAO,MAAM,iBAAiB,EAAE,YAkB/B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,oBAAoB,CAyBrG;AAED,wBAAgB,2BAA2B,CAC1C,MAAM,EAAE,oBAAoB,EAC5B,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,aAAa,GACvB,yBAAyB,CAK3B","sourcesContent":["import { ASM_CONTRACT_MAJOR, ASM_CONTRACT_MINOR, type AsmContractName } from \"./schemas.js\";\n\nexport const ASM_CAPABILITIES = [\n\t\"memory.read\",\n\t\"memory.write\",\n\t\"evidence.read\",\n\t\"retrieval.query\",\n\t\"intent.parse\",\n\t\"intent.route\",\n\t\"policy.decide\",\n\t\"policy.approval\",\n\t\"execution.idempotent\",\n\t\"feedback.write\",\n\t\"state.snapshot\",\n\t\"inference.manifest\",\n] as const;\n\nexport type AsmCapability = (typeof ASM_CAPABILITIES)[number];\n\nexport interface ContractVersionRange {\n\tmajor: number;\n\tminMinor: number;\n\tmaxMinor: number;\n}\n\nexport interface AsmPeerHello {\n\tprotocol: \"asm-contracts\";\n\tprotocolVersion: 1;\n\tcontracts: Partial<Record<AsmContractName, readonly ContractVersionRange[]>>;\n\tcapabilities: readonly AsmCapability[];\n}\n\nexport interface NegotiatedContractVersion {\n\tmajor: number;\n\tminor: number;\n}\n\nexport interface AsmNegotiationResult {\n\tcontracts: Partial<Record<AsmContractName, NegotiatedContractVersion>>;\n\tcapabilities: AsmCapability[];\n}\n\nexport const DEFAULT_ASM_HELLO: AsmPeerHello = {\n\tprotocol: \"asm-contracts\",\n\tprotocolVersion: 1,\n\tcontracts: Object.fromEntries(\n\t\t(\n\t\t\t[\n\t\t\t\t\"memory\",\n\t\t\t\t\"evidence\",\n\t\t\t\t\"retrieval\",\n\t\t\t\t\"intent\",\n\t\t\t\t\"policy\",\n\t\t\t\t\"feedback\",\n\t\t\t\t\"stateSnapshot\",\n\t\t\t\t\"inferenceManifest\",\n\t\t\t] as const\n\t\t).map((name) => [name, [{ major: ASM_CONTRACT_MAJOR, minMinor: 0, maxMinor: ASM_CONTRACT_MINOR }]]),\n\t),\n\tcapabilities: ASM_CAPABILITIES,\n};\n\nexport function negotiateAsmContracts(local: AsmPeerHello, remote: AsmPeerHello): AsmNegotiationResult {\n\tif (local.protocol !== remote.protocol || local.protocolVersion !== remote.protocolVersion) {\n\t\tthrow new Error(\"Incompatible ASM contract protocol\");\n\t}\n\tconst contracts: Partial<Record<AsmContractName, NegotiatedContractVersion>> = {};\n\tfor (const name of Object.keys(local.contracts) as AsmContractName[]) {\n\t\tconst localRanges = local.contracts[name] ?? [];\n\t\tconst remoteRanges = remote.contracts[name] ?? [];\n\t\tconst candidates: NegotiatedContractVersion[] = [];\n\t\tfor (const left of localRanges) {\n\t\t\tfor (const right of remoteRanges) {\n\t\t\t\tif (left.major !== right.major) continue;\n\t\t\t\tconst minMinor = Math.max(left.minMinor, right.minMinor);\n\t\t\t\tconst maxMinor = Math.min(left.maxMinor, right.maxMinor);\n\t\t\t\tif (minMinor <= maxMinor) candidates.push({ major: left.major, minor: maxMinor });\n\t\t\t}\n\t\t}\n\t\tcandidates.sort((left, right) => right.major - left.major || right.minor - left.minor);\n\t\tif (candidates[0]) contracts[name] = candidates[0];\n\t}\n\tconst remoteCapabilities = new Set(remote.capabilities);\n\treturn {\n\t\tcontracts,\n\t\tcapabilities: local.capabilities.filter((capability) => remoteCapabilities.has(capability)),\n\t};\n}\n\nexport function requireNegotiatedCapability(\n\tresult: AsmNegotiationResult,\n\tcontract: AsmContractName,\n\tcapability: AsmCapability,\n): NegotiatedContractVersion {\n\tconst version = result.contracts[contract];\n\tif (!version) throw new Error(`ASM contract not negotiated: ${contract}`);\n\tif (!result.capabilities.includes(capability)) throw new Error(`ASM capability not negotiated: ${capability}`);\n\treturn version;\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ASM_CONTRACT_MAJOR, ASM_CONTRACT_MINOR } from "./schemas.js";
|
|
2
|
+
export const ASM_CAPABILITIES = [
|
|
3
|
+
"memory.read",
|
|
4
|
+
"memory.write",
|
|
5
|
+
"evidence.read",
|
|
6
|
+
"retrieval.query",
|
|
7
|
+
"intent.parse",
|
|
8
|
+
"intent.route",
|
|
9
|
+
"policy.decide",
|
|
10
|
+
"policy.approval",
|
|
11
|
+
"execution.idempotent",
|
|
12
|
+
"feedback.write",
|
|
13
|
+
"state.snapshot",
|
|
14
|
+
"inference.manifest",
|
|
15
|
+
];
|
|
16
|
+
export const DEFAULT_ASM_HELLO = {
|
|
17
|
+
protocol: "asm-contracts",
|
|
18
|
+
protocolVersion: 1,
|
|
19
|
+
contracts: Object.fromEntries([
|
|
20
|
+
"memory",
|
|
21
|
+
"evidence",
|
|
22
|
+
"retrieval",
|
|
23
|
+
"intent",
|
|
24
|
+
"policy",
|
|
25
|
+
"feedback",
|
|
26
|
+
"stateSnapshot",
|
|
27
|
+
"inferenceManifest",
|
|
28
|
+
].map((name) => [name, [{ major: ASM_CONTRACT_MAJOR, minMinor: 0, maxMinor: ASM_CONTRACT_MINOR }]])),
|
|
29
|
+
capabilities: ASM_CAPABILITIES,
|
|
30
|
+
};
|
|
31
|
+
export function negotiateAsmContracts(local, remote) {
|
|
32
|
+
if (local.protocol !== remote.protocol || local.protocolVersion !== remote.protocolVersion) {
|
|
33
|
+
throw new Error("Incompatible ASM contract protocol");
|
|
34
|
+
}
|
|
35
|
+
const contracts = {};
|
|
36
|
+
for (const name of Object.keys(local.contracts)) {
|
|
37
|
+
const localRanges = local.contracts[name] ?? [];
|
|
38
|
+
const remoteRanges = remote.contracts[name] ?? [];
|
|
39
|
+
const candidates = [];
|
|
40
|
+
for (const left of localRanges) {
|
|
41
|
+
for (const right of remoteRanges) {
|
|
42
|
+
if (left.major !== right.major)
|
|
43
|
+
continue;
|
|
44
|
+
const minMinor = Math.max(left.minMinor, right.minMinor);
|
|
45
|
+
const maxMinor = Math.min(left.maxMinor, right.maxMinor);
|
|
46
|
+
if (minMinor <= maxMinor)
|
|
47
|
+
candidates.push({ major: left.major, minor: maxMinor });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
candidates.sort((left, right) => right.major - left.major || right.minor - left.minor);
|
|
51
|
+
if (candidates[0])
|
|
52
|
+
contracts[name] = candidates[0];
|
|
53
|
+
}
|
|
54
|
+
const remoteCapabilities = new Set(remote.capabilities);
|
|
55
|
+
return {
|
|
56
|
+
contracts,
|
|
57
|
+
capabilities: local.capabilities.filter((capability) => remoteCapabilities.has(capability)),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function requireNegotiatedCapability(result, contract, capability) {
|
|
61
|
+
const version = result.contracts[contract];
|
|
62
|
+
if (!version)
|
|
63
|
+
throw new Error(`ASM contract not negotiated: ${contract}`);
|
|
64
|
+
if (!result.capabilities.includes(capability))
|
|
65
|
+
throw new Error(`ASM capability not negotiated: ${capability}`);
|
|
66
|
+
return version;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=negotiation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negotiation.js","sourceRoot":"","sources":["../src/negotiation.ts"],"names":[],"mappings":"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","sourcesContent":["import { ASM_CONTRACT_MAJOR, ASM_CONTRACT_MINOR, type AsmContractName } from \"./schemas.js\";\n\nexport const ASM_CAPABILITIES = [\n\t\"memory.read\",\n\t\"memory.write\",\n\t\"evidence.read\",\n\t\"retrieval.query\",\n\t\"intent.parse\",\n\t\"intent.route\",\n\t\"policy.decide\",\n\t\"policy.approval\",\n\t\"execution.idempotent\",\n\t\"feedback.write\",\n\t\"state.snapshot\",\n\t\"inference.manifest\",\n] as const;\n\nexport type AsmCapability = (typeof ASM_CAPABILITIES)[number];\n\nexport interface ContractVersionRange {\n\tmajor: number;\n\tminMinor: number;\n\tmaxMinor: number;\n}\n\nexport interface AsmPeerHello {\n\tprotocol: \"asm-contracts\";\n\tprotocolVersion: 1;\n\tcontracts: Partial<Record<AsmContractName, readonly ContractVersionRange[]>>;\n\tcapabilities: readonly AsmCapability[];\n}\n\nexport interface NegotiatedContractVersion {\n\tmajor: number;\n\tminor: number;\n}\n\nexport interface AsmNegotiationResult {\n\tcontracts: Partial<Record<AsmContractName, NegotiatedContractVersion>>;\n\tcapabilities: AsmCapability[];\n}\n\nexport const DEFAULT_ASM_HELLO: AsmPeerHello = {\n\tprotocol: \"asm-contracts\",\n\tprotocolVersion: 1,\n\tcontracts: Object.fromEntries(\n\t\t(\n\t\t\t[\n\t\t\t\t\"memory\",\n\t\t\t\t\"evidence\",\n\t\t\t\t\"retrieval\",\n\t\t\t\t\"intent\",\n\t\t\t\t\"policy\",\n\t\t\t\t\"feedback\",\n\t\t\t\t\"stateSnapshot\",\n\t\t\t\t\"inferenceManifest\",\n\t\t\t] as const\n\t\t).map((name) => [name, [{ major: ASM_CONTRACT_MAJOR, minMinor: 0, maxMinor: ASM_CONTRACT_MINOR }]]),\n\t),\n\tcapabilities: ASM_CAPABILITIES,\n};\n\nexport function negotiateAsmContracts(local: AsmPeerHello, remote: AsmPeerHello): AsmNegotiationResult {\n\tif (local.protocol !== remote.protocol || local.protocolVersion !== remote.protocolVersion) {\n\t\tthrow new Error(\"Incompatible ASM contract protocol\");\n\t}\n\tconst contracts: Partial<Record<AsmContractName, NegotiatedContractVersion>> = {};\n\tfor (const name of Object.keys(local.contracts) as AsmContractName[]) {\n\t\tconst localRanges = local.contracts[name] ?? [];\n\t\tconst remoteRanges = remote.contracts[name] ?? [];\n\t\tconst candidates: NegotiatedContractVersion[] = [];\n\t\tfor (const left of localRanges) {\n\t\t\tfor (const right of remoteRanges) {\n\t\t\t\tif (left.major !== right.major) continue;\n\t\t\t\tconst minMinor = Math.max(left.minMinor, right.minMinor);\n\t\t\t\tconst maxMinor = Math.min(left.maxMinor, right.maxMinor);\n\t\t\t\tif (minMinor <= maxMinor) candidates.push({ major: left.major, minor: maxMinor });\n\t\t\t}\n\t\t}\n\t\tcandidates.sort((left, right) => right.major - left.major || right.minor - left.minor);\n\t\tif (candidates[0]) contracts[name] = candidates[0];\n\t}\n\tconst remoteCapabilities = new Set(remote.capabilities);\n\treturn {\n\t\tcontracts,\n\t\tcapabilities: local.capabilities.filter((capability) => remoteCapabilities.has(capability)),\n\t};\n}\n\nexport function requireNegotiatedCapability(\n\tresult: AsmNegotiationResult,\n\tcontract: AsmContractName,\n\tcapability: AsmCapability,\n): NegotiatedContractVersion {\n\tconst version = result.contracts[contract];\n\tif (!version) throw new Error(`ASM contract not negotiated: ${contract}`);\n\tif (!result.capabilities.includes(capability)) throw new Error(`ASM capability not negotiated: ${capability}`);\n\treturn version;\n}\n"]}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { type Static, Type } from "typebox";
|
|
2
|
+
export declare const ASM_CONTRACT_NAMESPACE: "ai.aletheion.asm";
|
|
3
|
+
export declare const ASM_CONTRACT_MAJOR: 1;
|
|
4
|
+
export declare const ASM_CONTRACT_MINOR: 1;
|
|
5
|
+
export declare const MemoryContractSchema: Type.TObject<{
|
|
6
|
+
header: Type.TObject<{
|
|
7
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
8
|
+
major: Type.TLiteral<1>;
|
|
9
|
+
minor: Type.TInteger;
|
|
10
|
+
}>;
|
|
11
|
+
memoryId: Type.TString;
|
|
12
|
+
revision: Type.TInteger;
|
|
13
|
+
ownerId: Type.TString;
|
|
14
|
+
projectId: Type.TString;
|
|
15
|
+
sessionId: Type.TOptional<Type.TString>;
|
|
16
|
+
kind: Type.TUnion<[Type.TLiteral<"observation">, Type.TLiteral<"fact">, Type.TLiteral<"instruction">]>;
|
|
17
|
+
content: Type.TString;
|
|
18
|
+
evidenceIds: Type.TArray<Type.TString>;
|
|
19
|
+
createdAt: Type.TString;
|
|
20
|
+
tombstonedAt: Type.TOptional<Type.TString>;
|
|
21
|
+
metadata: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const EvidenceContractSchema: Type.TObject<{
|
|
24
|
+
header: Type.TObject<{
|
|
25
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
26
|
+
major: Type.TLiteral<1>;
|
|
27
|
+
minor: Type.TInteger;
|
|
28
|
+
}>;
|
|
29
|
+
evidenceId: Type.TString;
|
|
30
|
+
ownerId: Type.TString;
|
|
31
|
+
projectId: Type.TString;
|
|
32
|
+
sourceType: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"tool">, Type.TLiteral<"document">, Type.TLiteral<"system">]>;
|
|
33
|
+
sourceUri: Type.TOptional<Type.TString>;
|
|
34
|
+
digest: Type.TString;
|
|
35
|
+
capturedAt: Type.TString;
|
|
36
|
+
contentType: Type.TString;
|
|
37
|
+
metadata: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
38
|
+
}>;
|
|
39
|
+
export declare const RetrievalContractSchema: Type.TObject<{
|
|
40
|
+
header: Type.TObject<{
|
|
41
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
42
|
+
major: Type.TLiteral<1>;
|
|
43
|
+
minor: Type.TInteger;
|
|
44
|
+
}>;
|
|
45
|
+
requestId: Type.TString;
|
|
46
|
+
ownerId: Type.TString;
|
|
47
|
+
projectId: Type.TString;
|
|
48
|
+
sessionId: Type.TOptional<Type.TString>;
|
|
49
|
+
query: Type.TString;
|
|
50
|
+
limit: Type.TInteger;
|
|
51
|
+
algorithm: Type.TString;
|
|
52
|
+
candidates: Type.TArray<Type.TObject<{
|
|
53
|
+
memoryId: Type.TString;
|
|
54
|
+
score: Type.TNumber;
|
|
55
|
+
selected: Type.TBoolean;
|
|
56
|
+
reasonCodes: Type.TArray<Type.TString>;
|
|
57
|
+
}>>;
|
|
58
|
+
startedAt: Type.TString;
|
|
59
|
+
latencyMs: Type.TInteger;
|
|
60
|
+
}>;
|
|
61
|
+
export declare const IntentContractSchema: Type.TObject<{
|
|
62
|
+
header: Type.TObject<{
|
|
63
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
64
|
+
major: Type.TLiteral<1>;
|
|
65
|
+
minor: Type.TInteger;
|
|
66
|
+
}>;
|
|
67
|
+
intentId: Type.TString;
|
|
68
|
+
operation: Type.TUnion<[Type.TLiteral<"diagnose">, Type.TLiteral<"read">, Type.TLiteral<"write">, Type.TLiteral<"execute">, Type.TLiteral<"communicate">, Type.TLiteral<"deploy">, Type.TLiteral<"purchase">, Type.TLiteral<"delete">]>;
|
|
69
|
+
resources: Type.TArray<Type.TString>;
|
|
70
|
+
externalEffect: Type.TBoolean;
|
|
71
|
+
idempotencyKey: Type.TOptional<Type.TString>;
|
|
72
|
+
requestedAt: Type.TString;
|
|
73
|
+
arguments: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
74
|
+
}>;
|
|
75
|
+
export declare const PolicyContractSchema: Type.TObject<{
|
|
76
|
+
header: Type.TObject<{
|
|
77
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
78
|
+
major: Type.TLiteral<1>;
|
|
79
|
+
minor: Type.TInteger;
|
|
80
|
+
}>;
|
|
81
|
+
decisionId: Type.TString;
|
|
82
|
+
intentId: Type.TString;
|
|
83
|
+
outcome: Type.TUnion<[Type.TLiteral<"allow">, Type.TLiteral<"deny">, Type.TLiteral<"require_approval">]>;
|
|
84
|
+
reasonCodes: Type.TArray<Type.TString>;
|
|
85
|
+
requiredApprovals: Type.TArray<Type.TString>;
|
|
86
|
+
decidedAt: Type.TString;
|
|
87
|
+
policyVersion: Type.TString;
|
|
88
|
+
}>;
|
|
89
|
+
export declare const FeedbackContractSchema: Type.TObject<{
|
|
90
|
+
header: Type.TObject<{
|
|
91
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
92
|
+
major: Type.TLiteral<1>;
|
|
93
|
+
minor: Type.TInteger;
|
|
94
|
+
}>;
|
|
95
|
+
feedbackId: Type.TString;
|
|
96
|
+
targetType: Type.TUnion<[Type.TLiteral<"memory">, Type.TLiteral<"retrieval">, Type.TLiteral<"action">]>;
|
|
97
|
+
targetId: Type.TString;
|
|
98
|
+
rating: Type.TUnion<[Type.TLiteral<"positive">, Type.TLiteral<"negative">, Type.TLiteral<"correction">]>;
|
|
99
|
+
comment: Type.TOptional<Type.TString>;
|
|
100
|
+
createdAt: Type.TString;
|
|
101
|
+
}>;
|
|
102
|
+
export declare const StateSnapshotContractSchema: Type.TObject<{
|
|
103
|
+
header: Type.TObject<{
|
|
104
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
105
|
+
major: Type.TLiteral<1>;
|
|
106
|
+
minor: Type.TInteger;
|
|
107
|
+
}>;
|
|
108
|
+
snapshotId: Type.TString;
|
|
109
|
+
sessionId: Type.TString;
|
|
110
|
+
sequence: Type.TInteger;
|
|
111
|
+
state: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
112
|
+
digest: Type.TString;
|
|
113
|
+
createdAt: Type.TString;
|
|
114
|
+
}>;
|
|
115
|
+
export declare const InferenceManifestContractSchema: Type.TObject<{
|
|
116
|
+
header: Type.TObject<{
|
|
117
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
118
|
+
major: Type.TLiteral<1>;
|
|
119
|
+
minor: Type.TInteger;
|
|
120
|
+
}>;
|
|
121
|
+
manifestId: Type.TString;
|
|
122
|
+
modelId: Type.TString;
|
|
123
|
+
modelVersion: Type.TString;
|
|
124
|
+
backend: Type.TUnion<[Type.TLiteral<"deterministic">, Type.TLiteral<"vector">, Type.TLiteral<"causal_head">, Type.TLiteral<"dual_asm">, Type.TLiteral<"asm_cm">]>;
|
|
125
|
+
artifactDigest: Type.TOptional<Type.TString>;
|
|
126
|
+
contractMajors: Type.TRecord<"^.*$", Type.TInteger>;
|
|
127
|
+
parameters: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
128
|
+
createdAt: Type.TString;
|
|
129
|
+
}>;
|
|
130
|
+
export declare const ASM_CONTRACT_SCHEMAS: {
|
|
131
|
+
readonly memory: Type.TObject<{
|
|
132
|
+
header: Type.TObject<{
|
|
133
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
134
|
+
major: Type.TLiteral<1>;
|
|
135
|
+
minor: Type.TInteger;
|
|
136
|
+
}>;
|
|
137
|
+
memoryId: Type.TString;
|
|
138
|
+
revision: Type.TInteger;
|
|
139
|
+
ownerId: Type.TString;
|
|
140
|
+
projectId: Type.TString;
|
|
141
|
+
sessionId: Type.TOptional<Type.TString>;
|
|
142
|
+
kind: Type.TUnion<[Type.TLiteral<"observation">, Type.TLiteral<"fact">, Type.TLiteral<"instruction">]>;
|
|
143
|
+
content: Type.TString;
|
|
144
|
+
evidenceIds: Type.TArray<Type.TString>;
|
|
145
|
+
createdAt: Type.TString;
|
|
146
|
+
tombstonedAt: Type.TOptional<Type.TString>;
|
|
147
|
+
metadata: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
148
|
+
}>;
|
|
149
|
+
readonly evidence: Type.TObject<{
|
|
150
|
+
header: Type.TObject<{
|
|
151
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
152
|
+
major: Type.TLiteral<1>;
|
|
153
|
+
minor: Type.TInteger;
|
|
154
|
+
}>;
|
|
155
|
+
evidenceId: Type.TString;
|
|
156
|
+
ownerId: Type.TString;
|
|
157
|
+
projectId: Type.TString;
|
|
158
|
+
sourceType: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"tool">, Type.TLiteral<"document">, Type.TLiteral<"system">]>;
|
|
159
|
+
sourceUri: Type.TOptional<Type.TString>;
|
|
160
|
+
digest: Type.TString;
|
|
161
|
+
capturedAt: Type.TString;
|
|
162
|
+
contentType: Type.TString;
|
|
163
|
+
metadata: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
164
|
+
}>;
|
|
165
|
+
readonly retrieval: Type.TObject<{
|
|
166
|
+
header: Type.TObject<{
|
|
167
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
168
|
+
major: Type.TLiteral<1>;
|
|
169
|
+
minor: Type.TInteger;
|
|
170
|
+
}>;
|
|
171
|
+
requestId: Type.TString;
|
|
172
|
+
ownerId: Type.TString;
|
|
173
|
+
projectId: Type.TString;
|
|
174
|
+
sessionId: Type.TOptional<Type.TString>;
|
|
175
|
+
query: Type.TString;
|
|
176
|
+
limit: Type.TInteger;
|
|
177
|
+
algorithm: Type.TString;
|
|
178
|
+
candidates: Type.TArray<Type.TObject<{
|
|
179
|
+
memoryId: Type.TString;
|
|
180
|
+
score: Type.TNumber;
|
|
181
|
+
selected: Type.TBoolean;
|
|
182
|
+
reasonCodes: Type.TArray<Type.TString>;
|
|
183
|
+
}>>;
|
|
184
|
+
startedAt: Type.TString;
|
|
185
|
+
latencyMs: Type.TInteger;
|
|
186
|
+
}>;
|
|
187
|
+
readonly intent: Type.TObject<{
|
|
188
|
+
header: Type.TObject<{
|
|
189
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
190
|
+
major: Type.TLiteral<1>;
|
|
191
|
+
minor: Type.TInteger;
|
|
192
|
+
}>;
|
|
193
|
+
intentId: Type.TString;
|
|
194
|
+
operation: Type.TUnion<[Type.TLiteral<"diagnose">, Type.TLiteral<"read">, Type.TLiteral<"write">, Type.TLiteral<"execute">, Type.TLiteral<"communicate">, Type.TLiteral<"deploy">, Type.TLiteral<"purchase">, Type.TLiteral<"delete">]>;
|
|
195
|
+
resources: Type.TArray<Type.TString>;
|
|
196
|
+
externalEffect: Type.TBoolean;
|
|
197
|
+
idempotencyKey: Type.TOptional<Type.TString>;
|
|
198
|
+
requestedAt: Type.TString;
|
|
199
|
+
arguments: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
200
|
+
}>;
|
|
201
|
+
readonly policy: Type.TObject<{
|
|
202
|
+
header: Type.TObject<{
|
|
203
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
204
|
+
major: Type.TLiteral<1>;
|
|
205
|
+
minor: Type.TInteger;
|
|
206
|
+
}>;
|
|
207
|
+
decisionId: Type.TString;
|
|
208
|
+
intentId: Type.TString;
|
|
209
|
+
outcome: Type.TUnion<[Type.TLiteral<"allow">, Type.TLiteral<"deny">, Type.TLiteral<"require_approval">]>;
|
|
210
|
+
reasonCodes: Type.TArray<Type.TString>;
|
|
211
|
+
requiredApprovals: Type.TArray<Type.TString>;
|
|
212
|
+
decidedAt: Type.TString;
|
|
213
|
+
policyVersion: Type.TString;
|
|
214
|
+
}>;
|
|
215
|
+
readonly feedback: Type.TObject<{
|
|
216
|
+
header: Type.TObject<{
|
|
217
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
218
|
+
major: Type.TLiteral<1>;
|
|
219
|
+
minor: Type.TInteger;
|
|
220
|
+
}>;
|
|
221
|
+
feedbackId: Type.TString;
|
|
222
|
+
targetType: Type.TUnion<[Type.TLiteral<"memory">, Type.TLiteral<"retrieval">, Type.TLiteral<"action">]>;
|
|
223
|
+
targetId: Type.TString;
|
|
224
|
+
rating: Type.TUnion<[Type.TLiteral<"positive">, Type.TLiteral<"negative">, Type.TLiteral<"correction">]>;
|
|
225
|
+
comment: Type.TOptional<Type.TString>;
|
|
226
|
+
createdAt: Type.TString;
|
|
227
|
+
}>;
|
|
228
|
+
readonly stateSnapshot: Type.TObject<{
|
|
229
|
+
header: Type.TObject<{
|
|
230
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
231
|
+
major: Type.TLiteral<1>;
|
|
232
|
+
minor: Type.TInteger;
|
|
233
|
+
}>;
|
|
234
|
+
snapshotId: Type.TString;
|
|
235
|
+
sessionId: Type.TString;
|
|
236
|
+
sequence: Type.TInteger;
|
|
237
|
+
state: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
238
|
+
digest: Type.TString;
|
|
239
|
+
createdAt: Type.TString;
|
|
240
|
+
}>;
|
|
241
|
+
readonly inferenceManifest: Type.TObject<{
|
|
242
|
+
header: Type.TObject<{
|
|
243
|
+
namespace: Type.TLiteral<"ai.aletheion.asm">;
|
|
244
|
+
major: Type.TLiteral<1>;
|
|
245
|
+
minor: Type.TInteger;
|
|
246
|
+
}>;
|
|
247
|
+
manifestId: Type.TString;
|
|
248
|
+
modelId: Type.TString;
|
|
249
|
+
modelVersion: Type.TString;
|
|
250
|
+
backend: Type.TUnion<[Type.TLiteral<"deterministic">, Type.TLiteral<"vector">, Type.TLiteral<"causal_head">, Type.TLiteral<"dual_asm">, Type.TLiteral<"asm_cm">]>;
|
|
251
|
+
artifactDigest: Type.TOptional<Type.TString>;
|
|
252
|
+
contractMajors: Type.TRecord<"^.*$", Type.TInteger>;
|
|
253
|
+
parameters: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
254
|
+
createdAt: Type.TString;
|
|
255
|
+
}>;
|
|
256
|
+
};
|
|
257
|
+
export type AsmContractName = keyof typeof ASM_CONTRACT_SCHEMAS;
|
|
258
|
+
export type MemoryContract = Static<typeof MemoryContractSchema>;
|
|
259
|
+
export type EvidenceContract = Static<typeof EvidenceContractSchema>;
|
|
260
|
+
export type RetrievalContract = Static<typeof RetrievalContractSchema>;
|
|
261
|
+
export type IntentContract = Static<typeof IntentContractSchema>;
|
|
262
|
+
export type PolicyContract = Static<typeof PolicyContractSchema>;
|
|
263
|
+
export type FeedbackContract = Static<typeof FeedbackContractSchema>;
|
|
264
|
+
export type StateSnapshotContract = Static<typeof StateSnapshotContractSchema>;
|
|
265
|
+
export type InferenceManifestContract = Static<typeof InferenceManifestContractSchema>;
|
|
266
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,sBAAsB,oBAA8B,CAAC;AAClE,eAAO,MAAM,kBAAkB,GAAa,CAAC;AAC7C,eAAO,MAAM,kBAAkB,GAAa,CAAC;AAgB7C,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;EAgBhC,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;EAmBlC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;EAyBnC,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;EAqBhC,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;EAYhC,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;EAWlC,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;EAWvC,CAAC;AAEF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;EAmB3C,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CASvB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,oBAAoB,CAAC;AAChE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACjE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACrE,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACvE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACjE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACjE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACrE,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAC/E,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,OAAO,+BAA+B,CAAC,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"]}
|