holarchy-eidolon-adapter 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "holarchy-eidolon-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Eidolon ResourcePackage adapter for frozen Holarchy organization snapshots and execution bindings.",
|
|
6
6
|
"type": "module",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"test": "bun test"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"ai-workflow-contract": "0.
|
|
23
|
+
"ai-workflow-contract": "0.2.0",
|
|
24
24
|
"depa-actor": "0.2.2",
|
|
25
|
-
"halfcode-compiler.xnl": "0.
|
|
26
|
-
"holarchy-core-contract": "0.
|
|
25
|
+
"halfcode-compiler.xnl": "0.3.0",
|
|
26
|
+
"holarchy-core-contract": "0.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"typescript": "^5.4.0"
|
|
@@ -232,13 +232,13 @@ function session(value: unknown, location: string): HolonGenericSessionRef {
|
|
|
232
232
|
if (mode === "targeted-agent-instance") {
|
|
233
233
|
exactKeys(record, ["mode", "selector", "sessionRef"], location)
|
|
234
234
|
const selectorRecord = closedObject(record.selector, `${location}.selector`)
|
|
235
|
-
const hasId = Object.prototype.hasOwnProperty.call(selectorRecord, "
|
|
236
|
-
const hasName = Object.prototype.hasOwnProperty.call(selectorRecord, "
|
|
235
|
+
const hasId = Object.prototype.hasOwnProperty.call(selectorRecord, "byId")
|
|
236
|
+
const hasName = Object.prototype.hasOwnProperty.call(selectorRecord, "byName")
|
|
237
237
|
if (hasId === hasName) invalid(`${location}.selector`, "Expected exactly one targeted Agent selector")
|
|
238
|
-
exactKeys(selectorRecord, [hasId ? "
|
|
239
|
-
const selector
|
|
240
|
-
? Object.freeze({
|
|
241
|
-
: Object.freeze({
|
|
238
|
+
exactKeys(selectorRecord, [hasId ? "byId" : "byName"], `${location}.selector`)
|
|
239
|
+
const selector = (hasId
|
|
240
|
+
? Object.freeze({ byId: exactString(selectorRecord.byId, `${location}.selector.byId`) })
|
|
241
|
+
: Object.freeze({ byName: exactString(selectorRecord.byName, `${location}.selector.byName`) })) as unknown as AIAgentSelector
|
|
242
242
|
return Object.freeze({
|
|
243
243
|
mode,
|
|
244
244
|
selector,
|
|
@@ -1,19 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
digestCanonical,
|
|
3
|
+
type JsonSchema,
|
|
4
|
+
type KindReaderRegistration,
|
|
5
|
+
type KindSemanticContract,
|
|
6
|
+
type PortableSpec,
|
|
7
|
+
} from "halfcode-compiler.xnl/resource-core"
|
|
8
|
+
import {
|
|
9
|
+
createKindSpecRevision,
|
|
10
|
+
createKindSubjectOwner,
|
|
11
|
+
} from "halfcode-compiler.xnl/kind-definition"
|
|
12
|
+
|
|
1
13
|
export const HOLON_EXECUTION_BINDING_KIND = "HolonExecutionBinding" as const
|
|
2
14
|
export const HOLON_EXECUTION_BINDING_KIND_DEFINITION_FQN =
|
|
3
15
|
"Eidolon.AI.KindDefinition.HolonExecutionBinding" as const
|
|
4
16
|
export const HOLON_EXECUTION_BINDING_API_VERSION = "eidolon.ai/v1" as const
|
|
5
|
-
export const
|
|
17
|
+
export const HOLON_EXECUTION_BINDING_KIND_DEFINITION_SPEC_VERSION = 1 as const
|
|
18
|
+
export const HOLON_EXECUTION_BINDING_KIND_OWNER_PACKAGE_ID =
|
|
19
|
+
"holarchy-eidolon-adapter" as const
|
|
20
|
+
|
|
21
|
+
export const HOLON_EXECUTION_BINDING_KIND_OWNER_PACKAGE_FINGERPRINT = digestCanonical(Object.freeze({
|
|
22
|
+
authority: "holarchy-eidolon-adapter/holon-execution-binding-kind/v1",
|
|
23
|
+
ownerPackageId: HOLON_EXECUTION_BINDING_KIND_OWNER_PACKAGE_ID,
|
|
24
|
+
subjects: Object.freeze([HOLON_EXECUTION_BINDING_KIND_DEFINITION_FQN]),
|
|
25
|
+
semanticContractVersion: HOLON_EXECUTION_BINDING_API_VERSION,
|
|
26
|
+
}))
|
|
27
|
+
|
|
28
|
+
export const HOLON_EXECUTION_BINDING_KIND_OWNER = createKindSubjectOwner({
|
|
29
|
+
kind: HOLON_EXECUTION_BINDING_KIND,
|
|
30
|
+
subjectFqn: HOLON_EXECUTION_BINDING_KIND_DEFINITION_FQN,
|
|
31
|
+
ownerPackageId: HOLON_EXECUTION_BINDING_KIND_OWNER_PACKAGE_ID,
|
|
32
|
+
ownerPackageFingerprint: HOLON_EXECUTION_BINDING_KIND_OWNER_PACKAGE_FINGERPRINT,
|
|
33
|
+
sourceShapes: Object.freeze(["single-file"]),
|
|
34
|
+
documentCardinality: "one",
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export const HOLON_EXECUTION_BINDING_SPEC_SCHEMA_V1: JsonSchema = Object.freeze({
|
|
38
|
+
type: "object",
|
|
39
|
+
required: Object.freeze(["properties", "body", "subdomains"]),
|
|
40
|
+
properties: Object.freeze({
|
|
41
|
+
properties: Object.freeze({
|
|
42
|
+
type: "object",
|
|
43
|
+
required: Object.freeze(["bindingBytesBase64"]),
|
|
44
|
+
properties: Object.freeze({
|
|
45
|
+
bindingBytesBase64: Object.freeze({ type: "string", minLength: 1 }),
|
|
46
|
+
}),
|
|
47
|
+
additionalProperties: false,
|
|
48
|
+
}),
|
|
49
|
+
body: Object.freeze({ type: "array", maxItems: 0 }),
|
|
50
|
+
subdomains: Object.freeze({ type: "object", maxProperties: 0 }),
|
|
51
|
+
}),
|
|
52
|
+
additionalProperties: false,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
export const HOLON_EXECUTION_BINDING_SEMANTIC_CONTRACT_V1: KindSemanticContract = Object.freeze({
|
|
56
|
+
semanticValidatorFingerprint: digestCanonical(Object.freeze({
|
|
57
|
+
authority: "holarchy-eidolon-adapter/holon-execution-binding-kind/v1",
|
|
58
|
+
role: "canonical-binding-and-graph-validation",
|
|
59
|
+
apiVersion: HOLON_EXECUTION_BINDING_API_VERSION,
|
|
60
|
+
validators: Object.freeze([
|
|
61
|
+
"parseHolonExecutionBindingBytes",
|
|
62
|
+
"validateHolonExecutionBindingGraph",
|
|
63
|
+
]),
|
|
64
|
+
})),
|
|
65
|
+
referenceProjectionFingerprint: digestCanonical(Object.freeze({
|
|
66
|
+
authority: "holarchy-eidolon-adapter/holon-execution-binding-kind/v1",
|
|
67
|
+
role: "closed-execution-binding-reference-projection",
|
|
68
|
+
fields: Object.freeze([
|
|
69
|
+
"snapshotRef",
|
|
70
|
+
"adapter",
|
|
71
|
+
"policy.taskProfileRef",
|
|
72
|
+
"policy.capabilityRefs",
|
|
73
|
+
"policy.toolRefs",
|
|
74
|
+
"policy.materialRefs",
|
|
75
|
+
]),
|
|
76
|
+
})),
|
|
77
|
+
compilerInputFingerprint: digestCanonical(Object.freeze({
|
|
78
|
+
authority: "holarchy-eidolon-adapter/holon-execution-binding-kind/v1",
|
|
79
|
+
role: "authored-resource-to-canonical-binding-input",
|
|
80
|
+
fields: Object.freeze(["properties.bindingBytesBase64"]),
|
|
81
|
+
encoding: "canonical-base64",
|
|
82
|
+
})),
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
export const HOLON_EXECUTION_BINDING_KIND_SPEC_REVISION_V1 = createKindSpecRevision({
|
|
86
|
+
kind: HOLON_EXECUTION_BINDING_KIND_OWNER.kind,
|
|
87
|
+
subjectFqn: HOLON_EXECUTION_BINDING_KIND_OWNER.subjectFqn,
|
|
88
|
+
specVersion: HOLON_EXECUTION_BINDING_KIND_DEFINITION_SPEC_VERSION,
|
|
89
|
+
specSchema: HOLON_EXECUTION_BINDING_SPEC_SCHEMA_V1,
|
|
90
|
+
semanticContract: HOLON_EXECUTION_BINDING_SEMANTIC_CONTRACT_V1,
|
|
91
|
+
sourceContractFingerprint: HOLON_EXECUTION_BINDING_KIND_OWNER.sourceContract.sourceContractFingerprint,
|
|
92
|
+
stability: "stable",
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
function renderHolonExecutionBindingKindDefinition(): string {
|
|
96
|
+
const owner = HOLON_EXECUTION_BINDING_KIND_OWNER
|
|
97
|
+
const revision = HOLON_EXECUTION_BINDING_KIND_SPEC_REVISION_V1
|
|
98
|
+
return [
|
|
99
|
+
`<KindDefinition #${HOLON_EXECUTION_BINDING_KIND_DEFINITION_FQN} envelopeVersion="halfcode.resource-envelope/v1" specVersion=1 {`,
|
|
100
|
+
' lifecycle = "Stable"',
|
|
101
|
+
` resourceKind = "${owner.kind}"`,
|
|
102
|
+
` subjectFqn = "${owner.subjectFqn}"`,
|
|
103
|
+
' sourceShapes = ["single-file"]',
|
|
104
|
+
` documentCardinality = "${owner.sourceContract.documentCardinality}"`,
|
|
105
|
+
' description = "Maps one frozen Holon Member or Role identity to an exact Eidolon execution adapter closure."',
|
|
106
|
+
'} (',
|
|
107
|
+
' <SpecRevisions [',
|
|
108
|
+
` <SpecRevision #v${revision.specVersion} {`,
|
|
109
|
+
` specVersion = ${revision.specVersion}`,
|
|
110
|
+
' schemaRef = "vfs://./spec-v1.schema.json"',
|
|
111
|
+
` schemaFingerprint = "${revision.schemaFingerprint}"`,
|
|
112
|
+
` contractFingerprint = "${revision.contractFingerprint}"`,
|
|
113
|
+
` semanticValidatorFingerprint = "${revision.semanticContract.semanticValidatorFingerprint}"`,
|
|
114
|
+
` referenceProjectionFingerprint = "${revision.semanticContract.referenceProjectionFingerprint}"`,
|
|
115
|
+
` compilerInputFingerprint = "${revision.semanticContract.compilerInputFingerprint}"`,
|
|
116
|
+
` stability = "${revision.stability}"`,
|
|
117
|
+
' }>',
|
|
118
|
+
' ]>',
|
|
119
|
+
')>',
|
|
120
|
+
'',
|
|
121
|
+
].join("\n")
|
|
122
|
+
}
|
|
6
123
|
|
|
7
124
|
export const HOLON_EXECUTION_BINDING_KIND_DEFINITION_SOURCE =
|
|
8
|
-
|
|
9
|
-
lifecycle = "Stable"
|
|
10
|
-
resourceKind = "HolonExecutionBinding"
|
|
11
|
-
sourceShapes = ["single-file"]
|
|
12
|
-
currentApiVersion = "eidolon.ai/v1"
|
|
13
|
-
supportedApiVersions = ["eidolon.ai/v1"]
|
|
14
|
-
description = "Maps one frozen Holon Member or Role identity to an exact Eidolon execution adapter closure."
|
|
15
|
-
}>
|
|
16
|
-
` as const
|
|
125
|
+
renderHolonExecutionBindingKindDefinition()
|
|
17
126
|
|
|
18
127
|
export const HOLON_EXECUTION_BINDING_KIND_DEFINITION_BYTES: Readonly<Uint8Array> =
|
|
19
128
|
new TextEncoder().encode(HOLON_EXECUTION_BINDING_KIND_DEFINITION_SOURCE)
|
|
@@ -331,6 +440,41 @@ export function parseHolonExecutionBindingBytes(bytes: Uint8Array): HolonExecuti
|
|
|
331
440
|
return binding
|
|
332
441
|
}
|
|
333
442
|
|
|
443
|
+
function canonicalBase64SpecBytes(spec: PortableSpec, property: string): Uint8Array {
|
|
444
|
+
const properties = closedObject(spec.properties, "$.properties")
|
|
445
|
+
exactKeys(properties, [property], "$.properties")
|
|
446
|
+
const value = exactString(properties[property], `$.properties.${property}`)
|
|
447
|
+
let bytes: Uint8Array
|
|
448
|
+
try {
|
|
449
|
+
bytes = Uint8Array.from(Buffer.from(value, "base64"))
|
|
450
|
+
} catch {
|
|
451
|
+
return invalid(`$.properties.${property}`, "Expected canonical base64")
|
|
452
|
+
}
|
|
453
|
+
if (bytes.byteLength === 0 || Buffer.from(bytes).toString("base64") !== value) {
|
|
454
|
+
return invalid(`$.properties.${property}`, "Expected canonical non-empty base64")
|
|
455
|
+
}
|
|
456
|
+
return bytes
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export const HOLON_EXECUTION_BINDING_KIND_READER_REGISTRATION_V1:
|
|
460
|
+
KindReaderRegistration<HolonExecutionBinding> = Object.freeze({
|
|
461
|
+
readerId: "holarchy-eidolon-adapter.holon-execution-binding.v1",
|
|
462
|
+
subjectFqn: HOLON_EXECUTION_BINDING_KIND_DEFINITION_FQN,
|
|
463
|
+
readerSpecVersion: HOLON_EXECUTION_BINDING_KIND_DEFINITION_SPEC_VERSION,
|
|
464
|
+
contractFingerprint: HOLON_EXECUTION_BINDING_KIND_SPEC_REVISION_V1.contractFingerprint,
|
|
465
|
+
readerImplementationFingerprint: digestCanonical(Object.freeze({
|
|
466
|
+
authority: "holarchy-eidolon-adapter/holon-execution-binding-reader/v1",
|
|
467
|
+
implementation: Object.freeze([
|
|
468
|
+
"canonicalBase64SpecBytes",
|
|
469
|
+
"parseHolonExecutionBindingBytes",
|
|
470
|
+
]),
|
|
471
|
+
})),
|
|
472
|
+
compatibilityPolicy: "exact",
|
|
473
|
+
read: (spec: PortableSpec) => parseHolonExecutionBindingBytes(
|
|
474
|
+
canonicalBase64SpecBytes(spec, "bindingBytesBase64"),
|
|
475
|
+
),
|
|
476
|
+
})
|
|
477
|
+
|
|
334
478
|
export function validateHolonExecutionBindingGraph(
|
|
335
479
|
values: readonly HolonExecutionBinding[],
|
|
336
480
|
): readonly HolonExecutionBinding[] {
|