@moldea.ai/core 2.1.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -98
- package/dist/adapter/index.d.ts +97 -14
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/adapter-execution/index.d.ts.map +1 -1
- package/dist/adapter-repository/index.d.ts +9 -0
- package/dist/adapter-repository/index.d.ts.map +1 -0
- package/dist/adapter-validation/index.d.ts +2 -3
- package/dist/adapter-validation/index.d.ts.map +1 -1
- package/dist/adapter.js +93 -0
- package/dist/adapter.js.map +1 -0
- package/dist/agent-assets/index.d.ts +2 -2
- package/dist/agent-assets/index.d.ts.map +1 -1
- package/dist/canonical-content-page/index.d.ts +5 -0
- package/dist/canonical-content-page/index.d.ts.map +1 -0
- package/dist/canonical-discovery/index.d.ts +3 -2
- package/dist/canonical-discovery/index.d.ts.map +1 -1
- package/dist/chunks/exceptions-DWsZTpqs.js +71 -0
- package/dist/chunks/exceptions-DWsZTpqs.js.map +1 -0
- package/dist/contracts/index.d.ts +129 -6
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/decision/index.d.ts +1 -1
- package/dist/decision/index.d.ts.map +1 -1
- package/dist/decision-graph/index.d.ts +3 -2
- package/dist/decision-graph/index.d.ts.map +1 -1
- package/dist/exceptions/index.d.ts +2 -2
- package/dist/exceptions/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +688 -228
- package/dist/index.js.map +1 -1
- package/dist/manifest/index.d.ts +1 -1
- package/dist/manifest/index.d.ts.map +1 -1
- package/dist/mirrors/index.d.ts +3 -2
- package/dist/mirrors/index.d.ts.map +1 -1
- package/dist/project-assets/index.d.ts +4 -3
- package/dist/project-assets/index.d.ts.map +1 -1
- package/dist/project-inspection-page/index.d.ts +5 -0
- package/dist/project-inspection-page/index.d.ts.map +1 -0
- package/dist/project-metadata/index.d.ts +6 -0
- package/dist/project-metadata/index.d.ts.map +1 -0
- package/dist/{project-inspection → project-validation}/index.d.ts +8 -2
- package/dist/project-validation/index.d.ts.map +1 -0
- package/dist/repository-inspection-session/index.d.ts +13 -3
- package/dist/repository-inspection-session/index.d.ts.map +1 -1
- package/dist/repository-reference-validation/index.d.ts +3 -2
- package/dist/repository-reference-validation/index.d.ts.map +1 -1
- package/dist/repository-text/index.d.ts +3 -2
- package/dist/repository-text/index.d.ts.map +1 -1
- package/dist/runtime-guidance/index.d.ts +3 -2
- package/dist/runtime-guidance/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/project-inspection/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -2,79 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
# `@moldea.ai/core`
|
|
4
4
|
|
|
5
|
-
Source-neutral, deterministic interpretation of the `moldea` repository format.
|
|
5
|
+
Source-neutral, deterministic, content-safe interpretation of the `moldea` repository format.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Version 3 accepts caller-supplied text and `@moldea.ai/repository` version 2 readers. It performs no filesystem, Git, or network access independently. Project validation returns content-free summaries, diagnostics, evidence, and metadata. Canonical document bodies are available only through an explicit path-scoped byte-range operation.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @moldea.ai/core@3 @moldea.ai/repository@2
|
|
13
|
+
```
|
|
8
14
|
|
|
9
15
|
## Public entry points
|
|
10
16
|
|
|
11
|
-
- `@moldea.ai/core` exposes Core construction, results, diagnostics, limits, and exceptions.
|
|
12
|
-
- `@moldea.ai/core/format` exposes repository-format
|
|
13
|
-
- `@moldea.ai/core/adapter` exposes the runtime-adapter
|
|
17
|
+
- `@moldea.ai/core` exposes Core construction, operations, results, diagnostics, limits, and exceptions.
|
|
18
|
+
- `@moldea.ai/core/format` exposes repository-format contracts.
|
|
19
|
+
- `@moldea.ai/core/adapter` exposes the per-agent runtime-adapter contract and bounded reader utilities.
|
|
14
20
|
|
|
15
|
-
## Text
|
|
21
|
+
## Text and document parsing
|
|
16
22
|
|
|
17
23
|
```typescript
|
|
18
24
|
import { createCore } from '@moldea.ai/core';
|
|
19
25
|
import { parseRepositoryPath } from '@moldea.ai/repository';
|
|
20
26
|
|
|
21
27
|
const core = createCore();
|
|
22
|
-
const
|
|
28
|
+
const normalized = core.normalizeText({
|
|
23
29
|
content: new TextEncoder().encode('\ufeffline one\r\nline two\r'),
|
|
24
30
|
path: parseRepositoryPath('/moldea/project.md'),
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const normalized = core.normalizeText(input);
|
|
28
|
-
const digested = await core.calculateContentDigest(input);
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Normalization validates strict UTF-8 or Unicode-scalar string input, removes one leading byte-order
|
|
32
|
-
mark, converts CRLF and CR line endings to LF, rejects NUL, performs no Unicode normalization, and
|
|
33
|
-
reports normalized UTF-8 byte and scalar lengths. Digests are SHA-256 over the normalized UTF-8
|
|
34
|
-
bytes.
|
|
35
|
-
|
|
36
|
-
## Manifest parsing
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
import { createCore } from '@moldea.ai/core';
|
|
40
|
-
import { parseRepositoryPath } from '@moldea.ai/repository';
|
|
41
|
-
|
|
42
|
-
const result = await createCore().parseManifest({
|
|
31
|
+
});
|
|
32
|
+
const manifest = await core.parseManifest({
|
|
43
33
|
content: new TextEncoder().encode('version: 1\n'),
|
|
44
34
|
path: parseRepositoryPath('/moldea/moldea.yaml'),
|
|
45
35
|
});
|
|
46
36
|
```
|
|
47
37
|
|
|
48
|
-
|
|
38
|
+
Normalization validates strict UTF-8 or Unicode-scalar strings, removes one leading byte-order mark, converts CRLF and CR endings to LF, rejects NUL, and performs no Unicode normalization. Digests are SHA-256 over normalized UTF-8 bytes.
|
|
49
39
|
|
|
50
|
-
|
|
40
|
+
Manifest and decision parsing enforce Repository Format version 1 as all-or-nothing document contracts. Structural content errors return deterministic diagnostics. Invalid operation input and resource or source failures reject with typed exceptions.
|
|
51
41
|
|
|
52
|
-
|
|
53
|
-
import { createCore } from '@moldea.ai/core';
|
|
54
|
-
import { parseRepositoryPath } from '@moldea.ai/repository';
|
|
55
|
-
|
|
56
|
-
const result = await createCore().parseDecision({
|
|
57
|
-
content: [
|
|
58
|
-
'---',
|
|
59
|
-
'status: accepted',
|
|
60
|
-
'createdAt: "2026-08-07T19:42:03.456Z"',
|
|
61
|
-
'---',
|
|
62
|
-
'Use the accepted implementation.',
|
|
63
|
-
'',
|
|
64
|
-
].join('\n'),
|
|
65
|
-
path: parseRepositoryPath('/moldea/decisions/1786131723456-use-postgresql.md'),
|
|
66
|
-
});
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Decision parsing validates the canonical timestamp-slug path, exact frontmatter delimiters, strict YAML metadata, status, canonical UTC `createdAt`, filename timestamp equality, supersession IDs, and non-empty Markdown body. A valid result preserves the exact normalized body and complete normalized asset, sorts supersession IDs, and includes a SHA-256 digest. It does not read other decisions or validate reference existence, duplicate IDs across files, supersession graphs, status consistency, or manifest relationships.
|
|
70
|
-
|
|
71
|
-
## Changed-path scope matching
|
|
42
|
+
## Cheap changed-path scope matching
|
|
72
43
|
|
|
73
44
|
```typescript
|
|
74
|
-
|
|
75
|
-
import { parseRepositoryPath } from '@moldea.ai/repository';
|
|
76
|
-
|
|
77
|
-
const result = await createCore().matchManifestScope({
|
|
45
|
+
const result = await core.matchManifestScope({
|
|
78
46
|
manifest: {
|
|
79
47
|
content: 'version: 1\n',
|
|
80
48
|
path: parseRepositoryPath('/moldea/moldea.yaml'),
|
|
@@ -83,74 +51,46 @@ const result = await createCore().matchManifestScope({
|
|
|
83
51
|
});
|
|
84
52
|
```
|
|
85
53
|
|
|
86
|
-
`matchManifestScope` parses the supplied manifest and
|
|
87
|
-
|
|
88
|
-
Changed-path input bytes use the existing `maxTotalBytesRead` limit. Supplied path entries, manifest relationship declarations, and returned matches each use the existing `maxEntries` limit, whose default is 100,000. This keeps the operation bounded while allowing large repositories to provide complete path sets. An invalid manifest returns structural diagnostics with no matches and cannot establish relevance.
|
|
54
|
+
`matchManifestScope` parses only the supplied manifest and matches sorted, deduplicated changed paths against exact relationships and supported globs. It reads no other repository file, returns no canonical content, and invokes no adapter. This is the preactivation boundary for callers that already know the changed paths.
|
|
89
55
|
|
|
90
|
-
##
|
|
56
|
+
## Content-free project validation
|
|
91
57
|
|
|
92
58
|
```typescript
|
|
93
|
-
import { createCore } from '@moldea.ai/core';
|
|
94
59
|
import { createMemoryRepositoryReader } from '@moldea.ai/repository/memory';
|
|
95
60
|
|
|
96
61
|
const repository = createMemoryRepositoryReader([
|
|
97
|
-
{
|
|
98
|
-
|
|
99
|
-
path: '/moldea/moldea.yaml',
|
|
100
|
-
type: 'file',
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
content: '# Project\n',
|
|
104
|
-
path: '/moldea/project.md',
|
|
105
|
-
type: 'file',
|
|
106
|
-
},
|
|
62
|
+
{ content: 'version: 1\n', path: '/moldea/moldea.yaml', type: 'file' },
|
|
63
|
+
{ content: '# Project\n', path: '/moldea/project.md', type: 'file' },
|
|
107
64
|
]);
|
|
108
|
-
const result = await
|
|
65
|
+
const result = await core.validateProject({ repository });
|
|
109
66
|
```
|
|
110
67
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
Canonical discovery and exact decision reads can compose through this `IRepositoryReader` boundary. Core parses each discovered decision once and deterministically validates project-wide ID uniqueness, missing supersession references, cycles, active and historical status consistency, and orphaned superseded decisions. Invalid or ambiguous decision nodes do not produce dependent graph cascades, while unrelated trustworthy graph rules continue to run.
|
|
114
|
-
|
|
115
|
-
The internal relationship layer also validates top-level and per-agent context and decision paths against canonical discovery and the parsed decision graph. Context targets must exist, and decision targets must exist and be accepted. Discovery and document diagnostics retain ownership of invalid targets so dependent missing or inactive diagnostics do not cascade.
|
|
116
|
-
|
|
117
|
-
Repository references, bindings, capability implementations, unresolved-requirement references, and exact `affectedBy` paths are validated through the same inspection reader. Exact targets must resolve to regular files without following symlinks, repeated paths share one exact lookup, and capability implementation failures use their specific tool or skill diagnostic instead of a generic reference diagnostic. Glob `affectedBy` patterns are not enumerated and may match zero entries; adapter-owned symbol resolution remains deferred to adapter inspection.
|
|
118
|
-
|
|
119
|
-
Core now also contains internal readers for every discovered runtime-guidance file and for convention-owned registered-agent assets. Runtime guidance is normalized, digested, checked for non-whitespace content, and reconciled with each agent's optional runtime guidance path. Registered agents are reconciled with exact directories, mandatory descriptions and instructions, optional handoff descriptions, Unicode-whitespace-trimmed description limits, forbidden runtime-variable delimiters, opening instruction identity, and complete runtime-placeholder grammar and declaration usage. Placeholder diagnostics preserve scalar-aware source ranges and deterministic declaration pointers. Unregistered directories and missing registered assets produce deterministic diagnostics without rereading unregistered content or cascading from discovery-owned failures.
|
|
120
|
-
|
|
121
|
-
Declared mirrors are resolved through the same inspection reader and compared with their owning canonical instruction after strict text decoding and repository-format normalization. One leading byte-order mark and CRLF or CR line endings are normalized; all other content differences remain significant. Only exact normalized matches retain mirror and canonical digests. Missing, non-file, symlink, stale, and invalid-text mirrors produce deterministic diagnostics, while an unavailable canonical instruction suppresses mirror lookups and dependent diagnostics.
|
|
122
|
-
|
|
123
|
-
Universal inspection now reads and parses the manifest, reads the project foundation, and then composes canonical discovery, focused-context reads, decision graphs, runtime guidance, registered-agent assets, manifest relationships, repository references, and mirrors through one coherent reader session. Exact foundation entries and file bytes are reused rather than requested twice. It aggregates diagnostics under one project-inspection limit and produces a deeply immutable, deterministic, JSON-safe provisional project index only when every universal phase succeeds. A supported format version remains available when it is independently trustworthy even if another manifest rule fails. Project and focused-context files must contain non-whitespace text; valid focused context retains its manifest relationship metadata, and all indexed assets retain normalized content, scalar and byte lengths, and SHA-256 digests.
|
|
124
|
-
|
|
125
|
-
Before any adapter runs, Core verifies that every recognized package-backed runtime ID declared by an agent has a configured adapter and that the adapter supports the active repository-format version. Availability failures retain manifest-derived source ranges, prevent every adapter from running, and return empty evidence. Core then groups agents by runtime ID and invokes each applicable configured adapter exactly once in ascending adapter-ID order. Each adapter receives only its matching agents, the complete frozen project, the shared budget-aware reader, and the active signal. The built-in `custom` behavior requires no configured adapter and produces no runtime evidence by itself.
|
|
68
|
+
`validateProject` returns validity, format version, source identity, summary counts and digests, diagnostics, and runtime evidence. It never returns manifest, project, context, decision, runtime-guidance, mirror, description, or instruction bodies.
|
|
126
69
|
|
|
127
|
-
|
|
70
|
+
`inspectProjectPage` provides bounded content-free views named `metadata`, `diagnostics`, `evidence`, and `all`. Each page uses a semantic continuation cursor tied to the validation digest and view. `readCanonicalContentPage` is the only Core project operation that returns a body, and it requires an explicit canonical `/moldea/**` file path, byte offset, and byte bound. Returned chunks end at a complete UTF-8 scalar.
|
|
128
71
|
|
|
129
|
-
|
|
72
|
+
## Per-agent runtime adapters
|
|
130
73
|
|
|
131
|
-
|
|
74
|
+
Universal validation must succeed before adapters run. Core invokes a configured package adapter once for each matching agent, in deterministic adapter and agent order. Each invocation receives only that agent, a bounded reader, a shared cancellation signal, and an exact same-runtime `resolveAgent(reference)` function for bindings that genuinely require another agent. It never receives the complete agent collection.
|
|
132
75
|
|
|
133
|
-
|
|
76
|
+
Adapter evidence and diagnostics are validated, normalized, deduplicated, sorted, and limited before exposure. An unexpected adapter failure or invalid output rejects the complete operation with `ADAPTER_EXECUTION_FAILED`.
|
|
134
77
|
|
|
135
|
-
|
|
78
|
+
## Resource and trust boundaries
|
|
136
79
|
|
|
137
|
-
|
|
138
|
-
| -------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
139
|
-
| `INVALID_ARGUMENT` | `The Core operation received an invalid argument.` | The inspection input, reader, or signal violates its runtime contract. `operation` is `inspect-project`; `retryable` is `false`. | No structural result is returned. |
|
|
140
|
-
| `ABORTED` | `The Core operation was aborted.` | The shared signal is already aborted or becomes aborted during Core or adapter work. `operation` is `inspect-project`; `retryable` is `true` because a fresh call with a non-aborted signal may succeed. | The signal reason is preserved as `cause` when available; no partial result is returned. |
|
|
141
|
-
| `RESOURCE_LIMIT_EXCEEDED` | `A Core resource limit was exceeded.` | A distinct-entry, byte, file, manifest, raw-diagnostic, or raw-evidence budget is exceeded. `limit` identifies the budget; `retryable` is `false`. | No partial project, evidence, or diagnostics are returned. |
|
|
142
|
-
| `ADAPTER_EXECUTION_FAILED` | `A runtime adapter failed during inspection.` | An adapter throws unexpectedly or returns malformed, unsafe, cyclic, incorrectly namespaced, ungrounded, or out-of-scope output. `adapterId` identifies the adapter; `operation` is `inspect-project` for invocation failures and `validate-adapter` for invalid results; `retryable` is `false`. | Unexpected failures are preserved as `cause`; malformed results use a safe validation cause. No partial result is returned. |
|
|
80
|
+
Core uses independent limits for distinct entries, total bytes, file bytes, manifest bytes, diagnostics, and evidence. The adapter-facing repository adds per-page entry and byte limits. Core executes no repository code, follows no symlink, receives no host path or source credential, and returns logical paths only.
|
|
143
81
|
|
|
144
|
-
|
|
82
|
+
The release-5 calibration corpus drives these limits through the real CLI and PR Assurance across ordinary, 1,024-path, broad-relationship, Unicode, binary, diagnostic-heavy, and incomplete-provider cases. Repeated measurements establish ordinary cumulative headroom, while adversarial tests prove explicit bounded failure without treating a page, file, or operation limit as total repository capacity.
|
|
145
83
|
|
|
146
84
|
## Development
|
|
147
85
|
|
|
148
86
|
From the monorepo root:
|
|
149
87
|
|
|
150
88
|
```bash
|
|
151
|
-
pnpm
|
|
152
|
-
pnpm
|
|
153
|
-
pnpm
|
|
89
|
+
pnpm --filter @moldea.ai/core typecheck
|
|
90
|
+
pnpm --filter @moldea.ai/core build
|
|
91
|
+
pnpm --filter @moldea.ai/core test:unit
|
|
92
|
+
pnpm --filter @moldea.ai/core test:integration
|
|
93
|
+
pnpm --filter @moldea.ai/core test
|
|
154
94
|
```
|
|
155
95
|
|
|
156
|
-
|
|
96
|
+
Repository fixtures use `@moldea.ai/repository/memory`. Package and consumer checks verify the published surface separately from source tests.
|
package/dist/adapter/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { IIndexedAgent,
|
|
1
|
+
import type { IRepositoryEntry, IRepositoryEntryPage, IRepositoryEntryPageOptions, IRepositoryFilePage, IRepositoryFilePageOptions, IRepositoryOperationOptions, IRepositoryPath, IRepositorySnapshot } from '@moldea.ai/repository';
|
|
2
|
+
import type { IIndexedAgent, IIndexedDescriptionAsset } from '../contracts/index.js';
|
|
3
3
|
import type { IAdapterDiagnostic, IDiagnosticDetails } from '../diagnostics/index.js';
|
|
4
4
|
import type { IRepositoryFormatVersion, IRepositoryReference } from '../format/index.js';
|
|
5
5
|
export interface IRuntimeAdapter {
|
|
@@ -7,27 +7,108 @@ export interface IRuntimeAdapter {
|
|
|
7
7
|
readonly supportedRepositoryFormatVersions: readonly IRepositoryFormatVersion[];
|
|
8
8
|
/**
|
|
9
9
|
* Inspects the trusted provisional project through the supplied budget-aware reader.
|
|
10
|
-
* @param context The immutable
|
|
10
|
+
* @param context The immutable agent closure, reader, and cancellation signal.
|
|
11
11
|
* @returns A promise resolving to deterministic evidence and adapter diagnostics.
|
|
12
12
|
* @throws
|
|
13
|
-
* - INVALID_REPOSITORY_PATH:
|
|
14
|
-
* - ENTRY_NOT_FOUND:
|
|
15
|
-
* - ENTRY_NOT_FILE:
|
|
16
|
-
* - ENTRY_NOT_DIRECTORY:
|
|
13
|
+
* - INVALID_REPOSITORY_PATH: The repository path is invalid.
|
|
14
|
+
* - ENTRY_NOT_FOUND: The requested repository entry was not found.
|
|
15
|
+
* - ENTRY_NOT_FILE: The requested repository entry is not a file.
|
|
16
|
+
* - ENTRY_NOT_DIRECTORY: The requested repository entry is not a directory.
|
|
17
17
|
* - ACCESS_DENIED: Access to the repository source was denied.
|
|
18
18
|
* - SOURCE_UNAVAILABLE: The repository source is unavailable.
|
|
19
|
-
* - SNAPSHOT_CHANGED: The repository snapshot changed during
|
|
20
|
-
* - INVALID_SOURCE_DATA: The repository
|
|
21
|
-
* - RESOURCE_LIMIT_EXCEEDED: A
|
|
22
|
-
* - ABORTED:
|
|
19
|
+
* - SNAPSHOT_CHANGED: The repository snapshot changed during the operation.
|
|
20
|
+
* - INVALID_SOURCE_DATA: The repository source returned invalid data.
|
|
21
|
+
* - RESOURCE_LIMIT_EXCEEDED: A named repository resource limit was exceeded.
|
|
22
|
+
* - ABORTED: The repository operation was aborted.
|
|
23
23
|
*/
|
|
24
24
|
inspect(context: IRuntimeAdapterContext): Promise<IRuntimeAdapterResult>;
|
|
25
25
|
}
|
|
26
26
|
export interface IRuntimeAdapterContext {
|
|
27
|
-
readonly
|
|
28
|
-
readonly
|
|
29
|
-
readonly agents: readonly IIndexedAgent[];
|
|
27
|
+
readonly agent: IIndexedAgent;
|
|
28
|
+
readonly repository: IRuntimeAdapterRepository;
|
|
30
29
|
readonly signal?: AbortSignal;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves one exact same-runtime manifest agent binding without exposing an agent index.
|
|
32
|
+
* @param reference The runtime-agent source reference to match exactly.
|
|
33
|
+
* @returns The absent, ambiguous, or content-minimal matched agent result.
|
|
34
|
+
*/
|
|
35
|
+
resolveAgent(reference: IRepositoryReference): IRuntimeAdapterAgentResolution;
|
|
36
|
+
}
|
|
37
|
+
export interface IRuntimeAdapterResolvedAgent {
|
|
38
|
+
readonly declaration: IIndexedAgent['declaration'];
|
|
39
|
+
readonly description: IIndexedDescriptionAsset;
|
|
40
|
+
readonly handoffDescription: IIndexedDescriptionAsset | null;
|
|
41
|
+
readonly id: string;
|
|
42
|
+
}
|
|
43
|
+
export type IRuntimeAdapterAgentResolution = {
|
|
44
|
+
readonly kind: 'absent';
|
|
45
|
+
} | {
|
|
46
|
+
readonly candidateCount: number;
|
|
47
|
+
readonly kind: 'ambiguous';
|
|
48
|
+
} | {
|
|
49
|
+
readonly agent: IRuntimeAdapterResolvedAgent;
|
|
50
|
+
readonly kind: 'matched';
|
|
51
|
+
};
|
|
52
|
+
export interface IRuntimeAdapterRepository {
|
|
53
|
+
readonly limits: IRuntimeAdapterRepositoryLimits;
|
|
54
|
+
readonly snapshot: IRepositorySnapshot;
|
|
55
|
+
/**
|
|
56
|
+
* Looks up one exact logical path without following symlinks.
|
|
57
|
+
* @param path The validated repository-logical path.
|
|
58
|
+
* @param options Optional cancellation controls.
|
|
59
|
+
* @returns The detached entry or `null` when it is absent.
|
|
60
|
+
* @throws
|
|
61
|
+
* - INVALID_REPOSITORY_PATH: The repository path is invalid.
|
|
62
|
+
* - ACCESS_DENIED: Access to the repository source was denied.
|
|
63
|
+
* - SOURCE_UNAVAILABLE: The repository source is unavailable.
|
|
64
|
+
* - SNAPSHOT_CHANGED: The repository snapshot changed during inspection.
|
|
65
|
+
* - INVALID_SOURCE_DATA: The repository reader returned invalid contract data.
|
|
66
|
+
* - RESOURCE_LIMIT_EXCEEDED: A Core or repository resource limit was exceeded.
|
|
67
|
+
* - ABORTED: Adapter inspection or the repository operation was aborted.
|
|
68
|
+
*/
|
|
69
|
+
getEntry(path: IRepositoryPath, options?: IRepositoryOperationOptions): Promise<IRepositoryEntry | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Returns one deterministic bounded descendant page.
|
|
72
|
+
* @param options The prefix, keyset cursor, page bound, and cancellation controls.
|
|
73
|
+
* @returns One immutable source-bound page and continuation state.
|
|
74
|
+
* @throws
|
|
75
|
+
* - INVALID_REPOSITORY_PATH: The repository path is invalid.
|
|
76
|
+
* - ENTRY_NOT_FOUND: The requested repository entry was not found.
|
|
77
|
+
* - ENTRY_NOT_DIRECTORY: The requested repository entry is not a directory.
|
|
78
|
+
* - INVALID_PAGE_REQUEST: The repository page request is invalid.
|
|
79
|
+
* - ACCESS_DENIED: Access to the repository source was denied.
|
|
80
|
+
* - SOURCE_UNAVAILABLE: The repository source is unavailable.
|
|
81
|
+
* - SNAPSHOT_CHANGED: The repository snapshot changed during the operation.
|
|
82
|
+
* - INVALID_SOURCE_DATA: The repository source returned invalid data.
|
|
83
|
+
* - RESOURCE_LIMIT_EXCEEDED: A named repository resource limit was exceeded.
|
|
84
|
+
* - ABORTED: The repository operation was aborted.
|
|
85
|
+
*/
|
|
86
|
+
listEntriesPage(options: IRepositoryEntryPageOptions): Promise<IRepositoryEntryPage>;
|
|
87
|
+
/**
|
|
88
|
+
* Reads one bounded regular-file byte range without following symlinks.
|
|
89
|
+
* @param path The validated repository-logical file path.
|
|
90
|
+
* @param options The offset, byte bound, and cancellation controls.
|
|
91
|
+
* @returns One detached source-bound byte page and continuation offset.
|
|
92
|
+
* @throws
|
|
93
|
+
* - INVALID_REPOSITORY_PATH: The repository path is invalid.
|
|
94
|
+
* - ENTRY_NOT_FOUND: The requested repository entry was not found.
|
|
95
|
+
* - ENTRY_NOT_FILE: The requested repository entry is not a file.
|
|
96
|
+
* - INVALID_PAGE_REQUEST: The repository page request is invalid.
|
|
97
|
+
* - ACCESS_DENIED: Access to the repository source was denied.
|
|
98
|
+
* - SOURCE_UNAVAILABLE: The repository source is unavailable.
|
|
99
|
+
* - SNAPSHOT_CHANGED: The repository snapshot changed during the operation.
|
|
100
|
+
* - INVALID_SOURCE_DATA: The repository source returned invalid data.
|
|
101
|
+
* - RESOURCE_LIMIT_EXCEEDED: A named repository resource limit was exceeded.
|
|
102
|
+
* - ABORTED: The repository operation was aborted.
|
|
103
|
+
*/
|
|
104
|
+
readFilePage(path: IRepositoryPath, options: IRepositoryFilePageOptions): Promise<IRepositoryFilePage>;
|
|
105
|
+
}
|
|
106
|
+
export interface IRuntimeAdapterRepositoryLimits {
|
|
107
|
+
readonly maxEntries: number;
|
|
108
|
+
readonly maxFileBytes: number;
|
|
109
|
+
readonly maxPageBytes: number;
|
|
110
|
+
readonly maxPageEntries: number;
|
|
111
|
+
readonly maxTotalBytesRead: number;
|
|
31
112
|
}
|
|
32
113
|
export type IRuntimeAdapterEvidenceKind = 'runtime-package' | 'language' | 'agent-definition' | 'instruction-loader' | 'schema' | 'tool-registration' | 'skill-registration' | 'handoff-registration' | 'variable-provider' | 'runtime-pattern';
|
|
33
114
|
export interface IRuntimeAdapterEvidence {
|
|
@@ -45,4 +126,6 @@ export interface IRuntimeAdapterResult {
|
|
|
45
126
|
readonly diagnostics: readonly IAdapterDiagnostic[];
|
|
46
127
|
}
|
|
47
128
|
export type { IAdapterDiagnostic } from '../diagnostics/index.js';
|
|
129
|
+
export type { IIndexedAgent, IIndexedContextAsset, IIndexedDecision, IIndexedDescriptionAsset, IIndexedManifest, IIndexedMirror, IIndexedRuntimeGuidance, IIndexedTextAsset, } from '../contracts/index.js';
|
|
130
|
+
export { iterateRuntimeAdapterEntries, readRuntimeAdapterFile, } from '../adapter-repository/index.js';
|
|
48
131
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,2BAA2B,EAC3B,mBAAmB,EACnB,0BAA0B,EAC1B,2BAA2B,EAC3B,eAAe,EACf,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACtF,OAAO,KAAK,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAGzF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,iCAAiC,EAAE,SAAS,wBAAwB,EAAE,CAAC;IAEhF;;;;;;;;;;;;;;;OAeG;IACH,OAAO,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YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,gCAAgC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter-execution/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter-execution/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,uBAAuB,EAGxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAiB,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAOhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGlE,OAAO,KAAK,EAAE,oBAAoB,EAA2B,MAAM,qBAAqB,CAAC;AAEzF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAG9F,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,QAAQ,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACtD,QAAQ,CAAC,WAAW,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACrD;AA0ID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,mBAAmB,EAC5B,SAAS,4BAA4B,EACrC,SAAS,oBAAoB,EAC7B,SAAS,WAAW,KACnB,OAAO,CAAC,+BAA+B,CAwCzC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type IRepositoryEntry, type IRepositoryOperationOptions, type IRepositoryPath } from '@moldea.ai/repository';
|
|
2
|
+
import type { IRuntimeAdapterRepository } from '../adapter/index.js';
|
|
3
|
+
/** Reads one complete adapter source file through bounded repository pages. */
|
|
4
|
+
export declare const readRuntimeAdapterFile: (repository: IRuntimeAdapterRepository, path: IRepositoryPath, options?: IRepositoryOperationOptions) => Promise<Uint8Array>;
|
|
5
|
+
/** Iterates one adapter-scoped descendant listing through bounded pages. */
|
|
6
|
+
export declare const iterateRuntimeAdapterEntries: (repository: IRuntimeAdapterRepository, options?: IRepositoryOperationOptions & {
|
|
7
|
+
readonly prefix?: IRepositoryPath;
|
|
8
|
+
}) => AsyncIterable<IRepositoryEntry>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter-repository/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,gBAAgB,EACrB,KAAK,2BAA2B,EAChC,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAyBrE,+EAA+E;AAC/E,eAAO,MAAM,sBAAsB,GACjC,YAAY,yBAAyB,EACrC,MAAM,eAAe,EACrB,UAAU,2BAA2B,KACpC,OAAO,CAAC,UAAU,CAoEpB,CAAC;AAEF,4EAA4E;AAC5E,eAAO,MAAM,4BAA4B,GACvC,YAAY,yBAAyB,EACrC,UAAU,2BAA2B,GAAG;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAA;CAAE,KAC5E,aAAa,CAAC,gBAAgB,CAyDhC,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { IRuntimeAdapterEvidence } from '../adapter/index.js';
|
|
1
|
+
import type { IRuntimeAdapterEvidence, IRuntimeAdapterRepository } from '../adapter/index.js';
|
|
3
2
|
import type { ICoreResourceLimits, IIndexedAgent, IMoldeaProjectIndex } from '../contracts/index.js';
|
|
4
3
|
import type { IAdapterDiagnostic } from '../diagnostics/index.js';
|
|
5
4
|
export interface IValidatedRuntimeAdapterResult {
|
|
@@ -14,7 +13,7 @@ interface IAdapterValidationContext {
|
|
|
14
13
|
readonly adapterId: string;
|
|
15
14
|
readonly agents: readonly IIndexedAgent[];
|
|
16
15
|
readonly project: IMoldeaProjectIndex;
|
|
17
|
-
readonly repository:
|
|
16
|
+
readonly repository: IRuntimeAdapterRepository;
|
|
18
17
|
readonly limits: ICoreResourceLimits;
|
|
19
18
|
readonly signal?: AbortSignal;
|
|
20
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter-validation/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter-validation/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,uBAAuB,EAEvB,yBAAyB,EAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,yBAAyB,CAAC;AA8DjC,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,QAAQ,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACtD,QAAQ,CAAC,WAAW,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACrD;AAGD,MAAM,WAAW,2BAA2B;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,yBAAyB;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,yBAAyB,CAAC;IAC/C,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AA6cD;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,GAC1C,YAAY,SAAS,uBAAuB,EAAE,KAC7C,SAAS,uBAAuB,EAQlC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,4BAA4B,GACvC,WAAW,OAAO,EAClB,SAAS,yBAAyB,EAClC,cAAc,2BAA2B,KACxC,OAAO,CAAC,8BAA8B,CA4DxC,CAAC"}
|
package/dist/adapter.js
CHANGED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { n as CoreOperationException } from "./chunks/exceptions-DWsZTpqs.js";
|
|
2
|
+
import { REPOSITORY_ROOT, RepositorySourceException, compareRepositoryPaths, parseRepositoryPath } from "@moldea.ai/repository";
|
|
3
|
+
//#region src/adapter-repository/index.ts
|
|
4
|
+
var invalidSourceData = (operation, path) => {
|
|
5
|
+
throw new RepositorySourceException({
|
|
6
|
+
code: "INVALID_SOURCE_DATA",
|
|
7
|
+
operation,
|
|
8
|
+
path,
|
|
9
|
+
retryable: false
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var throwResourceLimitExceeded = (limit) => {
|
|
13
|
+
throw new CoreOperationException({
|
|
14
|
+
code: "RESOURCE_LIMIT_EXCEEDED",
|
|
15
|
+
limit,
|
|
16
|
+
operation: "validate-project"
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
/** Reads one complete adapter source file through bounded repository pages. */
|
|
20
|
+
var readRuntimeAdapterFile = async (repository, path, options) => {
|
|
21
|
+
const parsedPath = parseRepositoryPath(path);
|
|
22
|
+
const entry = await repository.getEntry(parsedPath, options);
|
|
23
|
+
if (entry === null) throw new RepositorySourceException({
|
|
24
|
+
code: "ENTRY_NOT_FOUND",
|
|
25
|
+
operation: "read-file-page",
|
|
26
|
+
path: parsedPath,
|
|
27
|
+
retryable: false
|
|
28
|
+
});
|
|
29
|
+
if (entry.type !== "file" || entry.byteLength === null) throw new RepositorySourceException({
|
|
30
|
+
code: "ENTRY_NOT_FILE",
|
|
31
|
+
operation: "read-file-page",
|
|
32
|
+
path: parsedPath,
|
|
33
|
+
retryable: false
|
|
34
|
+
});
|
|
35
|
+
if (entry.byteLength > repository.limits.maxFileBytes) return throwResourceLimitExceeded("maxFileBytes");
|
|
36
|
+
const content = new Uint8Array(entry.byteLength);
|
|
37
|
+
let offset = 0;
|
|
38
|
+
let isFirstPage = true;
|
|
39
|
+
while (isFirstPage || offset < entry.byteLength) {
|
|
40
|
+
isFirstPage = false;
|
|
41
|
+
options?.signal?.throwIfAborted();
|
|
42
|
+
const page = await repository.readFilePage(parsedPath, {
|
|
43
|
+
maxBytes: Math.min(repository.limits.maxPageBytes, Math.max(1, entry.byteLength - offset)),
|
|
44
|
+
offset,
|
|
45
|
+
...options?.signal === void 0 ? {} : { signal: options.signal }
|
|
46
|
+
});
|
|
47
|
+
if (page.snapshot.id !== repository.snapshot.id || page.offset !== offset || page.totalBytes !== entry.byteLength || !(page.bytes instanceof Uint8Array) || page.bytes.byteLength > repository.limits.maxPageBytes || page.bytes.byteLength > content.byteLength - offset || page.bytes.byteLength === 0 && !page.isComplete) return invalidSourceData("read-file-page", parsedPath);
|
|
48
|
+
content.set(page.bytes, offset);
|
|
49
|
+
offset += page.bytes.byteLength;
|
|
50
|
+
if (page.isComplete) {
|
|
51
|
+
if (page.nextOffset !== null || offset !== content.byteLength) return invalidSourceData("read-file-page", parsedPath);
|
|
52
|
+
return content;
|
|
53
|
+
}
|
|
54
|
+
if (page.nextOffset !== offset) return invalidSourceData("read-file-page", parsedPath);
|
|
55
|
+
}
|
|
56
|
+
return invalidSourceData("read-file-page", parsedPath);
|
|
57
|
+
};
|
|
58
|
+
/** Iterates one adapter-scoped descendant listing through bounded pages. */
|
|
59
|
+
var iterateRuntimeAdapterEntries = (repository, options) => {
|
|
60
|
+
const prefix = options?.prefix === void 0 ? REPOSITORY_ROOT : parseRepositoryPath(options.prefix);
|
|
61
|
+
return { async *[Symbol.asyncIterator]() {
|
|
62
|
+
let cursor;
|
|
63
|
+
let entryCount = 0;
|
|
64
|
+
let previousPath = null;
|
|
65
|
+
do {
|
|
66
|
+
options?.signal?.throwIfAborted();
|
|
67
|
+
const page = await repository.listEntriesPage({
|
|
68
|
+
...cursor === void 0 ? {} : { cursor },
|
|
69
|
+
maxEntries: repository.limits.maxPageEntries,
|
|
70
|
+
prefix,
|
|
71
|
+
...options?.signal === void 0 ? {} : { signal: options.signal }
|
|
72
|
+
});
|
|
73
|
+
if (page.snapshot.id !== repository.snapshot.id || page.entries.length > repository.limits.maxPageEntries || page.entries.length === 0 && !page.isComplete) return invalidSourceData("list-entries-page", prefix);
|
|
74
|
+
for (const entry of page.entries) {
|
|
75
|
+
if (previousPath !== null && compareRepositoryPaths(previousPath, entry.path) >= 0) return invalidSourceData("list-entries-page", entry.path);
|
|
76
|
+
entryCount += 1;
|
|
77
|
+
if (entryCount > repository.limits.maxEntries) return throwResourceLimitExceeded("maxEntries");
|
|
78
|
+
previousPath = entry.path;
|
|
79
|
+
yield entry;
|
|
80
|
+
}
|
|
81
|
+
if (page.isComplete) {
|
|
82
|
+
if (page.nextCursor !== null) return invalidSourceData("list-entries-page", prefix);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (page.nextCursor === null || page.nextCursor === cursor) return invalidSourceData("list-entries-page", prefix);
|
|
86
|
+
cursor = page.nextCursor;
|
|
87
|
+
} while (true);
|
|
88
|
+
} };
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
export { iterateRuntimeAdapterEntries, readRuntimeAdapterFile };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","names":[],"sources":["../src/adapter-repository/index.ts"],"sourcesContent":["import {\n REPOSITORY_ROOT,\n RepositorySourceException,\n compareRepositoryPaths,\n parseRepositoryPath,\n type IRepositoryEntry,\n type IRepositoryOperationOptions,\n type IRepositoryPath,\n} from '@moldea.ai/repository';\n\nimport type { IRuntimeAdapterRepository } from '../adapter/index.js';\nimport { CoreOperationException } from '../exceptions/index.js';\n\nconst invalidSourceData = (\n operation: 'list-entries-page' | 'read-file-page',\n path: IRepositoryPath,\n): never => {\n throw new RepositorySourceException({\n code: 'INVALID_SOURCE_DATA',\n operation,\n path,\n retryable: false,\n });\n};\n\nconst throwResourceLimitExceeded = (\n limit: 'maxEntries' | 'maxFileBytes' | 'maxTotalBytesRead',\n): never => {\n throw new CoreOperationException({\n code: 'RESOURCE_LIMIT_EXCEEDED',\n limit,\n operation: 'validate-project',\n });\n};\n\n/** Reads one complete adapter source file through bounded repository pages. */\nexport const readRuntimeAdapterFile = async (\n repository: IRuntimeAdapterRepository,\n path: IRepositoryPath,\n options?: IRepositoryOperationOptions,\n): Promise<Uint8Array> => {\n const parsedPath = parseRepositoryPath(path);\n const entry = await repository.getEntry(parsedPath, options);\n\n if (entry === null) {\n throw new RepositorySourceException({\n code: 'ENTRY_NOT_FOUND',\n operation: 'read-file-page',\n path: parsedPath,\n retryable: false,\n });\n }\n\n if (entry.type !== 'file' || entry.byteLength === null) {\n throw new RepositorySourceException({\n code: 'ENTRY_NOT_FILE',\n operation: 'read-file-page',\n path: parsedPath,\n retryable: false,\n });\n }\n\n if (entry.byteLength > repository.limits.maxFileBytes) {\n return throwResourceLimitExceeded('maxFileBytes');\n }\n\n const content = new Uint8Array(entry.byteLength);\n let offset = 0;\n let isFirstPage = true;\n\n while (isFirstPage || offset < entry.byteLength) {\n isFirstPage = false;\n options?.signal?.throwIfAborted();\n const page = await repository.readFilePage(parsedPath, {\n maxBytes: Math.min(repository.limits.maxPageBytes, Math.max(1, entry.byteLength - offset)),\n offset,\n ...(options?.signal === undefined ? {} : { signal: options.signal }),\n });\n\n if (\n page.snapshot.id !== repository.snapshot.id ||\n page.offset !== offset ||\n page.totalBytes !== entry.byteLength ||\n !(page.bytes instanceof Uint8Array) ||\n page.bytes.byteLength > repository.limits.maxPageBytes ||\n page.bytes.byteLength > content.byteLength - offset ||\n (page.bytes.byteLength === 0 && !page.isComplete)\n ) {\n return invalidSourceData('read-file-page', parsedPath);\n }\n\n content.set(page.bytes, offset);\n offset += page.bytes.byteLength;\n\n if (page.isComplete) {\n if (page.nextOffset !== null || offset !== content.byteLength) {\n return invalidSourceData('read-file-page', parsedPath);\n }\n\n return content;\n }\n\n if (page.nextOffset !== offset) {\n return invalidSourceData('read-file-page', parsedPath);\n }\n }\n\n return invalidSourceData('read-file-page', parsedPath);\n};\n\n/** Iterates one adapter-scoped descendant listing through bounded pages. */\nexport const iterateRuntimeAdapterEntries = (\n repository: IRuntimeAdapterRepository,\n options?: IRepositoryOperationOptions & { readonly prefix?: IRepositoryPath },\n): AsyncIterable<IRepositoryEntry> => {\n const prefix =\n options?.prefix === undefined ? REPOSITORY_ROOT : parseRepositoryPath(options.prefix);\n\n return {\n async *[Symbol.asyncIterator](): AsyncIterator<IRepositoryEntry> {\n let cursor: string | undefined;\n let entryCount = 0;\n let previousPath: IRepositoryPath | null = null;\n\n do {\n options?.signal?.throwIfAborted();\n const page = await repository.listEntriesPage({\n ...(cursor === undefined ? {} : { cursor }),\n maxEntries: repository.limits.maxPageEntries,\n prefix,\n ...(options?.signal === undefined ? {} : { signal: options.signal }),\n });\n\n if (\n page.snapshot.id !== repository.snapshot.id ||\n page.entries.length > repository.limits.maxPageEntries ||\n (page.entries.length === 0 && !page.isComplete)\n ) {\n return invalidSourceData('list-entries-page', prefix);\n }\n\n for (const entry of page.entries) {\n if (previousPath !== null && compareRepositoryPaths(previousPath, entry.path) >= 0) {\n return invalidSourceData('list-entries-page', entry.path);\n }\n\n entryCount += 1;\n if (entryCount > repository.limits.maxEntries) {\n return throwResourceLimitExceeded('maxEntries');\n }\n\n previousPath = entry.path;\n yield entry;\n }\n\n if (page.isComplete) {\n if (page.nextCursor !== null) {\n return invalidSourceData('list-entries-page', prefix);\n }\n\n return;\n }\n\n if (page.nextCursor === null || page.nextCursor === cursor) {\n return invalidSourceData('list-entries-page', prefix);\n }\n\n cursor = page.nextCursor;\n } while (true);\n },\n };\n};\n"],"mappings":";;;AAaA,IAAM,qBACJ,WACA,SACU;CACV,MAAM,IAAI,0BAA0B;EAClC,MAAM;EACN;EACA;EACA,WAAW;CACb,CAAC;AACH;AAEA,IAAM,8BACJ,UACU;CACV,MAAM,IAAI,uBAAuB;EAC/B,MAAM;EACN;EACA,WAAW;CACb,CAAC;AACH;;AAGA,IAAa,yBAAyB,OACpC,YACA,MACA,YACwB;CACxB,MAAM,aAAa,oBAAoB,IAAI;CAC3C,MAAM,QAAQ,MAAM,WAAW,SAAS,YAAY,OAAO;CAE3D,IAAI,UAAU,MACZ,MAAM,IAAI,0BAA0B;EAClC,MAAM;EACN,WAAW;EACX,MAAM;EACN,WAAW;CACb,CAAC;CAGH,IAAI,MAAM,SAAS,UAAU,MAAM,eAAe,MAChD,MAAM,IAAI,0BAA0B;EAClC,MAAM;EACN,WAAW;EACX,MAAM;EACN,WAAW;CACb,CAAC;CAGH,IAAI,MAAM,aAAa,WAAW,OAAO,cACvC,OAAO,2BAA2B,cAAc;CAGlD,MAAM,UAAU,IAAI,WAAW,MAAM,UAAU;CAC/C,IAAI,SAAS;CACb,IAAI,cAAc;CAElB,OAAO,eAAe,SAAS,MAAM,YAAY;EAC/C,cAAc;EACd,SAAS,QAAQ,eAAe;EAChC,MAAM,OAAO,MAAM,WAAW,aAAa,YAAY;GACrD,UAAU,KAAK,IAAI,WAAW,OAAO,cAAc,KAAK,IAAI,GAAG,MAAM,aAAa,MAAM,CAAC;GACzF;GACA,GAAI,SAAS,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,QAAQ,OAAO;EACpE,CAAC;EAED,IACE,KAAK,SAAS,OAAO,WAAW,SAAS,MACzC,KAAK,WAAW,UAChB,KAAK,eAAe,MAAM,cAC1B,EAAE,KAAK,iBAAiB,eACxB,KAAK,MAAM,aAAa,WAAW,OAAO,gBAC1C,KA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MAAM;GACR;GAEA,IAAI,KAAK,YAAY;IACnB,IAAI,KAAK,eAAe,MACtB,OAAO,kBAAkB,qBAAqB,MAAM;IAGtD;GACF;GAEA,IAAI,KAAK,eAAe,QAAQ,KAAK,eAAe,QAClD,OAAO,kBAAkB,qBAAqB,MAAM;GAGtD,SAAS,KAAK;EAChB,SAAS;CACX,EACF;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type IRepositoryReader } from '@moldea.ai/repository';
|
|
2
1
|
import type { ICanonicalDiscoveryResult } from '../canonical-discovery/index.js';
|
|
3
2
|
import type { IIndexedDescriptionAsset, IIndexedTextAsset } from '../contracts/index.js';
|
|
4
3
|
import type { ICoreDiagnostic } from '../diagnostics/index.js';
|
|
5
4
|
import type { IAgentManifestEntry, IMoldeaManifestV1 } from '../format/index.js';
|
|
6
5
|
import { type ICoreOptionsSnapshot } from '../options/index.js';
|
|
6
|
+
import type { IRepositoryInspectionReader } from '../repository-inspection-session/index.js';
|
|
7
7
|
export interface IInspectedAgentAssets {
|
|
8
8
|
readonly id: string;
|
|
9
9
|
readonly declaration: IAgentManifestEntry;
|
|
@@ -34,5 +34,5 @@ export interface IAgentAssetInspectionResult {
|
|
|
34
34
|
* - RESOURCE_LIMIT_EXCEEDED: A Core or repository resource limit was exceeded.
|
|
35
35
|
* - ABORTED: Agent inspection or a repository operation was aborted.
|
|
36
36
|
*/
|
|
37
|
-
export declare const inspectAgentAssets: (repository:
|
|
37
|
+
export declare const inspectAgentAssets: (repository: IRepositoryInspectionReader, manifest: IMoldeaManifestV1, discovery: ICanonicalDiscoveryResult, options: ICoreOptionsSnapshot, signal?: AbortSignal) => Promise<IAgentAssetInspectionResult>;
|
|
38
38
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent-assets/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent-assets/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAKzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,EAAsC,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACpG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AAO7F,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,wBAAwB,GAAG,IAAI,CAAC;IACtD,QAAQ,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC/C,QAAQ,CAAC,kBAAkB,EAAE,wBAAwB,GAAG,IAAI,CAAC;CAC9D;AAGD,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAClD,QAAQ,CAAC,WAAW,EAAE,SAAS,eAAe,EAAE,CAAC;CAClD;AAyFD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,kBAAkB,GAC7B,YAAY,2BAA2B,EACvC,UAAU,iBAAiB,EAC3B,WAAW,yBAAyB,EACpC,SAAS,oBAAoB,EAC7B,SAAS,WAAW,KACnB,OAAO,CAAC,2BAA2B,CAiIrC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ICanonicalContentPageInput, ICanonicalContentPageResult } from '../contracts/index.js';
|
|
2
|
+
import type { ICoreOptionsSnapshot } from '../options/index.js';
|
|
3
|
+
/** Reads one explicit canonical file range without materializing the complete file. */
|
|
4
|
+
export declare const readCanonicalContentPage: (input: ICanonicalContentPageInput, options: ICoreOptionsSnapshot) => Promise<ICanonicalContentPageResult>;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canonical-content-page/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAoHhE,uFAAuF;AACvF,eAAO,MAAM,wBAAwB,GACnC,OAAO,0BAA0B,EACjC,SAAS,oBAAoB,KAC5B,OAAO,CAAC,2BAA2B,CAwGrC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type IRepositoryEntry, type IRepositoryPath
|
|
1
|
+
import { type IRepositoryEntry, type IRepositoryPath } from '@moldea.ai/repository';
|
|
2
2
|
import type { ICoreResourceLimits } from '../contracts/index.js';
|
|
3
3
|
import type { ICoreDiagnostic } from '../diagnostics/index.js';
|
|
4
|
+
import type { IRepositoryInspectionReader } from '../repository-inspection-session/index.js';
|
|
4
5
|
export interface IDiscoveredAgentAssets {
|
|
5
6
|
readonly id: string;
|
|
6
7
|
readonly path: IRepositoryPath;
|
|
@@ -43,5 +44,5 @@ export interface ICanonicalDiscoveryFoundationEntries {
|
|
|
43
44
|
* - RESOURCE_LIMIT_EXCEEDED: A Core or repository resource limit was exceeded.
|
|
44
45
|
* - ABORTED: Discovery or a repository operation was aborted.
|
|
45
46
|
*/
|
|
46
|
-
export declare const discoverCanonicalAssets: (repository:
|
|
47
|
+
export declare const discoverCanonicalAssets: (repository: IRepositoryInspectionReader, limits: ICoreResourceLimits, signal?: AbortSignal, foundations?: ICanonicalDiscoveryFoundationEntries) => Promise<ICanonicalDiscoveryResult>;
|
|
47
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canonical-discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canonical-discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAM/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAKjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG/D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AAO7F,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,kBAAkB,EAAE,eAAe,GAAG,IAAI,CAAC;CACrD;AAGD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,QAAQ,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IAC/C,QAAQ,CAAC,eAAe,EAAE,SAAS,eAAe,EAAE,CAAC;IACrD,QAAQ,CAAC,MAAM,EAAE,SAAS,sBAAsB,EAAE,CAAC;CACpD;AAGD,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