@sentropic/h2a-runtime 0.98.7-rc.1 → 0.98.7-rc.3

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.
Files changed (104) hide show
  1. package/dist/agent-launch-args.d.ts.map +1 -1
  2. package/dist/agent-launch-args.js +5 -5
  3. package/dist/agent-launch-args.js.map +1 -1
  4. package/dist/agy-claude.d.ts +2 -0
  5. package/dist/agy-claude.d.ts.map +1 -0
  6. package/dist/agy-claude.js +3 -0
  7. package/dist/agy-claude.js.map +1 -0
  8. package/dist/agy-headless.d.ts +11 -0
  9. package/dist/agy-headless.d.ts.map +1 -0
  10. package/dist/agy-headless.js +104 -0
  11. package/dist/agy-headless.js.map +1 -0
  12. package/dist/claude-code-cli-isolation.d.ts +53 -0
  13. package/dist/claude-code-cli-isolation.d.ts.map +1 -0
  14. package/dist/claude-code-cli-isolation.js +277 -0
  15. package/dist/claude-code-cli-isolation.js.map +1 -0
  16. package/dist/claude-code-cli-lifecycle.d.ts +80 -0
  17. package/dist/claude-code-cli-lifecycle.d.ts.map +1 -0
  18. package/dist/claude-code-cli-lifecycle.js +402 -0
  19. package/dist/claude-code-cli-lifecycle.js.map +1 -0
  20. package/dist/claude-code-cli-runner.d.ts +89 -0
  21. package/dist/claude-code-cli-runner.d.ts.map +1 -0
  22. package/dist/claude-code-cli-runner.js +659 -0
  23. package/dist/claude-code-cli-runner.js.map +1 -0
  24. package/dist/claude-seat-input.d.ts +47 -0
  25. package/dist/claude-seat-input.d.ts.map +1 -0
  26. package/dist/claude-seat-input.js +272 -0
  27. package/dist/claude-seat-input.js.map +1 -0
  28. package/dist/claude-seat-mesh-contract.d.ts +88 -0
  29. package/dist/claude-seat-mesh-contract.d.ts.map +1 -0
  30. package/dist/claude-seat-mesh-contract.js +13 -0
  31. package/dist/claude-seat-mesh-contract.js.map +1 -0
  32. package/dist/delegate.d.ts +10 -0
  33. package/dist/delegate.d.ts.map +1 -1
  34. package/dist/delegate.js +29 -0
  35. package/dist/delegate.js.map +1 -1
  36. package/dist/gateway-host/claude-seat-client.d.ts +32 -0
  37. package/dist/gateway-host/claude-seat-client.d.ts.map +1 -0
  38. package/dist/gateway-host/claude-seat-client.js +38 -0
  39. package/dist/gateway-host/claude-seat-client.js.map +1 -0
  40. package/dist/gateway-host/host.d.ts +6 -0
  41. package/dist/gateway-host/host.d.ts.map +1 -1
  42. package/dist/gateway-host/host.js +24 -3
  43. package/dist/gateway-host/host.js.map +1 -1
  44. package/dist/gateway-host/live-auth.d.ts +62 -0
  45. package/dist/gateway-host/live-auth.d.ts.map +1 -0
  46. package/dist/gateway-host/live-auth.js +87 -0
  47. package/dist/gateway-host/live-auth.js.map +1 -0
  48. package/dist/gateway-host/live-declarations.d.ts.map +1 -1
  49. package/dist/gateway-host/live-declarations.js +13 -7
  50. package/dist/gateway-host/live-declarations.js.map +1 -1
  51. package/dist/gateway-host/live-disclosure.d.ts +124 -0
  52. package/dist/gateway-host/live-disclosure.d.ts.map +1 -0
  53. package/dist/gateway-host/live-disclosure.js +347 -0
  54. package/dist/gateway-host/live-disclosure.js.map +1 -0
  55. package/dist/gateway-host/live-github.d.ts +11 -0
  56. package/dist/gateway-host/live-github.d.ts.map +1 -0
  57. package/dist/gateway-host/live-github.js +374 -0
  58. package/dist/gateway-host/live-github.js.map +1 -0
  59. package/dist/gateway-host/live-host.d.ts +20 -0
  60. package/dist/gateway-host/live-host.d.ts.map +1 -0
  61. package/dist/gateway-host/live-host.js +14 -0
  62. package/dist/gateway-host/live-host.js.map +1 -0
  63. package/dist/gateway-host/live-object-store.d.ts +35 -0
  64. package/dist/gateway-host/live-object-store.d.ts.map +1 -0
  65. package/dist/gateway-host/live-object-store.js +447 -0
  66. package/dist/gateway-host/live-object-store.js.map +1 -0
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +211 -22
  69. package/dist/index.js.map +1 -1
  70. package/dist/llm-mesh-accounts.d.ts +70 -4
  71. package/dist/llm-mesh-accounts.d.ts.map +1 -1
  72. package/dist/llm-mesh-accounts.js +296 -9
  73. package/dist/llm-mesh-accounts.js.map +1 -1
  74. package/dist/native-host.d.ts +1 -1
  75. package/dist/native-host.d.ts.map +1 -1
  76. package/dist/native-host.js +3 -12
  77. package/dist/native-host.js.map +1 -1
  78. package/dist/native-terminal/host.d.ts +6 -1
  79. package/dist/native-terminal/host.d.ts.map +1 -1
  80. package/dist/native-terminal/host.js +6 -25
  81. package/dist/native-terminal/host.js.map +1 -1
  82. package/dist/proc-identity.d.ts +31 -0
  83. package/dist/proc-identity.d.ts.map +1 -1
  84. package/dist/proc-identity.js +54 -0
  85. package/dist/proc-identity.js.map +1 -1
  86. package/dist/prompt-delivery.d.ts +3 -0
  87. package/dist/prompt-delivery.d.ts.map +1 -1
  88. package/dist/prompt-delivery.js +8 -3
  89. package/dist/prompt-delivery.js.map +1 -1
  90. package/dist/tmux.d.ts +3 -1
  91. package/dist/tmux.d.ts.map +1 -1
  92. package/dist/tmux.js +13 -9
  93. package/dist/tmux.js.map +1 -1
  94. package/dist/vendor/engram-live/contracts.d.ts +619 -2
  95. package/dist/vendor/engram-live/contracts.js +1201 -25
  96. package/dist/vendor/engram-live/integration.d.ts +44 -4
  97. package/dist/vendor/engram-live/integration.js +65 -5
  98. package/dist/vendor/engram-live/pr-sync.d.ts +144 -0
  99. package/dist/vendor/engram-live/pr-sync.js +411 -0
  100. package/dist/vendor/engram-live/registration.d.ts +2 -2
  101. package/dist/vendor/engram-live/registration.js +2 -4
  102. package/dist/vendor/engram-live/retention.d.ts +56 -0
  103. package/dist/vendor/engram-live/retention.js +179 -0
  104. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
