@weaveintel/core 0.0.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/README.md +62 -89
- package/dist/admin-capabilities.d.ts +1 -1
- package/dist/admin-capabilities.js +1 -1
- package/dist/capability-packs/index.d.ts +18 -0
- package/dist/capability-packs/index.d.ts.map +1 -0
- package/dist/capability-packs/index.js +19 -0
- package/dist/capability-packs/index.js.map +1 -0
- package/dist/capability-packs/installer.d.ts +69 -0
- package/dist/capability-packs/installer.d.ts.map +1 -0
- package/dist/capability-packs/installer.js +66 -0
- package/dist/capability-packs/installer.js.map +1 -0
- package/dist/capability-packs/manifest.d.ts +56 -0
- package/dist/capability-packs/manifest.d.ts.map +1 -0
- package/dist/capability-packs/manifest.js +9 -0
- package/dist/capability-packs/manifest.js.map +1 -0
- package/dist/capability-packs/validator.d.ts +29 -0
- package/dist/capability-packs/validator.d.ts.map +1 -0
- package/dist/capability-packs/validator.js +80 -0
- package/dist/capability-packs/validator.js.map +1 -0
- package/dist/capability-packs/version-resolver.d.ts +29 -0
- package/dist/capability-packs/version-resolver.d.ts.map +1 -0
- package/dist/capability-packs/version-resolver.js +39 -0
- package/dist/capability-packs/version-resolver.js.map +1 -0
- package/dist/contracts/contract.d.ts +40 -0
- package/dist/contracts/contract.d.ts.map +1 -0
- package/dist/contracts/contract.js +67 -0
- package/dist/contracts/contract.js.map +1 -0
- package/dist/contracts/index.d.ts +8 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +9 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/outcome.d.ts +23 -0
- package/dist/contracts/outcome.d.ts.map +1 -0
- package/dist/contracts/outcome.js +52 -0
- package/dist/contracts/outcome.js.map +1 -0
- package/dist/contracts/report.d.ts +23 -0
- package/dist/contracts/report.d.ts.map +1 -0
- package/dist/contracts/report.js +50 -0
- package/dist/contracts/report.js.map +1 -0
- package/dist/contracts/validator.d.ts +25 -0
- package/dist/contracts/validator.d.ts.map +1 -0
- package/dist/contracts/validator.js +149 -0
- package/dist/contracts/validator.js.map +1 -0
- package/dist/hardened-fetch.d.ts +1 -1
- package/dist/hardened-fetch.d.ts.map +1 -1
- package/dist/hardened-fetch.js +28 -5
- package/dist/hardened-fetch.js.map +1 -1
- package/dist/i18n/i18n.d.ts +41 -0
- package/dist/i18n/i18n.d.ts.map +1 -0
- package/dist/i18n/i18n.js +148 -0
- package/dist/i18n/i18n.js.map +1 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +3 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/router.d.ts +46 -0
- package/dist/models/router.d.ts.map +1 -0
- package/dist/models/router.js +326 -0
- package/dist/models/router.js.map +1 -0
- package/dist/net-guard.d.ts +13 -2
- package/dist/net-guard.d.ts.map +1 -1
- package/dist/net-guard.js +59 -42
- package/dist/net-guard.js.map +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/plugins/compatibility.d.ts +11 -0
- package/dist/plugins/compatibility.d.ts.map +1 -0
- package/dist/plugins/compatibility.js +39 -0
- package/dist/plugins/compatibility.js.map +1 -0
- package/dist/plugins/index.d.ts +6 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +8 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/installer.d.ts +17 -0
- package/dist/plugins/installer.d.ts.map +1 -0
- package/dist/plugins/installer.js +22 -0
- package/dist/plugins/installer.js.map +1 -0
- package/dist/plugins/lifecycle.d.ts +15 -0
- package/dist/plugins/lifecycle.d.ts.map +1 -0
- package/dist/plugins/lifecycle.js +26 -0
- package/dist/plugins/lifecycle.js.map +1 -0
- package/dist/plugins/manifest.d.ts +28 -0
- package/dist/plugins/manifest.d.ts.map +1 -0
- package/dist/plugins/manifest.js +24 -0
- package/dist/plugins/manifest.js.map +1 -0
- package/dist/plugins/registry.d.ts +26 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +43 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/run-events.d.ts +4 -4
- package/dist/run-events.js +3 -3
- package/dist/run-journal.d.ts +1 -1
- package/dist/run-journal.js +6 -6
- package/dist/run-journal.js.map +1 -1
- package/dist/run-registry.js +5 -5
- package/dist/run-substrate-contract.d.ts +1 -1
- package/dist/runs.d.ts +1 -1
- package/dist/runtime.d.ts +4 -4
- package/dist/runtime.js +1 -1
- package/dist/secrets.d.ts +1 -1
- package/dist/secrets.js +1 -1
- package/dist/sse-parser.d.ts +1 -1
- package/dist/sse-parser.js +1 -1
- package/dist/sse-writer.d.ts +1 -1
- package/dist/sse-writer.js +1 -1
- package/package.json +34 -1
package/README.md
CHANGED
|
@@ -1,91 +1,64 @@
|
|
|
1
1
|
# @weaveintel/core
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
- `
|
|
36
|
-
- `
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
- `
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
###
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- `
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
The canonical run-lifecycle contracts, relocated here from `@weaveintel/collaboration`
|
|
66
|
-
so there is ONE registry/journal interface with interchangeable backends (a KV
|
|
67
|
-
reference adapter here; a SQL adapter in geneWeave), each proven by the same
|
|
68
|
-
shared conformance suite.
|
|
69
|
-
- **Run registry** — `RunRegistry` (port), `createKvRunRegistry()` (KV adapter): durable run-handle store; tenant-isolated; idempotent status updates; lifecycle events.
|
|
70
|
-
- **Run journal** — `RunJournal` (port), `createKvRunJournal()` (KV adapter): append-only, sequenced, resumable-by-cursor run-event log. `readAfter(N)` is **exclusive** (returns `sequence > N`) and **gap-safe** (throws `RunCursorTooOldError` if the cursor fell below the retained watermark). Defaults (`RUN_JOURNAL_DEFAULTS`) derive from `RUN_STREAM_CONFIG_DEFAULTS` — one source for retention/size.
|
|
71
|
-
- **Conformance** — `runRegistryContract()` / `runJournalContract()`: shared test suites every adapter (KV here, SQL in geneWeave) must pass.
|
|
72
|
-
|
|
73
|
-
### SSE parsing
|
|
74
|
-
- `parseSseStream(stream, opts)` — the single, WHATWG-correct, browser-safe
|
|
75
|
-
Server-Sent-Events byte→event decoder (`SseEvent`, `ParseSseOptions`,
|
|
76
|
-
`SseStallError`). De-duplicated from `@weaveintel/client` + `@weaveintel/a2a`
|
|
77
|
-
(which now consume this one). Handles LF/CRLF, multi-line `data:`, comments,
|
|
78
|
-
UTF-8 chunk boundaries, an optional stall timeout, and abort/cancel.
|
|
79
|
-
|
|
80
|
-
### Protocol Contracts
|
|
81
|
-
- **MCP:** `MCPClient`, `MCPServer`, `MCPToolDefinition`, `MCPResource`, `MCPPrompt`, `MCPTransport`
|
|
82
|
-
- **A2A:** `A2AClient`, `A2AServer`, `A2ATask`, `AgentCard`, `AgentSkill`, `InternalA2ABus`
|
|
83
|
-
|
|
84
|
-
### Error Handling
|
|
85
|
-
- `WeaveIntelError` — typed error with `code`, `retryable`, `details`
|
|
86
|
-
- `normalizeError()` — normalize unknown errors to WeaveIntelError
|
|
87
|
-
- 20+ error codes: `RATE_LIMITED`, `TIMEOUT`, `INVALID_CONFIG`, `TOOL_EXECUTION_FAILED`, etc.
|
|
88
|
-
|
|
89
|
-
### Plugin Registry
|
|
90
|
-
- `PluginRegistry`, `PluginDescriptor`, `PluginType`
|
|
91
|
-
- `createPluginRegistry()` — register and query plugins by type
|
|
3
|
+
**The dependency-free foundation every other weaveIntel package is built on: shared contracts, types, the WeaveRuntime, and persistence interfaces.**
|
|
4
|
+
|
|
5
|
+
## Why it exists
|
|
6
|
+
|
|
7
|
+
Imagine a big building where the plumbing, wiring, and doorframes all have to line up. If every team invented its own pipe diameter, nothing would connect. `core` is the set of agreed-upon fittings: the exact shape of a `Model`, a `Tool`, a run event, an audit log. Every provider, router, and app speaks these shapes, so a piece written by one team drops cleanly into work by another. Crucially, `core` depends on *no* other `@weaveintel` package — everyone depends on it, never the reverse.
|
|
8
|
+
|
|
9
|
+
## When to reach for it
|
|
10
|
+
|
|
11
|
+
Reach for `core` whenever you need a type or interface that crosses package boundaries — defining a model, describing a tool, wiring the `WeaveRuntime` slots (egress, secrets, audit, persistence, resilience) that features run against. If you want a working model client, router, or prompt engine, don't stop here — install the package that *implements* the contract (e.g. `@weaveintel/routing`). `core` is the vocabulary, not the machinery.
|
|
12
|
+
|
|
13
|
+
## How to use it
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { weaveRuntime, weaveContext, defineTool as weaveTool } from '@weaveintel/core';
|
|
17
|
+
|
|
18
|
+
const clock = weaveTool({
|
|
19
|
+
name: 'now',
|
|
20
|
+
description: 'Return the current ISO timestamp',
|
|
21
|
+
schema: { type: 'object', properties: {} },
|
|
22
|
+
async execute() {
|
|
23
|
+
return { iso: new Date().toISOString() };
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const runtime = weaveRuntime({ /* egress, secrets, audit, persistence slots */ });
|
|
28
|
+
const ctx = weaveContext({ runtime });
|
|
29
|
+
|
|
30
|
+
console.log(await clock.execute({}, ctx));
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## What's in the box
|
|
34
|
+
|
|
35
|
+
- **Runtime** — `weaveRuntime`, its typed slots (`RuntimeEgressSlot`, `RuntimePersistenceSlot`, `RuntimeRoutingSlot`, …), `assertRuntimeRequires`, in-memory persistence and audit.
|
|
36
|
+
- **Model & tool contracts** — `Model`, `ModelRequest`, `Message`, `Tool`, `weaveTool`, `weaveToolRegistry`.
|
|
37
|
+
- **Execution** — `weaveContext`, `ExecutionBudget`, `WeaveIntelError`, `classifyError`, `weaveEventBus`, `WeavePipeline`/middleware.
|
|
38
|
+
- **Contracts galore** — memory, security, guardrails, observability, agents, workflows, MCP, A2A, RAG/vectorstore, compliance, and more.
|
|
39
|
+
- **Runtime plumbing** — `newUUIDv7`, `createLogger`, `assertSafeOutboundUrl`, `createHardenedFetch`, `parseSseStream`, `applyJsonPatch`.
|
|
40
|
+
|
|
41
|
+
Subpath entry points: `@weaveintel/core/models`, `/contracts`, `/plugins`, `/capability-packs`, `/i18n`.
|
|
42
|
+
|
|
43
|
+
### Outbound HTTP
|
|
44
|
+
|
|
45
|
+
`hardenedFetch` validates each redirect and rejects cross-origin redirects by
|
|
46
|
+
default. A trusted host may opt in with `allowCrossOriginRedirects`, but only
|
|
47
|
+
bodyless GET or HEAD requests can cross origins and caller headers are removed.
|
|
48
|
+
Manual and error redirect modes do not follow redirects. Existing callers
|
|
49
|
+
depending on cross-origin redirects or custom headers must adjust their flow.
|
|
50
|
+
|
|
51
|
+
Non-loopback HTTP and private-network access require separate trusted-policy
|
|
52
|
+
opt-ins (`allowInsecureHttp` and `allowPrivateNetwork`). Both broaden network
|
|
53
|
+
access; insecure HTTP exposes payloads and credentials. Use an `allowedHosts`
|
|
54
|
+
list and HTTPS wherever possible. Known metadata addresses remain blocked even
|
|
55
|
+
when private networking is enabled.
|
|
56
|
+
|
|
57
|
+
When the optional `undici` package is available, connection-time DNS validation
|
|
58
|
+
also protects against rebinding between the initial check and connection.
|
|
59
|
+
Without it, the client falls back to global fetch and only performs the initial
|
|
60
|
+
DNS check; that fallback does not provide equivalent rebinding protection.
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
MIT.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared admin-schema primitives for DB-driven capability management UIs.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Consuming applications can compose their admin tabs from these
|
|
5
5
|
* types/helpers so prompt/skill/tool/agent records stay model-discoverable
|
|
6
6
|
* and consistently labeled across apps.
|
|
7
7
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared admin-schema primitives for DB-driven capability management UIs.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Consuming applications can compose their admin tabs from these
|
|
5
5
|
* types/helpers so prompt/skill/tool/agent records stay model-discoverable
|
|
6
6
|
* and consistently labeled across apps.
|
|
7
7
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @weaveintel/capability-packs
|
|
3
|
+
*
|
|
4
|
+
* Capability packs are operator-shippable bundles of DB rows that compose a
|
|
5
|
+
* complete capability (a workflow + its handler kinds + its tools + its
|
|
6
|
+
* triggers + its prompts, etc.) into a single JSON manifest that can be
|
|
7
|
+
* exported from one weaveintel instance and installed into another.
|
|
8
|
+
*
|
|
9
|
+
* The package is intentionally agnostic about which row shapes exist — apps
|
|
10
|
+
* declare their content kinds via the `PackInstallAdapter` they pass to the
|
|
11
|
+
* installer. This keeps the package free of a hardcoded coupling to any
|
|
12
|
+
* specific app schema.
|
|
13
|
+
*/
|
|
14
|
+
export * from './manifest.js';
|
|
15
|
+
export * from './validator.js';
|
|
16
|
+
export * from './installer.js';
|
|
17
|
+
export * from './version-resolver.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/capability-packs/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;GAYG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
* @weaveintel/capability-packs
|
|
4
|
+
*
|
|
5
|
+
* Capability packs are operator-shippable bundles of DB rows that compose a
|
|
6
|
+
* complete capability (a workflow + its handler kinds + its tools + its
|
|
7
|
+
* triggers + its prompts, etc.) into a single JSON manifest that can be
|
|
8
|
+
* exported from one weaveintel instance and installed into another.
|
|
9
|
+
*
|
|
10
|
+
* The package is intentionally agnostic about which row shapes exist — apps
|
|
11
|
+
* declare their content kinds via the `PackInstallAdapter` they pass to the
|
|
12
|
+
* installer. This keeps the package free of a hardcoded coupling to any
|
|
13
|
+
* specific app schema.
|
|
14
|
+
*/
|
|
15
|
+
export * from './manifest.js';
|
|
16
|
+
export * from './validator.js';
|
|
17
|
+
export * from './installer.js';
|
|
18
|
+
export * from './version-resolver.js';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/capability-packs/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;;;;;;;;GAYG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { CapabilityPack, PackInstallationLedger, PackPreconditions } from './manifest.js';
|
|
2
|
+
/**
|
|
3
|
+
* Apps implement this. The installer is generic — it knows nothing about
|
|
4
|
+
* SQLite, workflow_defs, tool_catalog, etc. The adapter is the boundary.
|
|
5
|
+
*
|
|
6
|
+
* Implementations SHOULD perform `upsertRows` for a single pack install
|
|
7
|
+
* inside one DB transaction. The installer aggregates ledger entries across
|
|
8
|
+
* kinds and hands them back so uninstall can reverse them precisely.
|
|
9
|
+
*/
|
|
10
|
+
export interface PackInstallAdapter {
|
|
11
|
+
/**
|
|
12
|
+
* Check that the target satisfies a pack's preconditions (handler kinds,
|
|
13
|
+
* tool keys, MCP servers, trigger source kinds present). Return a list of
|
|
14
|
+
* unmet preconditions; empty array means OK.
|
|
15
|
+
*/
|
|
16
|
+
checkPreconditions(pre: PackPreconditions): Promise<string[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Insert or update rows for a single content kind. Return the ids that were
|
|
19
|
+
* actually written (so the ledger reflects exactly what install touched —
|
|
20
|
+
* useful when the adapter chooses to skip already-present rows).
|
|
21
|
+
*/
|
|
22
|
+
upsertRows(kind: string, rows: ReadonlyArray<Record<string, unknown>>): Promise<string[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Remove rows for a content kind by id. Best-effort; missing ids are not an
|
|
25
|
+
* error. Apps SHOULD respect FK constraints by ordering kinds correctly via
|
|
26
|
+
* the `uninstallOrder` option on `uninstallPack`.
|
|
27
|
+
*/
|
|
28
|
+
deleteRows(kind: string, rowIds: ReadonlyArray<string>): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Optional hook to wrap a single install in a transaction. If omitted the
|
|
31
|
+
* installer runs without a tx and the adapter is responsible for its own
|
|
32
|
+
* atomicity.
|
|
33
|
+
*/
|
|
34
|
+
withTransaction?<T>(fn: () => Promise<T>): Promise<T>;
|
|
35
|
+
}
|
|
36
|
+
export interface InstallPackOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Override the default content-kind installation order. Earlier kinds are
|
|
39
|
+
* inserted first — useful when later kinds reference earlier ids by FK.
|
|
40
|
+
* Defaults to the order of keys on `pack.contents`.
|
|
41
|
+
*/
|
|
42
|
+
installOrder?: string[];
|
|
43
|
+
/** Skip preconditions check entirely (for tests). Default: false. */
|
|
44
|
+
skipPreconditions?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface InstallPackResult {
|
|
47
|
+
ledger: PackInstallationLedger;
|
|
48
|
+
/** Unmet preconditions discovered during the run. Empty when ok. */
|
|
49
|
+
unmetPreconditions: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Install a capability pack. Validates the manifest, checks preconditions,
|
|
53
|
+
* applies all rows in dependency-friendly order, and returns a ledger that
|
|
54
|
+
* can later be used by `uninstallPack`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function installPack(pack: CapabilityPack, adapter: PackInstallAdapter, options?: InstallPackOptions): Promise<InstallPackResult>;
|
|
57
|
+
export interface UninstallPackOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Reverse-order list of content kinds to delete. If omitted, the ledger's
|
|
60
|
+
* own kind order is reversed (so rows inserted last are deleted first).
|
|
61
|
+
*/
|
|
62
|
+
uninstallOrder?: string[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Uninstall a previously-installed pack by replaying its ledger in reverse.
|
|
66
|
+
* Best-effort: missing rows are not an error.
|
|
67
|
+
*/
|
|
68
|
+
export declare function uninstallPack(ledger: PackInstallationLedger, adapter: PackInstallAdapter, options?: UninstallPackOptions): Promise<void>;
|
|
69
|
+
//# sourceMappingURL=installer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../src/capability-packs/installer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,eAAe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Acf"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { validateManifest, PackValidationError } from './validator.js';
|
|
2
|
+
/**
|
|
3
|
+
* Install a capability pack. Validates the manifest, checks preconditions,
|
|
4
|
+
* applies all rows in dependency-friendly order, and returns a ledger that
|
|
5
|
+
* can later be used by `uninstallPack`.
|
|
6
|
+
*/
|
|
7
|
+
export async function installPack(pack, adapter, options = {}) {
|
|
8
|
+
const result = validateManifest(pack);
|
|
9
|
+
if (!result.ok) {
|
|
10
|
+
throw new PackValidationError(result.issues);
|
|
11
|
+
}
|
|
12
|
+
const unmet = [];
|
|
13
|
+
if (!options.skipPreconditions && pack.preconditions) {
|
|
14
|
+
const missing = await adapter.checkPreconditions(pack.preconditions);
|
|
15
|
+
if (missing.length > 0) {
|
|
16
|
+
unmet.push(...missing);
|
|
17
|
+
throw new Error(`pack preconditions not met: ${missing.join(', ')}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const order = options.installOrder ?? Object.keys(pack.contents);
|
|
21
|
+
const rowsByKind = {};
|
|
22
|
+
const apply = async () => {
|
|
23
|
+
for (const kind of order) {
|
|
24
|
+
const rows = pack.contents[kind];
|
|
25
|
+
if (!rows || rows.length === 0)
|
|
26
|
+
continue;
|
|
27
|
+
const writtenIds = await adapter.upsertRows(kind, rows);
|
|
28
|
+
rowsByKind[kind] = writtenIds;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
if (adapter.withTransaction) {
|
|
32
|
+
await adapter.withTransaction(apply);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
await apply();
|
|
36
|
+
}
|
|
37
|
+
const ledger = {
|
|
38
|
+
packKey: pack.key,
|
|
39
|
+
packVersion: pack.version,
|
|
40
|
+
installedAt: new Date().toISOString(),
|
|
41
|
+
rowsByKind,
|
|
42
|
+
};
|
|
43
|
+
return { ledger, unmetPreconditions: unmet };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Uninstall a previously-installed pack by replaying its ledger in reverse.
|
|
47
|
+
* Best-effort: missing rows are not an error.
|
|
48
|
+
*/
|
|
49
|
+
export async function uninstallPack(ledger, adapter, options = {}) {
|
|
50
|
+
const kinds = options.uninstallOrder ?? Object.keys(ledger.rowsByKind).reverse();
|
|
51
|
+
const run = async () => {
|
|
52
|
+
for (const kind of kinds) {
|
|
53
|
+
const rowIds = ledger.rowsByKind[kind];
|
|
54
|
+
if (!rowIds || rowIds.length === 0)
|
|
55
|
+
continue;
|
|
56
|
+
await adapter.deleteRows(kind, rowIds);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
if (adapter.withTransaction) {
|
|
60
|
+
await adapter.withTransaction(run);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
await run();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=installer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../../src/capability-packs/installer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAyDvE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAAoB,EACpB,OAA2B,EAC3B,UAA8B,EAAE;IAEhC,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,CAAC,OAAO,CAAC,iBAAiB,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACrD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACrE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,E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,KAAK,GAAG,OAAO,CAAC,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;IACjF,MAAM,GAAG,GAAG,KAAK,IAAI,EAAE;QACrB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YACvC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;gBAAE,SAAS;YAC7C,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACzC,CAAC;IACH,CAAC,CAAC;IACF,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;QAC5B,MAAM,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability pack manifest types.
|
|
3
|
+
*
|
|
4
|
+
* A pack is a versioned, exportable bundle of DB rows. The package holds the
|
|
5
|
+
* manifest contract and the structural shape; the actual row schemas (which
|
|
6
|
+
* tables those rows belong to) are the app's concern.
|
|
7
|
+
*/
|
|
8
|
+
export type PackStatus = 'draft' | 'published' | 'retired';
|
|
9
|
+
/**
|
|
10
|
+
* A bucket of rows within a pack. Keys are app-defined content kinds
|
|
11
|
+
* (e.g. `'workflows'`, `'workflowSteps'`, `'tools'`, `'triggers'`). Values
|
|
12
|
+
* are opaque row payloads — the installer adapter knows how to upsert each.
|
|
13
|
+
*/
|
|
14
|
+
export type PackContents = Record<string, ReadonlyArray<Record<string, unknown>>>;
|
|
15
|
+
export interface PackDependency {
|
|
16
|
+
/** Pack key the manifest depends on. */
|
|
17
|
+
packKey: string;
|
|
18
|
+
/** Semver-ish range. The validator does an exact-or-prefix match only. */
|
|
19
|
+
versionRange: string;
|
|
20
|
+
}
|
|
21
|
+
export interface PackPreconditions {
|
|
22
|
+
/** Workflow handler kinds that must already exist on the target. */
|
|
23
|
+
requiredHandlerKinds?: string[];
|
|
24
|
+
/** Tool keys that must already exist in the target's tool catalog. */
|
|
25
|
+
requiredToolKeys?: string[];
|
|
26
|
+
/** MCP server keys that must already be registered. */
|
|
27
|
+
requiredMcpServers?: string[];
|
|
28
|
+
/** Trigger source kinds that must be supported by the target dispatcher. */
|
|
29
|
+
requiredTriggerSourceKinds?: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface CapabilityPack {
|
|
32
|
+
/** Pinned to '1' for now — bump when manifest shape changes. */
|
|
33
|
+
manifestVersion: '1';
|
|
34
|
+
/** Stable, dotted identifier (e.g. `'kaggle.pipeline'`). */
|
|
35
|
+
key: string;
|
|
36
|
+
/** Semver. The validator enforces `MAJOR.MINOR.PATCH`. */
|
|
37
|
+
version: string;
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
authoredBy?: string;
|
|
41
|
+
dependencies?: PackDependency[];
|
|
42
|
+
preconditions?: PackPreconditions;
|
|
43
|
+
/** App-defined buckets of opaque rows. */
|
|
44
|
+
contents: PackContents;
|
|
45
|
+
/** Free-form, persisted alongside the manifest. */
|
|
46
|
+
metadata?: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
/** Result of `installPack` — a per-row ledger so uninstall can clean up exactly what install added. */
|
|
49
|
+
export interface PackInstallationLedger {
|
|
50
|
+
packKey: string;
|
|
51
|
+
packVersion: string;
|
|
52
|
+
installedAt: string;
|
|
53
|
+
/** For each content kind, the ids of rows the installer wrote. */
|
|
54
|
+
rowsByKind: Record<string, string[]>;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/capability-packs/manifest.ts"],"names":[],"mappings":"AAAA;;;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AAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACtC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability pack manifest types.
|
|
3
|
+
*
|
|
4
|
+
* A pack is a versioned, exportable bundle of DB rows. The package holds the
|
|
5
|
+
* manifest contract and the structural shape; the actual row schemas (which
|
|
6
|
+
* tables those rows belong to) are the app's concern.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/capability-packs/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CapabilityPack } from './manifest.js';
|
|
2
|
+
export interface PackValidationIssue {
|
|
3
|
+
severity: 'error' | 'warning';
|
|
4
|
+
path: string;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PackValidationResult {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
issues: PackValidationIssue[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Static structural validation of a `CapabilityPack`. Does NOT run install
|
|
13
|
+
* preconditions against a live target — that happens inside `installPack`.
|
|
14
|
+
*
|
|
15
|
+
* Checks performed:
|
|
16
|
+
* - manifestVersion === '1'
|
|
17
|
+
* - key matches `lower.dotted.snake_case`
|
|
18
|
+
* - version is semver
|
|
19
|
+
* - name and description present
|
|
20
|
+
* - contents is a Record of arrays
|
|
21
|
+
* - every row has a stable id (string), so the ledger can track it
|
|
22
|
+
* - no duplicate ids within a content kind
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateManifest(pack: CapabilityPack): PackValidationResult;
|
|
25
|
+
export declare class PackValidationError extends Error {
|
|
26
|
+
readonly issues: PackValidationIssue[];
|
|
27
|
+
constructor(issues: PackValidationIssue[]);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/capability-packs/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,mBAAmB,EAAE,CAAC;CAC/B;AAKD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,oBAAoB,CA4D3E;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC;gBAC3B,MAAM,EAAE,mBAAmB,EAAE;CAK1C"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const SEMVER_RE = /^\d+\.\d+\.\d+(?:-[\w.]+)?$/;
|
|
2
|
+
const KEY_RE = /^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)*$/;
|
|
3
|
+
/**
|
|
4
|
+
* Static structural validation of a `CapabilityPack`. Does NOT run install
|
|
5
|
+
* preconditions against a live target — that happens inside `installPack`.
|
|
6
|
+
*
|
|
7
|
+
* Checks performed:
|
|
8
|
+
* - manifestVersion === '1'
|
|
9
|
+
* - key matches `lower.dotted.snake_case`
|
|
10
|
+
* - version is semver
|
|
11
|
+
* - name and description present
|
|
12
|
+
* - contents is a Record of arrays
|
|
13
|
+
* - every row has a stable id (string), so the ledger can track it
|
|
14
|
+
* - no duplicate ids within a content kind
|
|
15
|
+
*/
|
|
16
|
+
export function validateManifest(pack) {
|
|
17
|
+
const issues = [];
|
|
18
|
+
const err = (path, message) => issues.push({ severity: 'error', path, message });
|
|
19
|
+
if (pack.manifestVersion !== '1') {
|
|
20
|
+
err('manifestVersion', `unsupported manifest version: ${String(pack.manifestVersion)}`);
|
|
21
|
+
}
|
|
22
|
+
if (!pack.key || !KEY_RE.test(pack.key)) {
|
|
23
|
+
err('key', `invalid pack key: ${JSON.stringify(pack.key)} (expected lower.dotted.snake_case)`);
|
|
24
|
+
}
|
|
25
|
+
if (!pack.version || !SEMVER_RE.test(pack.version)) {
|
|
26
|
+
err('version', `invalid semver: ${JSON.stringify(pack.version)}`);
|
|
27
|
+
}
|
|
28
|
+
if (!pack.name || pack.name.trim().length === 0) {
|
|
29
|
+
err('name', 'name is required');
|
|
30
|
+
}
|
|
31
|
+
if (!pack.description || pack.description.trim().length === 0) {
|
|
32
|
+
err('description', 'description is required');
|
|
33
|
+
}
|
|
34
|
+
if (!pack.contents || typeof pack.contents !== 'object' || Array.isArray(pack.contents)) {
|
|
35
|
+
err('contents', 'contents must be an object of {kind: row[]} buckets');
|
|
36
|
+
return { ok: false, issues };
|
|
37
|
+
}
|
|
38
|
+
for (const [kind, rows] of Object.entries(pack.contents)) {
|
|
39
|
+
if (!Array.isArray(rows)) {
|
|
40
|
+
err(`contents.${kind}`, 'bucket must be an array');
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const seenIds = new Set();
|
|
44
|
+
rows.forEach((row, idx) => {
|
|
45
|
+
if (!row || typeof row !== 'object' || Array.isArray(row)) {
|
|
46
|
+
err(`contents.${kind}[${idx}]`, 'row must be an object');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const id = row['id'];
|
|
50
|
+
if (typeof id !== 'string' || id.length === 0) {
|
|
51
|
+
err(`contents.${kind}[${idx}].id`, 'row must have a string id');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (seenIds.has(id)) {
|
|
55
|
+
err(`contents.${kind}[${idx}].id`, `duplicate id within bucket: ${id}`);
|
|
56
|
+
}
|
|
57
|
+
seenIds.add(id);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (pack.dependencies) {
|
|
61
|
+
pack.dependencies.forEach((dep, idx) => {
|
|
62
|
+
if (!dep.packKey || !KEY_RE.test(dep.packKey)) {
|
|
63
|
+
err(`dependencies[${idx}].packKey`, `invalid dependency packKey: ${dep.packKey}`);
|
|
64
|
+
}
|
|
65
|
+
if (!dep.versionRange) {
|
|
66
|
+
err(`dependencies[${idx}].versionRange`, 'versionRange is required');
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return { ok: issues.every((i) => i.severity !== 'error'), issues };
|
|
71
|
+
}
|
|
72
|
+
export class PackValidationError extends Error {
|
|
73
|
+
issues;
|
|
74
|
+
constructor(issues) {
|
|
75
|
+
super(`capability pack validation failed: ${issues.map((i) => `${i.path}: ${i.message}`).join('; ')}`);
|
|
76
|
+
this.name = 'PackValidationError';
|
|
77
|
+
this.issues = issues;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/capability-packs/validator.ts"],"names":[],"mappings":"AAaA,MAAM,SAAS,GAAG,6BAA6B,CAAC;AAChD,MAAM,MAAM,GAAG,yCAAyC,CAAC;AAEzD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAoB;IACnD,MAAM,MAAM,GAA0B,EAAE,CAAC;IACzC,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAEjG,IAAI,IAAI,CAAC,eAAe,KAAK,GAAG,EAAE,CAAC;QACjC,GAAG,CAAC,iBAAiB,EAAE,iCAAiC,MAAM,CAAC,IAAI,CAAC,eAAe,C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,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YACpF,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;gBACtB,GAAG,CAAC,gBAAgB,GAAG,gBAAgB,EAAE,0BAA0B,CAAC,CAAC;YACvE,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;AACrE,CAAC;AAED,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,MAAM,CAAwB;IACvC,YAAY,MAA6B;QACvC,KAAK,CAAC,sCAAsC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvG,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PackStatus } from './manifest.js';
|
|
2
|
+
/**
|
|
3
|
+
* Minimal row shape the resolver works against. Apps can extend this on
|
|
4
|
+
* their DB rows; the resolver only depends on these fields.
|
|
5
|
+
*/
|
|
6
|
+
export interface PackVersionRow {
|
|
7
|
+
packKey: string;
|
|
8
|
+
version: string;
|
|
9
|
+
status: PackStatus;
|
|
10
|
+
/** Higher = newer. The resolver uses semver comparison, not this field. */
|
|
11
|
+
publishedAt?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ResolvePackContext {
|
|
14
|
+
/** When set, the resolver returns this exact version regardless of status. */
|
|
15
|
+
versionOverride?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Pick the active version for a pack key.
|
|
19
|
+
*
|
|
20
|
+
* Precedence (matches `@weaveintel/prompts` Phase 5):
|
|
21
|
+
* 1. ctx.versionOverride (any status, exact match)
|
|
22
|
+
* 2. The highest semver among status === 'published'
|
|
23
|
+
* 3. The highest semver among any status (fallback for dev environments)
|
|
24
|
+
* 4. null
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveActivePackVersion(rows: ReadonlyArray<PackVersionRow>, packKey: string, ctx?: ResolvePackContext): PackVersionRow | null;
|
|
27
|
+
/** Lexicographic semver compare on MAJOR.MINOR.PATCH (ignores pre-release). */
|
|
28
|
+
export declare function compareSemver(a: string, b: string): number;
|
|
29
|
+
//# sourceMappingURL=version-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-resolver.d.ts","sourceRoot":"","sources":["../../src/capability-packs/version-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;IACnB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,aAAa,CAAC,cAAc,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,kBAAuB,GAC3B,cAAc,GAAG,IAAI,CAavB;AAMD,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAS1D"}
|