- // Vendored types for the sibling .js — see its provenance header; do not hand-edit.
2
- import { type CapabilityId, type CapabilityStatus, type CoverageReport, type FactBatchDto, type GrammarCoverageDto, type ValidationResult, type WorkspaceDeclarationDto } from "./contracts.js";
1
+ // Vendored from rhanka/engram@545a57b8911ab108e84fa1778e0f268fe11bf1de: engram-live/integration.ts.
2
+ // Compiled with TypeScript 5.9.3 (ES2022/NodeNext, declarations); do not hand-edit.
3
+ import { type CapabilityId, type CapabilityStatus, type CoverageReport, type FactBatchDto, type GrammarCoverageDto, type LiveScope, type ValidationResult, type WorkspaceDeclarationDto } from "./contracts.js";
3
4
  export interface GitPort {
4
5
  /** Bounded Git read seam; operations arrive with L2a/L2b. Unused in L1b. */
5
6
  readonly liveGitSeam: "host-git";
@@ -18,11 +19,51 @@ export interface ContentPort {
18
19
  }
19
20
  export interface FactSinkPort {
20
21
  /** Durable receipt of a fact batch; separate from publication (spec §3). */
21
- deliver(batch: FactBatchDto): Promise<{
22
+ deliver(batch: FactBatchDto, fencingToken: ScopeFencingTokenDto): Promise<{
22
23
  received: true;
23
24
  batchId: string;
25
+ receiptId?: string;
24
26
  }>;
25
27
  }
28
+ /**
29
+ * Mandatory scope fencing token threaded from E (L6b) across every write,
30
+ * cursor, and publication port to S (L3a/L3b-S) (Opus Amendment 2).
31
+ */
32
+ export interface ScopeFencingTokenDto {
33
+ readonly tokenId: string;
34
+ readonly scope: LiveScope;
35
+ readonly epoch: number;
36
+ readonly epochId: string;
37
+ readonly declarationRevision: number;
38
+ readonly projectionIncarnation: string;
39
+ readonly issuedAt: number;
40
+ readonly expiresAt: number;
41
+ }
42
+ /**
43
+ * Required S-side storage contract for L3a / L3b-S (Opus Amendment 2):
44
+ * Every storage write, cursor update, and generation publication MUST atomically
45
+ * verify the caller's ScopeFencingTokenDto against the active writer lease and
46
+ * storage-owned projection incarnation P inside the storage transaction.
47
+ */
48
+ export interface StorageIncarnationPort {
49
+ incarnation(): string;
50
+ hasGeneration(incarnation: string, generationId: string): boolean;
51
+ validateFencingToken(token: ScopeFencingTokenDto, nowMs: number): ValidationResult;
52
+ }
53
+ export declare const REQUIRED_STORAGE_FENCING_CONTRACT: {
54
+ readonly enforcedByLots: readonly ["L3a", "L3b-S"];
55
+ readonly requireAtomicLeaseCheckOnFactWrite: true;
56
+ readonly requireAtomicLeaseCheckOnCursorWrite: true;
57
+ readonly requireAtomicLeaseCheckOnGenerationPublish: true;
58
+ readonly requireStorageOwnedIncarnationBinding: true;
59
+ readonly requireAtomicLeaseCheckOnProgressReadWrite: true;
60
+ readonly requireAtomicLeaseCheckOnPark: true;
61
+ readonly requireAtomicLeaseCheckOnRelationRepair: true;
62
+ readonly requireAtomicLeaseCheckOnMarkerDelete: true;
63
+ readonly requireSourceAndProjectionEqualityOnGenerationPublish: true;
64
+ readonly requireSynchronousLeaseRevocationOnShutdown: true;
65
+ };
66
+ export declare function validateScopeFencingToken(candidate: unknown, expectedScope?: LiveScope, expectedIncarnation?: string, nowMs?: number): ValidationResult;
26
67
  export interface CachePort {
27
68
  /** Bounded, versioned cache seam; wired by L2b/L5. Unused in L1b. */
28
69
  readonly liveCacheSeam: "host-cache";
@@ -70,4 +111,3 @@ export declare function createLiveFactory(options: CreateLiveFactoryOptions): Li
70
111
  /** The advertised grammar matrix of this build, from the pinned manifest data. */
71
112
  export declare const ADVERTISED_GRAMMAR_LANGUAGES: readonly string[];
72
113
  export { deriveCloneIdentity, deriveWorktreeIdentity, deriveDeclarationIdentity, type DeclarationIdentityDto, type DeriveCloneIdentityInput, type DeriveWorktreeIdentityInput, type DeriveDeclarationIdentityInput, } from "./registration.js";
73
- //# sourceMappingURL=integration.d.ts.map
@@ -1,8 +1,5 @@
1
- // Vendored from @sentropic/engram-live 0.1.0 dist/integration.js — same
2
- // provenance as the sibling contracts.js header (graphify@70ebdfee, pinned
3
- // tarball sha512 in the GUARD test). Only the derive* re-exports are
4
- // consumed by H; the factory reads grammars lazily through injected ports.
5
- // Portable: node: builtins plus siblings only. Do not hand-edit.
1
+ // Vendored from rhanka/engram@545a57b8911ab108e84fa1778e0f268fe11bf1de: engram-live/integration.ts.
2
+ // Compiled with TypeScript 5.9.3 (ES2022/NodeNext, declarations); do not hand-edit.
6
3
  // @sentropic/engram-live/integration — executable neutral factory
7
4
  // (spec/SPEC_LIVE_GIT_INDEXING.md §2–3, §11; plan/09 L1b).
8
5
  //
@@ -20,6 +17,69 @@ import { createHash } from "node:crypto";
20
17
  import { dirname, join } from "node:path";
21
18
  import { fileURLToPath } from "node:url";
22
19
  import { ADVERTISED_LANGUAGES, CAPABILITY_IDS, CAPABILITY_PLANNED_LOTS, GRAMMAR_UNAVAILABLE_REASON, NOT_IMPLEMENTED_REASON, validateFactBatch, validateWorkspaceDeclaration, } from "./contracts.js";
20
+ export const REQUIRED_STORAGE_FENCING_CONTRACT = {
21
+ enforcedByLots: ["L3a", "L3b-S"],
22
+ requireAtomicLeaseCheckOnFactWrite: true,
23
+ requireAtomicLeaseCheckOnCursorWrite: true,
24
+ requireAtomicLeaseCheckOnGenerationPublish: true,
25
+ requireStorageOwnedIncarnationBinding: true,
26
+ requireAtomicLeaseCheckOnProgressReadWrite: true,
27
+ requireAtomicLeaseCheckOnPark: true,
28
+ requireAtomicLeaseCheckOnRelationRepair: true,
29
+ requireAtomicLeaseCheckOnMarkerDelete: true,
30
+ requireSourceAndProjectionEqualityOnGenerationPublish: true,
31
+ requireSynchronousLeaseRevocationOnShutdown: true,
32
+ };
33
+ export function validateScopeFencingToken(candidate, expectedScope, expectedIncarnation, nowMs) {
34
+ const errors = [];
35
+ if (typeof candidate !== "object" || candidate === null) {
36
+ return { ok: false, errors: ["fencing token must be a non-null object"] };
37
+ }
38
+ const t = candidate;
39
+ if (!t.scope || typeof t.scope.tenant !== "string" || typeof t.scope.clone !== "string" || typeof t.scope.worktree !== "string")
40
+ errors.push("fencing token requires a complete scope");
41
+ if (!Number.isSafeInteger(t.declarationRevision) || (t.declarationRevision ?? 0) < 1)
42
+ errors.push("fencing token requires declaration revision");
43
+ if (typeof t.epochId !== "string" || !t.epochId)
44
+ errors.push("fencing token requires epoch identity");
45
+ for (const value of [t.tokenId, t.epochId, t.projectionIncarnation, t.scope?.tenant, t.scope?.clone, t.scope?.worktree])
46
+ if (typeof value !== "string" || value.length < 1 || value.length > 1024)
47
+ errors.push("fencing identity must be bounded");
48
+ if (typeof t.tokenId !== "string" || t.tokenId.length === 0) {
49
+ errors.push("fencing token requires a non-empty tokenId");
50
+ }
51
+ if (typeof t.epoch !== "number" || !Number.isSafeInteger(t.epoch) || t.epoch < 1) {
52
+ errors.push("fencing token requires a positive integer epoch");
53
+ }
54
+ if (typeof t.projectionIncarnation !== "string" || t.projectionIncarnation.length === 0) {
55
+ errors.push("fencing token requires a non-empty projectionIncarnation");
56
+ }
57
+ if (typeof t.issuedAt !== "number" ||
58
+ typeof t.expiresAt !== "number" ||
59
+ !Number.isFinite(t.issuedAt) ||
60
+ !Number.isFinite(t.expiresAt) ||
61
+ t.expiresAt <= t.issuedAt) {
62
+ errors.push("fencing token requires finite issuedAt < expiresAt");
63
+ }
64
+ if (expectedScope !== undefined && t.scope !== undefined) {
65
+ if (t.scope.tenant !== expectedScope.tenant ||
66
+ t.scope.clone !== expectedScope.clone ||
67
+ t.scope.worktree !== expectedScope.worktree) {
68
+ errors.push("fencing token scope does not match target scope");
69
+ }
70
+ }
71
+ if (expectedIncarnation !== undefined &&
72
+ t.projectionIncarnation !== undefined &&
73
+ t.projectionIncarnation !== expectedIncarnation) {
74
+ errors.push("fencing token projectionIncarnation does not match active storage incarnation P");
75
+ }
76
+ if (nowMs !== undefined && typeof t.expiresAt === "number" && nowMs >= t.expiresAt) {
77
+ errors.push("fencing token is expired");
78
+ }
79
+ if (nowMs !== undefined && typeof t.issuedAt === "number" && t.issuedAt > nowMs)
80
+ errors.push("fencing token is not yet valid");
81
+ return { ok: errors.length === 0, errors };
82
+ }
23
83
  function decodeJson(bytes) {
24
84
  return JSON.parse(new TextDecoder().decode(bytes));
25
85
  }
@@ -0,0 +1,144 @@
1
+ import { type GithubRepositoryDto, type PrCoverageDto, type PrObjectJobDto, type PrPageDto, type PrSyncCursorDto, type PrSyncErrorKind, type PullRequestFactDto } from "./contracts.js";
2
+ /** Neutral PR sync extractor version (checkpoints are per version). */
3
+ export declare const PR_SYNC_EXTRACTOR_VERSION = "engram-live/pr-sync/1";
4
+ /**
5
+ * Overlap re-ask on incremental retries (milliseconds): the resume window
6
+ * re-reads recently updated PRs so a page that moved during enumeration is
7
+ * deduplicated instead of lost. Pure constant, consumed by hosts.
8
+ */
9
+ export declare const PR_SYNC_OVERLAP_MS: number;
10
+ export declare class PrSyncError extends Error {
11
+ readonly kind: PrSyncErrorKind;
12
+ constructor(kind: PrSyncErrorKind, message: string);
13
+ }
14
+ export interface PrPageRequest {
15
+ readonly repository: GithubRepositoryDto;
16
+ readonly cursor: string | null;
17
+ readonly updatedAtSince: number | null;
18
+ /**
19
+ * Conditional validator bound to this exact (repository, filter, cursor)
20
+ * position: the engine replays only the ETag stored for the requested
21
+ * position, never another page's validator. Null means no validator yet.
22
+ */
23
+ readonly etag: string | null;
24
+ }
25
+ export type PrTransportResult = {
26
+ readonly ok: true;
27
+ readonly page: PrPageDto;
28
+ } | {
29
+ readonly ok: false;
30
+ readonly kind: PrSyncErrorKind;
31
+ readonly message: string;
32
+ readonly retryAfterMs?: number;
33
+ };
34
+ /**
35
+ * INJECTED GitHub listing transport (neutral port). Production H: serves it
36
+ * with the approved installed `gh` binary, host-controlled credentials and
37
+ * ETag/rate-limit handling; tests serve fixture pages. No network in engram.
38
+ * The request carries no count limit: the engine never sends a ceiling.
39
+ */
40
+ export interface GithubPrTransportPort {
41
+ fetchPage(request: PrPageRequest): Promise<PrTransportResult>;
42
+ }
43
+ /**
44
+ * INJECTED durable PR persistence (neutral port, never a base). Engram owns
45
+ * no database; cluster-mesh/app implement it behind this shape (S mapping).
46
+ * Retention contract: saveObservation keeps every distinct observation —
47
+ * a moved head, a state change, a base change or new merge evidence appends
48
+ * a row, never erases the previous one; only byte-identical repeats
49
+ * collapse. Object jobs are keyed by (repository, PR, head OID): recording
50
+ * head B never replaces head A's job, its failures or its receipts.
51
+ */
52
+ export interface PrSyncPersistencePort {
53
+ loadCursor(repository: GithubRepositoryDto): Promise<PrSyncCursorDto | null>;
54
+ saveCursor(cursor: PrSyncCursorDto): Promise<void>;
55
+ saveObservation(fact: PullRequestFactDto): Promise<void>;
56
+ listObservations(repository: GithubRepositoryDto): Promise<readonly PullRequestFactDto[]>;
57
+ recordObjectJob(job: PrObjectJobDto): Promise<void>;
58
+ updateObjectJob(job: PrObjectJobDto): Promise<void>;
59
+ listObjectJobs(repository: GithubRepositoryDto): Promise<readonly PrObjectJobDto[]>;
60
+ }
61
+ export interface PrSyncInput {
62
+ readonly repository: GithubRepositoryDto;
63
+ readonly sweepKind: "incremental" | "full";
64
+ readonly now: number;
65
+ }
66
+ export interface PrSyncStats {
67
+ readonly pages: number;
68
+ readonly itemsSeen: number;
69
+ readonly unique: number;
70
+ readonly duplicates: number;
71
+ readonly observations: number;
72
+ readonly objectJobsPending: number;
73
+ }
74
+ export interface PrSyncOutcome {
75
+ readonly state: "complete" | "stale";
76
+ readonly observations: readonly PullRequestFactDto[];
77
+ readonly cursor: PrSyncCursorDto;
78
+ readonly coverage: readonly PrCoverageDto[];
79
+ readonly stats: PrSyncStats;
80
+ }
81
+ /**
82
+ * Identity of one persisted observation: the complete observed fact. Two
83
+ * rows sharing one head OID but differing by state, draft flag, refs, base,
84
+ * merge evidence or timestamp are different observations and all persist;
85
+ * only a byte-identical repeat collapses. The (PR, head OID) key is reserved
86
+ * for object-job deduplication (objectJobIdentityKey), never for dropping
87
+ * observations.
88
+ */
89
+ export declare function observationIdentityKey(fact: PullRequestFactDto): string;
90
+ /**
91
+ * Identity of one object-acquisition job: the PR plus the observed head OID.
92
+ * Two jobs for one PR with different heads are different rows; recording
93
+ * head B never replaces head A's job, failures or receipts.
94
+ */
95
+ export declare function objectJobIdentityKey(job: Pick<PrObjectJobDto, "repositoryOwner" | "repositoryRepo" | "prNumber" | "headOid">): string;
96
+ /**
97
+ * Deduplicate exact observation repeats by complete observation identity,
98
+ * keeping one row per distinct fact. Observations whose metadata differs
99
+ * (state, base, merge evidence, timestamp, …) are all kept: this is the
100
+ * persistence rule (nothing erased), not the current view.
101
+ */
102
+ export declare function deduplicatePrObservations(items: readonly PullRequestFactDto[]): readonly PullRequestFactDto[];
103
+ /**
104
+ * Current view over observations: one row per PR identity
105
+ * (owner/repo/number), keeping the newest updatedAt record. Computed
106
+ * separately AFTER every distinct observation is retained, so the live head
107
+ * never erases the observed history.
108
+ */
109
+ export declare function deduplicatePrPageItems(items: readonly PullRequestFactDto[]): readonly PullRequestFactDto[];
110
+ /**
111
+ * Refuse any row that does not belong to the requested repository: the
112
+ * stored cursor and every received observation must carry the canonical
113
+ * requested identity before any persistence or completion. A foreign row is
114
+ * a protocol failure, never a silent adoption.
115
+ */
116
+ export declare function assertSameRepository(expected: GithubRepositoryDto, owner: string, repo: string, what: string): void;
117
+ /**
118
+ * ETag position key: one validator per (filter, cursor) position inside the
119
+ * repository pass, so page N's ETag is never replayed for page M.
120
+ */
121
+ export declare function etagPositionKey(cursor: string | null, updatedAtSince: number | null): string;
122
+ /**
123
+ * Require the explicit end-of-list proof: hasMore false without endProof is
124
+ * a protocol failure, never a silent completion. hasMore true without a
125
+ * continuation cursor is the same failure class.
126
+ */
127
+ export declare function requireEndOfListProof(page: PrPageDto): void;
128
+ /**
129
+ * S mapping rule: metadata receipts never acknowledge a failed private
130
+ * object acquisition. True only when every job is acquired AND verified:
131
+ * the acquired OID equals the observed head OID, no residual error stands,
132
+ * and known counters agree exactly (a partial count never acknowledges).
133
+ */
134
+ export declare function canAcknowledgePrObjects(jobs: readonly PrObjectJobDto[]): boolean;
135
+ /**
136
+ * Run one neutral PR sync pass: full pagination with overlap/dedup, durable
137
+ * cursor advance only after proven completion, object jobs recorded as
138
+ * pending independently of metadata, failures preserving last success with
139
+ * stale coverage and durable retry state for automatic resume.
140
+ */
141
+ export declare function runPrSyncPass(input: PrSyncInput, ports: {
142
+ readonly transport: GithubPrTransportPort;
143
+ readonly persistence: PrSyncPersistencePort;
144
+ }): Promise<PrSyncOutcome>;