@corca-org/ceal-host-linux-arm64 1.0.10 → 1.0.12

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.
@@ -2,6 +2,46 @@
2
2
  import { createRequire as __cealCreateRequire } from "node:module";
3
3
  const require = __cealCreateRequire(import.meta.url);
4
4
 
5
+ // host/producer-service.ts
6
+ import { posix as posix3, win32 as win323 } from "node:path";
7
+
8
+ // host/runtime-source-paths.ts
9
+ import { createHash } from "node:crypto";
10
+ import { posix as posix2, win32 as win322 } from "node:path";
11
+
12
+ // host/absolute-path.ts
13
+ import { posix, win32 } from "node:path";
14
+ function isAbsoluteNormalizedNonRootPath(value, flavor = process.platform, allowRoot = false) {
15
+ const pathApi = flavor === "win32" || flavor === "windows" ? win32 : posix;
16
+ return typeof value === "string" && value.length <= 4096 && !value.includes("\0") && pathApi.isAbsolute(value) && pathApi.normalize(value) === value && (allowRoot || pathApi.parse(value).root !== value);
17
+ }
18
+
19
+ // host/runtime-source-paths.ts
20
+ var HOST_SOURCE_ID = /^host-source:([0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})$/u;
21
+ function hostSourceUuid(sourceRef) {
22
+ return HOST_SOURCE_ID.exec(sourceRef)?.[1] ?? null;
23
+ }
24
+ function hostRuntimeSourcePaths(stateRoot, sourceRef, platform = process.platform) {
25
+ const sourceId = hostSourceUuid(sourceRef);
26
+ if (!isAbsoluteNormalizedNonRootPath(stateRoot, platform) || sourceId === null) throw new TypeError("Host runtime source identity is invalid.");
27
+ const path = platform === "win32" ? win322 : posix2;
28
+ const sourcesRoot = path.join(stateRoot, "sources");
29
+ const sourceRoot = path.join(sourcesRoot, sourceId);
30
+ const runtimeRoot = path.join(stateRoot, "run");
31
+ const endpoint = platform === "win32" ? `\\\\.\\pipe\\ceal-host-${createHash("sha256").update(`${stateRoot}\0${sourceRef}`).digest("hex").slice(0, 24)}` : path.join(runtimeRoot, `${sourceId}.sock`);
32
+ assertHostRuntimeIpcLength(endpoint, platform);
33
+ return { sourceId, sourcesRoot, sourceRoot, relayRoot: path.join(sourceRoot, "relay"), codexOutbox: path.join(sourceRoot, "producers", "codex", "outbox"), claudeOutbox: path.join(sourceRoot, "producers", "claude", "outbox"), endpoint, runtimeRoot };
34
+ }
35
+ function assertHostRuntimeIpcLength(endpoint, platform) {
36
+ if (platform === "win32") return;
37
+ const maximum = platform === "linux" ? 107 : 103;
38
+ if (Buffer.byteLength(endpoint, "utf8") > maximum) throw Object.assign(new TypeError(`ipc_endpoint_too_long: Host IPC path exceeds ${maximum} bytes; use a shorter Host state root.`), { code: "ipc_endpoint_too_long" });
39
+ }
40
+ function assertHostProducerSourcePaths(stateRoot, config, producer, platform = process.platform) {
41
+ const paths = hostRuntimeSourcePaths(stateRoot, config.host_source_ref, platform);
42
+ if (config.outbox_dir !== (producer === "codex" ? paths.codexOutbox : paths.claudeOutbox) || config.relay_endpoint !== paths.endpoint) throw new TypeError("Host producer outbox and IPC must belong to its configured source.");
43
+ }
44
+
5
45
  // host/producer-service.ts
6
46
  import { constants } from "node:fs";
7
47
  import { lstat, open } from "node:fs/promises";
@@ -65,6 +105,46 @@ var client_wire_contract_default = {
65
105
  schema_version: "ceal.command_request.v1",
66
106
  absolute_transport_max_bytes: 65536
67
107
  },
108
+ command_resolution: {
109
+ schema_version: "ceal.gateway_command_resolution.v1",
110
+ authority: {
111
+ anonymous: {
112
+ state: "anonymous",
113
+ fields: [
114
+ "state"
115
+ ]
116
+ },
117
+ authenticated: {
118
+ state: "authenticated",
119
+ fields: [
120
+ "state",
121
+ "principal_kind",
122
+ "organization_ref",
123
+ "instance_ref",
124
+ "access_group_ref",
125
+ "principal_ref",
126
+ "authority_revision_ref"
127
+ ]
128
+ }
129
+ },
130
+ semantic_options: {
131
+ inspection: {
132
+ values: [
133
+ "default",
134
+ "full"
135
+ ]
136
+ },
137
+ cache_mode: {
138
+ values: [
139
+ "default",
140
+ "bypass"
141
+ ]
142
+ },
143
+ compact: {
144
+ type: "boolean"
145
+ }
146
+ }
147
+ },
68
148
  command_response: {
69
149
  schema_version: "ceal.command_response.v1",
70
150
  descriptor_field: "verified_artifact",
@@ -78,12 +158,15 @@ var client_wire_contract_default = {
78
158
  ],
79
159
  bare_document_fields: [
80
160
  "invocation",
81
- "required_action_sequence",
82
161
  "entrypoints",
83
162
  "common_concepts",
84
163
  "operations",
85
164
  "catalog_revision"
86
165
  ],
166
+ bare_document_optional_fields: [
167
+ "required_action_sequence",
168
+ "withheld"
169
+ ],
87
170
  prompt_field: "prompt",
88
171
  prompt_schema_version: "ceal.prompt.v1",
89
172
  focused_prompt_document_fields: [
@@ -96,7 +179,7 @@ var client_wire_contract_default = {
96
179
  "prompt"
97
180
  ],
98
181
  discovery_command: "discovery",
99
- discovery_manifest_schema_version: "ceal.discovery_manifest.v1",
182
+ discovery_manifest_schema_version: "ceal.discovery_manifest.v2",
100
183
  discovery_manifest_document_fields: [
101
184
  "discovery_manifest"
102
185
  ],
@@ -104,11 +187,29 @@ var client_wire_contract_default = {
104
187
  bare_document_max_bytes: 65536,
105
188
  complete_max_bytes: 66019,
106
189
  absolute_transport_max_bytes: 4194304
190
+ },
191
+ resource_stream: {
192
+ path: "/api/ceal/v2/resources",
193
+ request_schema_version: "ceal.resource_stream_request.v1",
194
+ ref_pattern: "^resource:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
195
+ media_type_pattern: "^[a-z0-9][a-z0-9!#$&^_.+-]{0,63}/[a-z0-9][a-z0-9!#$&^_.+-]{0,63}$",
196
+ filename_max_bytes: 512,
197
+ max_bytes: 9007199254740991,
198
+ deadline_ms: 6e5,
199
+ fetch_argv: [
200
+ "resource",
201
+ "fetch"
202
+ ],
203
+ ref_flag: "--ref"
107
204
  }
108
205
  };
109
206
 
110
207
  // packages/ceal-client-protocol/src/client-wire-contract.ts
111
208
  var CEAL_CLIENT_WIRE_CONTRACT = Object.freeze(client_wire_contract_default);
209
+ var commandResolution = CEAL_CLIENT_WIRE_CONTRACT.command_resolution;
210
+ var commandResolutionAuthority = commandResolution.authority;
211
+ var commandResolutionSemanticOptions = commandResolution.semantic_options;
212
+ var CEAL_GATEWAY_COMMAND_RESOLUTION_SCHEMA_VERSION = commandResolution.schema_version;
112
213
  var artifact = CEAL_CLIENT_WIRE_CONTRACT.artifact_descriptor;
113
214
  var request = CEAL_CLIENT_WIRE_CONTRACT.command_request;
114
215
  var response = CEAL_CLIENT_WIRE_CONTRACT.command_response;
@@ -129,6 +230,7 @@ var CEAL_COMMAND_REQUEST_MAX_BYTES = request.absolute_transport_max_bytes;
129
230
  var CEAL_COMMAND_RESPONSE_BARE_DOCUMENT_MAX_BYTES = response.bare_document_max_bytes;
130
231
  var CEAL_COMMAND_RESPONSE_PROMPT_FIELD = response.prompt_field;
131
232
  var CEAL_COMMAND_RESPONSE_PROMPT_SCHEMA_VERSION = response.prompt_schema_version;
233
+ var CEAL_COMMAND_RESPONSE_BARE_DOCUMENT_OPTIONAL_FIELDS = Object.freeze([...response.bare_document_optional_fields]);
132
234
  var CEAL_COMMAND_RESPONSE_PROMPT_DOCUMENT_FIELDS = Object.freeze([...response.bare_document_fields, response.prompt_field]);
133
235
  var CEAL_COMMAND_RESPONSE_FOCUSED_PROMPT_DOCUMENT_FIELDS = Object.freeze([...response.focused_prompt_document_fields]);
134
236
  var CEAL_COMMAND_RESPONSE_FOCUSED_PROMPT_CONTINUATION_DOCUMENT_FIELDS = Object.freeze([...response.focused_prompt_continuation_document_fields]);
@@ -142,9 +244,50 @@ function vocabulary(words) {
142
244
  return Object.freeze(words);
143
245
  }
144
246
 
247
+ // packages/ceal-client-protocol/src/gateway-response-types.ts
248
+ var CEAL_OPERATION_READINESS_VALUES = vocabulary(["ready", "degraded", "unavailable", "unknown"]);
249
+ var CEAL_TARGET_REQUIREMENTS = vocabulary(["required", "optional", "none"]);
250
+ var CEAL_AUDIT_OUTCOMES = vocabulary(["succeeded", "denied", "failed"]);
251
+ var CEAL_GATEWAY_PROVIDER_STEP_OUTCOMES = vocabulary(["completed", "rejected", "throttled", "failed"]);
252
+ var CEAL_GATEWAY_READ_REUSE_DISPOSITIONS = vocabulary(["response_cache_hit", "corpus_hit", "corpus_hit_after_revalidation", "corpus_partial_provider_supplement", "provider_direct", "provider_continuation", "reuse_unavailable"]);
253
+ var CEAL_GATEWAY_READ_REUSE_UNAVAILABLE_REASONS = vocabulary(["not_reported", "storage_unavailable", "coverage_incomplete", "freshness_refresh_required", "not_reusable", "bypassed"]);
254
+ var CEAL_POLICY_DECISIONS = vocabulary(["allowed", "denied", "not_evaluated"]);
255
+ var CEAL_CONNECTOR_ROUTE_PHASES = vocabulary(["scope_observation", "target_selection", "route_resolution"]);
256
+ var CEAL_CONNECTOR_ROUTE_CAUSES = vocabulary(["provider_throttled", "provider_unavailable", "binding_invalid", "scope_limit_exceeded"]);
257
+ var CEAL_WRITE_SOURCE_KINDS = vocabulary(["authenticated_registered_client", "agent_lease_admission", "provider_authenticated_event"]);
258
+ var CEAL_REFRESH_DELIVERIES = vocabulary(["initial", "recovery", "replay", "terminal_failure", "recovery_unavailable"]);
259
+ var CEAL_CLIENT_OPERATIONS = vocabulary(["handshake", "discover", "call", "readback"]);
260
+ var CEAL_WRITE_IDEMPOTENCY_POSTURES = vocabulary(["required", "optional", "not_required"]);
261
+ var CEAL_WRITE_PROVIDER_READBACK_POSTURES = vocabulary(["required", "best_effort", "not_available"]);
262
+ var CEAL_WRITE_ATTRIBUTIONS = vocabulary(["subject", "requester_event", "connector_integration"]);
263
+ var CEAL_WRITE_RECEIPT_PROVIDER_STATES = vocabulary(["outcome_unknown", "verified", "not_dispatched"]);
264
+ var CEAL_WRITE_RECEIPT_PROVIDER_READBACKS = vocabulary(["outcome_unknown", "verified", "not_applied"]);
265
+ var CEAL_PROTOCOL_VERSION = "1.4.0";
266
+ var CEAL_GATEWAY_ANNOUNCEMENT_SCOPE_STATEMENTS = Object.freeze({
267
+ github_app_installation_repositories: "Repositories in the installed GitHub App installation.",
268
+ slack_public_app_member_channels_only: "Public channels where the installed Slack app is a member, plus direct and multi-person direct messages the requester is a member of, as Slack reports that membership; private channels the administrator has not approved are not declared by this connector.",
269
+ notion_connected_logical_area: "Connected Notion logical area under provider-enforced sharing; descendant inventory is not declared.",
270
+ google_workspace_calendar_read_only: "Approved Calendar availability and event reads only; Calendar mutation is not declared.",
271
+ google_workspace_admitted_drive_target_metadata: "Metadata search for files in the shared drives and directly shared files the Connector reaches and the Organization admits as Targets; file-content read and mutation are not declared.",
272
+ google_workspace_admitted_drive_target_sheet_ranges: "Bounded values reads from Google Sheets in the shared drives and directly shared files the Connector reaches and the Organization admits as Targets; file mutation is not declared.",
273
+ google_workspace_admitted_drive_target_sheet_tabs: "Bounded tab metadata and grid extents from Google Sheets in the shared drives and directly shared files the Connector reaches and the Organization admits as Targets; cell contents and file mutation are not declared.",
274
+ google_workspace_admitted_drive_target_editable_sheet_ranges: "Bounded values updates and clears in editable Google Sheets in the shared drives and directly shared files the Connector reaches and the Organization admits as Targets; Docs, Slides, and other Drive file mutation are not declared."
275
+ });
276
+ var CEAL_OPERATION_ACCESS_SCHEMA_VERSION = "ceal.operation_access.v1";
277
+ var CEAL_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["connector_kind", "phase", "schema_version"]);
278
+ var CEAL_CLASSIFIED_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["cause", ...CEAL_CONNECTOR_ROUTE_FAILURE_KEYS]);
279
+ var CEAL_UNCLASSIFIED_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["connector_kind", "error_class", "phase", "schema_version"]);
280
+ var CEAL_GATEWAY_ORGANIZATION_ROUTE_FACT_CALL_KEYS = Object.freeze([
281
+ "connector_ref",
282
+ "connector_revision",
283
+ "policy_decision_revision"
284
+ ]);
285
+
145
286
  // packages/ceal-client-protocol/src/operation-contract-types.ts
146
287
  var CEAL_JSON_SCHEMA_2020_12 = "https://json-schema.org/draft/2020-12/schema";
147
288
  var CEAL_OPERATION_ERROR_SCHEMA_VERSION = "ceal.operation_error.v1";
289
+ var CEAL_OPERATION_WITHHELD_CAUSES = vocabulary(["provider_permission", "access_level", "personal_authorization_required"]);
290
+ var CEAL_RETRY_AFTER_MAX_MS = 60 * 60 * 1e3;
148
291
  var CEAL_JSON_SCHEMA_TYPES = vocabulary(["object", "array", "string", "integer", "number", "boolean", "null"]);
149
292
  var OBSERVATION_POSTURES = vocabulary(["direct_readback", "approved_no_readback", "operator_mediated", "excluded"]);
150
293
  var EFFECT_DOMAINS = vocabulary(["none", "gateway_state", "provider", "external_world"]);
@@ -180,27 +323,6 @@ var CEAL_OPERATION_APPROVAL_DISPOSITIONS = vocabulary([
180
323
  "interactive_unavailable"
181
324
  ]);
182
325
 
183
- // packages/ceal-client-protocol/src/gateway-response-types.ts
184
- var CEAL_CAPABILITY_READINESS_VALUES = vocabulary(["ready", "degraded", "unavailable", "unknown"]);
185
- var CEAL_TARGET_REQUIREMENTS = vocabulary(["required", "optional", "none"]);
186
- var CEAL_AUDIT_OUTCOMES = vocabulary(["succeeded", "denied", "failed"]);
187
- var CEAL_GATEWAY_PROVIDER_STEP_OUTCOMES = vocabulary(["completed", "rejected", "throttled", "failed"]);
188
- var CEAL_GATEWAY_READ_REUSE_DISPOSITIONS = vocabulary(["response_cache_hit", "corpus_hit", "corpus_hit_after_revalidation", "corpus_partial_provider_supplement", "provider_direct", "provider_continuation", "reuse_unavailable"]);
189
- var CEAL_GATEWAY_READ_REUSE_UNAVAILABLE_REASONS = vocabulary(["not_reported", "storage_unavailable", "coverage_incomplete", "freshness_refresh_required", "not_reusable", "bypassed"]);
190
- var CEAL_POLICY_DECISIONS = vocabulary(["allowed", "denied", "not_evaluated"]);
191
- var CEAL_CONNECTOR_ROUTE_PHASES = vocabulary(["scope_observation", "target_selection", "route_resolution"]);
192
- var CEAL_CONNECTOR_ROUTE_CAUSES = vocabulary(["provider_throttled", "provider_unavailable", "binding_invalid", "scope_limit_exceeded"]);
193
- var CEAL_WRITE_SOURCE_KINDS = vocabulary(["authenticated_registered_client", "agent_lease_admission", "provider_authenticated_event"]);
194
- var CEAL_REFRESH_DELIVERIES = vocabulary(["initial", "recovery", "replay", "terminal_failure", "recovery_unavailable"]);
195
- var CEAL_CLIENT_OPERATIONS = vocabulary(["handshake", "discover", "call", "readback"]);
196
- var CEAL_WRITE_IDEMPOTENCY_POSTURES = vocabulary(["required", "optional", "not_required"]);
197
- var CEAL_WRITE_PROVIDER_READBACK_POSTURES = vocabulary(["required", "best_effort", "not_available"]);
198
- var CEAL_WRITE_ATTRIBUTIONS = vocabulary(["subject", "requester_event", "connector_integration"]);
199
- var CEAL_PROTOCOL_VERSION = "1.4.0";
200
- var CEAL_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["connector_kind", "phase", "schema_version"]);
201
- var CEAL_CLASSIFIED_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["cause", ...CEAL_CONNECTOR_ROUTE_FAILURE_KEYS]);
202
- var CEAL_UNCLASSIFIED_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["connector_kind", "error_class", "phase", "schema_version"]);
203
-
204
326
  // packages/ceal-client-protocol/src/gateway-validation-primitives.ts
205
327
  var CealProtocolValidationError = class extends Error {
206
328
  name = "CealProtocolValidationError";
@@ -217,6 +339,7 @@ var SAFE_CONNECTOR_KIND = new RegExp(`^[a-z][a-z0-9-]{0,${MAX_SAFE_TOKEN_LENGTH
217
339
  var FORBIDDEN_SECRET_KEY = /^(?:[a-z0-9_]*(?:token|secret|password|credential(?:s)?|private_?key)|api_?key|authorization|bearer|raw_?provider_?payload|provider_?payload)$/iu;
218
340
  var FORBIDDEN_AUTHORITY_KEY = /^(?:actor_?ref|owner_?ref|registration_?ref|runner_?ref|auth_?decision|policy_?decision|host_?decision)$/iu;
219
341
  var TEXT_ENCODER = new TextEncoder();
342
+ var CEAL_WIRE_SAFE_ARRAY_MAX_ITEMS = 128;
220
343
  var CEAL_WIRE_SAFE_TEXT_MAX_BYTES = 8 * 1024;
221
344
  function assertSafeJsonValue(value, options, depth = 0, count = { value: 0 }) {
222
345
  count.value += 1;
@@ -236,12 +359,12 @@ function assertSafeJsonString(value, options) {
236
359
  if (byteLength(value) > CEAL_WIRE_SAFE_TEXT_MAX_BYTES || firstDisallowedControl(value, "multi_line") !== null) invalidByContext(options);
237
360
  }
238
361
  function assertSafeJsonArray(value, options, depth, count) {
239
- if (value.length > 128) invalidByContext(options);
362
+ if (value.length > CEAL_WIRE_SAFE_ARRAY_MAX_ITEMS) invalidByContext(options);
240
363
  for (const item of value) assertSafeJsonValue(item, options, depth + 1, count);
241
364
  }
242
365
  function assertSafeJsonRecord(record6, options, depth, count) {
243
366
  const entries = Object.entries(record6);
244
- if (entries.length > 128) invalidByContext(options);
367
+ if (entries.length > CEAL_WIRE_SAFE_ARRAY_MAX_ITEMS) invalidByContext(options);
245
368
  const sourceUrlColumn = options.allowHttpsUrl ? compactSourceUrlColumn(record6.fields) : null;
246
369
  for (const [key, child] of entries) {
247
370
  if (key === "credential_material_included" && child !== false) invalidByContext(options);
@@ -267,9 +390,9 @@ function compactSourceUrlColumn(fields) {
267
390
  return index < 0 ? null : index;
268
391
  }
269
392
  function assertSafeJsonCompactRows(value, sourceUrlColumn, options, depth, count) {
270
- if (!Array.isArray(value) || value.length > 128) invalidByContext(options);
393
+ if (!Array.isArray(value) || value.length > CEAL_WIRE_SAFE_ARRAY_MAX_ITEMS) invalidByContext(options);
271
394
  for (const row of value) {
272
- if (!Array.isArray(row) || row.length > 128) invalidByContext(options);
395
+ if (!Array.isArray(row) || row.length > CEAL_WIRE_SAFE_ARRAY_MAX_ITEMS) invalidByContext(options);
273
396
  for (const [index, cell] of row.entries()) {
274
397
  if (index === sourceUrlColumn && (cell === null || isSafeExternalHttpsUrl(cell))) continue;
275
398
  assertSafeJsonValue(cell, options, depth + 2, count);
@@ -302,6 +425,7 @@ function isSafeResultContent(value, key) {
302
425
  const maximum = key === "text" ? 8192 : 1024;
303
426
  return typeof value === "string" && byteLength(value) <= maximum && firstDisallowedControl(value, "multi_line") === null;
304
427
  }
428
+ var CEAL_PUBLIC_DISPLAY_NAME_MAX_BYTES = 512;
305
429
  function normalizeCealSingleLineText(value) {
306
430
  return value.split("").map((character) => hasControlCharacter(character) ? " " : character).join("").trim();
307
431
  }
@@ -410,6 +534,28 @@ function cut(text) {
410
534
  return text.length <= REFUSAL_VALUE_MAX_CHARS ? text : `${text.slice(0, REFUSAL_VALUE_MAX_CHARS)}...(+${text.length - REFUSAL_VALUE_MAX_CHARS} chars)`;
411
535
  }
412
536
 
537
+ // packages/ceal-client-protocol/src/operation-access-class.ts
538
+ var CEAL_OPERATION_ACCESS_CLASSES = vocabulary(["read", "write"]);
539
+
540
+ // packages/ceal-client-protocol/src/domain-vocabulary.ts
541
+ var CEAL_INTEGRATION_KINDS = vocabulary(["github", "google-workspace", "notion", "slack"]);
542
+ var CEAL_CONNECTOR_STATUSES = vocabulary(["active", "disabled", "disconnected"]);
543
+ var CEAL_CONNECTOR_CUSTODIES = vocabulary(["organization", "personal"]);
544
+ var CEAL_PROVIDER_BOUNDARY_KINDS = vocabulary([
545
+ "github_account",
546
+ "github_organization",
547
+ "google_workspace_domain",
548
+ "notion_workspace",
549
+ "slack_workspace"
550
+ ]);
551
+ var CEAL_PROVIDER_BOUNDARY_EVIDENCE = vocabulary(["provider_readback", "operator_stated"]);
552
+ var CEAL_ACCESS_LEVELS = vocabulary(["none", "read", "read_write"]);
553
+ var CEAL_PERSONAL_ACCESS_CEILINGS = vocabulary(["disabled", "read", "read_write"]);
554
+ var CEAL_TARGET_VISIBILITIES = vocabulary(["public", "private"]);
555
+ var CEAL_PRINCIPAL_KINDS = vocabulary(["human", "service", "runtime"]);
556
+ var CEAL_ORGANIZATION_ROLES = vocabulary(["member", "admin"]);
557
+ var LABEL_EXPECTATION = `public-safe display text of at most ${CEAL_PUBLIC_DISPLAY_NAME_MAX_BYTES} bytes`;
558
+
413
559
  // packages/ceal-client-protocol/src/safe-json-budget.ts
414
560
  var SAFE_JSON_MIN_BYTES_PER_NODE = 4;
415
561
  function safeJsonNodeBudgetForBytes(maxBytes) {
@@ -439,7 +585,9 @@ var CEAL_OPERATION_JSON_SCHEMA_BUDGET = Object.freeze({
439
585
  });
440
586
 
441
587
  // packages/ceal-client-protocol/src/operation-validation-primitives.ts
442
- var ISO_TIMESTAMP = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/u;
588
+ var ISO_TIMESTAMP = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?([Zz]|([+-])(\d{2}):(\d{2}))$/u;
589
+ var CEAL_CALENDAR_DATE_PATTERN_SOURCE = "^\\d{4}-\\d{2}-\\d{2}$";
590
+ var CEAL_CALENDAR_DATE = new RegExp(CEAL_CALENDAR_DATE_PATTERN_SOURCE, "u");
443
591
  function isOperationRecord(value) {
444
592
  if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
445
593
  const prototype = Object.getPrototypeOf(value);
@@ -451,8 +599,56 @@ function requireOperationRecord(value, message) {
451
599
  function requireClosedValue(value, members, message) {
452
600
  if (typeof value !== "string" || !members.includes(value)) throw new TypeError(message);
453
601
  }
602
+ function isCealIsoTimestamp(value) {
603
+ return typeof value === "string" && parseCealIsoTimestamp(value) !== null;
604
+ }
605
+ function parseCealIsoTimestamp(value) {
606
+ const fields = parseCealIsoTimestampFields(value);
607
+ if (fields === null || !validCalendarDate(fields) || !validClockTime(fields) || !validUtcOffset(fields)) return null;
608
+ const epochMilliseconds = cealFieldsEpochMilliseconds(fields);
609
+ if (!Number.isFinite(epochMilliseconds)) return null;
610
+ return {
611
+ epochNanoseconds: BigInt(epochMilliseconds) * 1000000n + BigInt(fields.fraction.padEnd(9, "0") || "0")
612
+ };
613
+ }
614
+ function parseCealIsoTimestampFields(value) {
615
+ const match = ISO_TIMESTAMP.exec(value);
616
+ if (match === null) return null;
617
+ return {
618
+ year: Number(match[1]),
619
+ month: Number(match[2]),
620
+ day: Number(match[3]),
621
+ hour: Number(match[4]),
622
+ minute: Number(match[5]),
623
+ second: Number(match[6]),
624
+ fraction: match[7] ?? "",
625
+ offsetSign: match[9] === void 0 ? 0 : match[9] === "+" ? 1 : -1,
626
+ offsetHour: Number(match[10] ?? 0),
627
+ offsetMinute: Number(match[11] ?? 0)
628
+ };
629
+ }
630
+ function validCalendarDate({ year, month, day }) {
631
+ return month >= 1 && month <= 12 && day >= 1 && day <= daysInMonth(year, month);
632
+ }
633
+ function validClockTime({ hour, minute, second }) {
634
+ return hour <= 23 && minute <= 59 && second <= 59;
635
+ }
636
+ function validUtcOffset({ offsetHour, offsetMinute }) {
637
+ return offsetHour <= 23 && offsetMinute <= 59;
638
+ }
639
+ function cealFieldsEpochMilliseconds(fields) {
640
+ const shiftedYear = fields.year < 100 ? fields.year + 400 : fields.year;
641
+ const cycleMilliseconds = fields.year < 100 ? (400 * 365 + 97) * 24 * 60 * 60 * 1e3 : 0;
642
+ const localMilliseconds = Date.UTC(shiftedYear, fields.month - 1, fields.day, fields.hour, fields.minute, fields.second, 0) - cycleMilliseconds;
643
+ const offsetMilliseconds = fields.offsetSign * (fields.offsetHour * 60 + fields.offsetMinute) * 6e4;
644
+ return localMilliseconds - offsetMilliseconds;
645
+ }
646
+ function daysInMonth(year, month) {
647
+ const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
648
+ return [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1] ?? 0;
649
+ }
454
650
  function requireIsoTimestamp(value, message) {
455
- if (typeof value !== "string" || !ISO_TIMESTAMP.test(value) || !Number.isFinite(Date.parse(value))) throw new TypeError(message);
651
+ if (!isCealIsoTimestamp(value)) throw new TypeError(message);
456
652
  }
457
653
 
458
654
  // packages/ceal-client-protocol/src/operation-json-schema.ts
@@ -474,7 +670,7 @@ var CLIENT_AUDIENCE_SET = new Set(CLIENT_AUDIENCES);
474
670
  // packages/ceal-client-protocol/src/schema-literals.ts
475
671
  var CEAL_SCHEMA_LITERALS = [
476
672
  "ceal.activation_transport.v1",
477
- "ceal.capability_access.v1",
673
+ CEAL_OPERATION_ACCESS_SCHEMA_VERSION,
478
674
  CEAL_OPERATION_CATALOG_SCHEMA_VERSION,
479
675
  "ceal.client_refresh_request.v2",
480
676
  "ceal.client_refresh_result.v2",
@@ -497,7 +693,6 @@ var CEAL_SCHEMA_LITERALS = [
497
693
  "ceal.enrollment_exchange.v1",
498
694
  "ceal.enrollment_result.v1",
499
695
  "ceal.first_activation_causal_join.v1",
500
- "ceal.gateway_aggregate_authorization_snapshot.v2",
501
696
  "ceal.gateway_announcement_policy.v1",
502
697
  "ceal.gateway_audit_call_detail.v1",
503
698
  "ceal.gateway_audit_event.v1",
@@ -505,7 +700,7 @@ var CEAL_SCHEMA_LITERALS = [
505
700
  "ceal.gateway_authorization_snapshot.v1",
506
701
  "ceal.gateway_cache_origin.v1",
507
702
  "ceal.gateway_call_result.v1",
508
- "ceal.gateway_command_resolution.v1",
703
+ CEAL_GATEWAY_COMMAND_RESOLUTION_SCHEMA_VERSION,
509
704
  "ceal.gateway_connector_route_failure.v1",
510
705
  "ceal.gateway_discovery.v3",
511
706
  "ceal.gateway_handshake.v1",
@@ -540,7 +735,7 @@ var CEAL_SCHEMA_LITERALS = [
540
735
  "ceal.operation_receipt.v1",
541
736
  "ceal.operation_result.v1",
542
737
  "ceal.operation_result.compact.v1",
543
- "ceal.local_result_materialization.v1",
738
+ "ceal.local_result_materialization.v2",
544
739
  "ceal.local_result_root.v1",
545
740
  "ceal.owner_bootstrap_exchange_request.v1",
546
741
  "ceal.owner_bootstrap_exchange_result.v1",
@@ -550,7 +745,8 @@ var CEAL_SCHEMA_LITERALS = [
550
745
  "ceal.request_cancellation.v1",
551
746
  "ceal.request_graph_revision.v1",
552
747
  "ceal.request_occurrence_correlation.v1",
553
- "ceal.request_projection.v1"
748
+ "ceal.request_projection.v1",
749
+ "ceal.write_safety_finding.v1"
554
750
  ];
555
751
  var CEAL_SCHEMA_LITERAL_SET = new Set(CEAL_SCHEMA_LITERALS);
556
752
 
@@ -565,21 +761,14 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
565
761
  thread_run_events: (root) => join(root, "run-events.jsonl"),
566
762
  bounded_store_sidecar: (root) => `${root}.jsonl`,
567
763
  gateway_audit_archive: (root) => `${root}.jsonl`,
568
- gateway_capability_audit: (root) => join(root, "capability-audit.jsonl"),
569
- gateway_retrieval_waste_partition: (root) => `${root}.jsonl`,
570
- gateway_access_policy_publication: (root) => join(root, "access-policy-publications.jsonl"),
571
764
  gateway_access_group_connector_control_audit: (root) => `${root}.audit.jsonl`,
572
765
  gateway_access_group_connector_scope_audit: (root) => join(root, "profile-connector-scope-audit.jsonl"),
573
766
  gateway_access_group_connector_activity_scope_audit: (root) => join(root, "profile-connector-activity-scope-audit.jsonl"),
767
+ gateway_access_group_connector_calendar_scope_audit: (root) => join(root, "profile-connector-calendar-scope-audit.jsonl"),
574
768
  gateway_access_group_connector_readiness_audit: (root) => join(root, "profile-connector-readiness.audit.jsonl"),
575
769
  gateway_organization_audit_ledger: (root) => join(root, "organization-ledger.jsonl"),
576
770
  gateway_personal_client_audit: (root) => join(root, "audit.jsonl"),
577
- gateway_personal_client_access_audit: (root) => join(root, "access-audit.jsonl"),
578
- gateway_admin_enrollment: (root) => join(root, "enrollments.jsonl"),
579
- gateway_admin_login: (root) => join(root, "logins.jsonl"),
580
- gateway_admin_family: (root) => join(root, "families.jsonl"),
581
- gateway_admin_refresh_token: (root) => join(root, "refresh-tokens.jsonl"),
582
- gateway_admin_access_token: (root) => join(root, "access-tokens.jsonl")
771
+ gateway_personal_client_access_audit: (root) => join(root, "access-audit.jsonl")
583
772
  });
584
773
 
585
774
  // packages/ceal-client-protocol/src/gateway-installation-activation.ts
@@ -587,8 +776,20 @@ var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS = 32;
587
776
  var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS = 8;
588
777
  var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_COMPACT_CHARACTERS = CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS + CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS;
589
778
 
779
+ // packages/ceal-client-protocol/src/gateway-entrypoint-commands.ts
780
+ var GATEWAY_ENTRYPOINT_COMMANDS = Object.freeze([
781
+ Object.freeze({ id: "controlPlane", path: Object.freeze(["control-plane"]) }),
782
+ Object.freeze({ id: "originShow", path: Object.freeze(["origin", "show"]) }),
783
+ Object.freeze({ id: "credentialsImport", path: Object.freeze(["credentials", "import"]) }),
784
+ Object.freeze({ id: "initialize", path: Object.freeze(["init"]) })
785
+ ]);
786
+
590
787
  // packages/ceal-client-protocol/src/host-registration.ts
591
788
  var CEAL_HOST_REGISTRATION_RESULT_KEYS = Object.freeze(["credential_generation", "host_access_token", "host_installation_ref", "host_source_ref", "ok", "registration_attempt_ref", "schema_version", "status"]);
789
+ var CEAL_LOWERCASE_UUID_PATTERN = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
790
+ var CEAL_HOST_REGISTRATION_ATTEMPT_REF_PATTERN = new RegExp(`^host-registration-attempt:${CEAL_LOWERCASE_UUID_PATTERN}$`, "u");
791
+ var CEAL_HOST_INSTALLATION_REF_PATTERN = new RegExp(`^host-installation:${CEAL_LOWERCASE_UUID_PATTERN}$`, "u");
792
+ var CEAL_HOST_SOURCE_REF_PATTERN = new RegExp(`^host-source:${CEAL_LOWERCASE_UUID_PATTERN}$`, "u");
592
793
 
593
794
  // packages/ceal-client-protocol/src/agent-session-handoff.ts
594
795
  var CEAL_AGENT_ADMISSION_PHASES = vocabulary([
@@ -620,12 +821,19 @@ var CEAL_AGENT_SERVICE_SESSION_RECORD_KEYS = vocabulary([
620
821
  var CEAL_AGENT_SESSION_COMMIT_KEYS = vocabulary(["attempt_ref", "expected_session_revision", "session_revision"]);
621
822
 
622
823
  // packages/ceal-client-protocol/src/operation-next-actions.ts
824
+ var CEAL_REPEAT_REQUEST_NEXT_ACTION = "repeat_request";
825
+ var CEAL_INSPECT_RECEIPT_NEXT_ACTION = "inspect_receipt";
623
826
  var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
624
827
  "select_did_you_mean",
625
828
  "choose_new_output_path",
626
829
  "choose_new_idempotency_key",
627
830
  "restart_search",
628
831
  "repeat_original_arguments",
832
+ // The occurrence this call addressed is settled and cannot move again -- a
833
+ // denied effect approval, an expired continuation -- so the caller runs the
834
+ // same call again as a new request. The refusal names the re-request; this
835
+ // word is the re-request.
836
+ CEAL_REPEAT_REQUEST_NEXT_ACTION,
629
837
  "choose_new_request_identity",
630
838
  // A refusal that names the argument (invalid_argument with `property`) tells the caller exactly what to change.
631
839
  "correct_argument",
@@ -644,10 +852,35 @@ var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
644
852
  "use_original_input",
645
853
  // The same mismatch on the Request binding rather than the input: the
646
854
  // occurrence was admitted under one binding and the replay presents another.
647
- "use_original_request_binding"
855
+ "use_original_request_binding",
856
+ // The client's own filesystem write was refused -- EACCES, EPERM, or a
857
+ // read-only mount -- which is how an agent sandbox fences writes outside its
858
+ // workspace. The caller reruns the same command with unsandboxed or escalated
859
+ // execution; re-adopting the session cannot help, because the sandbox refuses
860
+ // that write too.
861
+ "rerun_outside_agent_sandbox",
862
+ // The refusal names the one Operation to read next in `describe_command`:
863
+ // an absent Operation id with a sole catalog-ranked candidate, or a known
864
+ // Operation invoked without its input. Describing only reads the verified
865
+ // contract and dispatches nothing, and the caller then retries with the
866
+ // named Operation or input, so it is guidance the scorer counts.
867
+ "describe_operation",
868
+ // The refusal names the caller's own personal connect Operation in
869
+ // `required_action_sequence`: the Operation asked for, or the credential
870
+ // the call ran on, needs a personal connection the caller does not hold
871
+ // (never connected, revoked, or expired). The caller runs that exact
872
+ // Operation, completes the consent it hands back, and retries the same call.
873
+ "connect_personal_account",
874
+ // The provider or Gateway named a bounded wait; the caller waits that long
875
+ // and submits the same read again.
876
+ "retry_after"
648
877
  ];
649
878
  var CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS = Object.freeze(CALLER_RECOVERABLE_NEXT_ACTION_VALUES);
650
879
  var NON_REMEDY_NEXT_ACTION_VALUES = [
880
+ // Only an administrator can take the named step -- approving a place for an
881
+ // Operation, granting a withheld capability -- so a non-administrator asks
882
+ // one. The refusal names the administrator step; this word is the ask.
883
+ "ask_admin",
651
884
  "await_pending_approval",
652
885
  "check_gateway",
653
886
  "inspect_context_store",
@@ -662,9 +895,13 @@ var NON_REMEDY_NEXT_ACTION_VALUES = [
662
895
  "inspect_local_command",
663
896
  "inspect_local_output",
664
897
  "inspect_local_route",
665
- "inspect_receipt",
898
+ CEAL_INSPECT_RECEIPT_NEXT_ACTION,
666
899
  "inspect_request",
667
900
  "none",
901
+ // The provider refused because of its own configuration -- an API not
902
+ // enabled, an app scope missing -- which an operator changes in that
903
+ // provider's console. No caller edit and no retry fixes it.
904
+ "operator_action",
668
905
  "recover",
669
906
  "reconcile",
670
907
  // Reconciliation of one named occurrence, not of the deployment: a legacy
@@ -672,6 +909,10 @@ var NON_REMEDY_NEXT_ACTION_VALUES = [
672
909
  // no edit to the call changes that. `reconcile` is the deployment-wide word.
673
910
  "reconcile_occurrence",
674
911
  "reduce_request_size",
912
+ // The Host's invocation context for this turn is stale or expired at the
913
+ // Gateway. The Host's next turn rebinds it and the same call then succeeds;
914
+ // nothing in the call changes, so it is not a remedy the scorer may count.
915
+ "refresh_host_invocation_context",
675
916
  "repair_or_adopt_session",
676
917
  "retry",
677
918
  // The owner -- a correlation hook, an approval hook -- is not serving right
@@ -685,10 +926,23 @@ var NON_REMEDY_NEXT_ACTION_VALUES = [
685
926
  var CEAL_NON_REMEDY_NEXT_ACTIONS = Object.freeze(NON_REMEDY_NEXT_ACTION_VALUES);
686
927
  var DECLARED = /* @__PURE__ */ new Set([...CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS, ...CEAL_NON_REMEDY_NEXT_ACTIONS]);
687
928
  var RECOVERABLE = new Set(CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS);
929
+ var CEAL_OPERATION_WITHHELD_NEXT_ACTIONS = Object.freeze({
930
+ provider_permission: "ask_admin",
931
+ access_level: "ask_admin",
932
+ personal_authorization_required: "connect_personal_account"
933
+ });
688
934
 
689
935
  // packages/ceal-client-protocol/src/operation-contract-artifact.ts
690
936
  var CATALOG_REVISION = new RegExp(CEAL_VERIFIED_ARTIFACT_CATALOG_REVISION_PATTERN, "u");
691
937
  var SHA256 = new RegExp(CEAL_VERIFIED_ARTIFACT_DIGEST_PATTERN, "u");
938
+ var CEAL_OPERATION_INVOKE_COMMAND = "invoke";
939
+ var CEAL_OPERATION_INPUT_FLAG = "--input";
940
+ var CEAL_OPERATION_ID_PLACEHOLDER = "<operation-id>";
941
+ var CEAL_OPERATION_INPUT_PLACEHOLDER = "<json-object>";
942
+ var CEAL_MODEL_INVOCATION_ARGUMENTS = [CEAL_OPERATION_INVOKE_COMMAND, CEAL_OPERATION_ID_PLACEHOLDER, CEAL_OPERATION_INPUT_FLAG, shellSingleQuoted(CEAL_OPERATION_INPUT_PLACEHOLDER)].join(" ");
943
+ function shellSingleQuoted(value) {
944
+ return `'${value.replaceAll("'", "'\\''")}'`;
945
+ }
692
946
  var CEAL_OPERATION_CONTRACT_REQUIRED_FIELDS = Object.freeze(["input_schema", "result_schema"]);
693
947
  var CEAL_OPERATION_CONTRACT_OPTIONAL_FIELDS = Object.freeze(["summary", "input_resolution"]);
694
948
  var CEAL_VERIFIED_ARTIFACT_DESCRIPTOR_JSON_SCHEMA = Object.freeze({
@@ -717,9 +971,178 @@ var CEAL_VERIFIED_ARTIFACT_DESCRIPTOR_JSON_SCHEMA = Object.freeze({
717
971
  }
718
972
  });
719
973
 
974
+ // packages/ceal-client-protocol/src/bare-document.ts
975
+ var REQUIRED_FIELDS = CEAL_CLIENT_WIRE_CONTRACT.command_response.bare_document_fields;
976
+ var OPTIONAL_FIELDS = CEAL_CLIENT_WIRE_CONTRACT.command_response.bare_document_optional_fields;
977
+
978
+ // packages/ceal-client-protocol/src/leased-consumer-vocabulary.ts
979
+ var CEAL_TERMINAL_DISPOSITIONS = vocabulary(["completed", "failed", "cancelled"]);
980
+ var CEAL_LEASE_DISPOSITIONS = vocabulary([...CEAL_TERMINAL_DISPOSITIONS, "deferred"]);
981
+ var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["initial"]);
982
+ var CEAL_LEASED_MESSAGE_DELIVERY_OPERATION_IDS = vocabulary(["message.send", "message.update", "message.delete"]);
983
+ var CEAL_REPOSITORY_VISIBILITIES = vocabulary(["public", "private", "internal"]);
984
+ var CEAL_RESULT_DELIVERY_OFFERS = vocabulary(["pending", "offered", "transport_lost"]);
985
+ var CEAL_RESULT_DELIVERY_STATES = vocabulary(["unavailable", ...CEAL_RESULT_DELIVERY_OFFERS]);
986
+ var CEAL_PROVIDER_OUTCOMES = vocabulary(["not_attempted", "outcome_unknown", "verified"]);
987
+ var CEAL_ACTIVITY_GAP_CODES = vocabulary([
988
+ "provider_page_budget",
989
+ "call_deadline",
990
+ "related_item_budget",
991
+ "provider_cursor_unavailable",
992
+ "malformed_provider_page",
993
+ "visibility_incomplete",
994
+ "unsupported_event_kind"
995
+ ]);
996
+ var CEAL_ACTIVITY_CONNECTOR_KINDS = vocabulary(["slack", "github", "google-calendar", "google-drive", "notion"]);
997
+ var CEAL_ACTIVITY_COVERAGE_STATUSES = vocabulary(["complete_for_target", "continuation_required", "blocked"]);
998
+ var CEAL_ACTIVITY_EVENT_KINDS = vocabulary([
999
+ "slack.message",
1000
+ "slack.reply",
1001
+ "slack.direct_message",
1002
+ "github.commit.authored",
1003
+ "github.issue.opened",
1004
+ "github.pull_request.opened",
1005
+ "github.review.submitted",
1006
+ "github.issue_comment.created",
1007
+ "github.review_comment.created",
1008
+ "calendar.organized",
1009
+ "calendar.accepted_invite",
1010
+ "calendar.recorded",
1011
+ "drive.file.created",
1012
+ "drive.file.modified",
1013
+ "drive.file.viewed",
1014
+ "notion.page.created",
1015
+ "notion.page.edited"
1016
+ ]);
1017
+ var CEAL_ACTIVITY_TIMESTAMP_BASES = vocabulary([
1018
+ "message_created",
1019
+ "commit_authored",
1020
+ "resource_created",
1021
+ "review_submitted",
1022
+ "comment_created",
1023
+ "event_start",
1024
+ "all_day_start",
1025
+ "file_created",
1026
+ "file_modified",
1027
+ "file_modified_by_me",
1028
+ "file_viewed_by_me",
1029
+ "page_created",
1030
+ "page_last_edited",
1031
+ "resource_modified"
1032
+ ]);
1033
+ var CEAL_ACTIVITY_V3_KINDS = vocabulary(["authored", "edited", "messaged", "responded"]);
1034
+ var CEAL_RESOURCE_TIME_BASES = vocabulary(["created", "modified", "viewed"]);
1035
+ var CEAL_RESOURCE_SEARCH_ORDERS = vocabulary(["relevance", "modified", "viewed", "created"]);
1036
+ var CEAL_RESOURCE_SEARCH_DIRECTIONS = vocabulary(["ascending", "descending"]);
1037
+ var CEAL_RESOURCE_SEARCH_FILTERS = vocabulary(["query", "modified_since", "kinds", "container_ref", "addressed_to_me", "unread"]);
1038
+ var CEAL_ARTIFACT_STAGE_TERMINALS = vocabulary(["chunk_accepted", "artifact_ready", "idempotency_replayed"]);
1039
+ var CEAL_READ_ITEM_KINDS = vocabulary(["conversation", "identity", "usergroup", "message", "file", "document"]);
1040
+ var CEAL_LEASED_MESSAGE_SEARCH_COMPLETENESS = vocabulary(["complete", "continuation_available", "truncated"]);
1041
+ var CEAL_OPAQUE_HANDLE_KINDS = vocabulary(["target", "message", "thread", "artifact", "document", "object"]);
1042
+ var CEAL_WRITE_OBJECT_KINDS = vocabulary(["document", "comment", "cell_range"]);
1043
+ var CEAL_CONVERSATION_KINDS = vocabulary(["channel", "dm", "group"]);
1044
+ var CEAL_FILE_TYPE_FAMILIES = vocabulary(["all", "image", "pdf"]);
1045
+ var CEAL_GITHUB_ISSUE_STATES = vocabulary(["open", "closed", "all"]);
1046
+ var CEAL_NOTION_UPDATABLE_BLOCK_TYPES = vocabulary([
1047
+ "paragraph",
1048
+ "heading_1",
1049
+ "heading_2",
1050
+ "heading_3",
1051
+ "bulleted_list_item",
1052
+ "numbered_list_item",
1053
+ "to_do",
1054
+ "code"
1055
+ ]);
1056
+ var CEAL_NOTION_NEUTRAL_TYPES = vocabulary([
1057
+ "text",
1058
+ "number",
1059
+ "boolean",
1060
+ "date",
1061
+ "select",
1062
+ "multi_select",
1063
+ "people",
1064
+ "url",
1065
+ "email",
1066
+ "phone",
1067
+ "unsupported"
1068
+ ]);
1069
+ var CEAL_NOTION_IDENTITY_GAP_REASONS = vocabulary([
1070
+ "identity_unavailable",
1071
+ "identity_stale",
1072
+ "identity_ambiguous",
1073
+ "identity_revoked",
1074
+ "identity_unlinked"
1075
+ ]);
1076
+ var CEAL_NOTION_STRING_VALUE_TYPES = vocabulary(["text", "select", "url", "email", "phone"]);
1077
+ var CEAL_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "permission_denied"]);
1078
+ var CEAL_PLAN_ITEM_STATUSES = vocabulary(["pending", "active", "completed"]);
1079
+ var CEAL_FINAL_PRESENTATION_INTENTS = vocabulary(["final", "stop", "transient_notice"]);
1080
+ var CEAL_PRESENTATION_INTENTS = vocabulary(["progress", ...CEAL_FINAL_PRESENTATION_INTENTS]);
1081
+
1082
+ // packages/ceal-client-protocol/src/resource-row.ts
1083
+ var RESOURCE_ROW_KEY_RULES = Object.freeze({
1084
+ schema_version: { required: true, timestamp: false },
1085
+ ref: { required: true, timestamp: false },
1086
+ next: { required: true, timestamp: false },
1087
+ kind: { required: true, timestamp: false },
1088
+ title: { required: true, timestamp: false },
1089
+ container_label: { required: true, timestamp: false },
1090
+ container_ref: { required: false, timestamp: false },
1091
+ source: { required: true, timestamp: false },
1092
+ owner: { required: false, timestamp: false },
1093
+ counterparts: { required: false, timestamp: false },
1094
+ created_at: { required: false, timestamp: true },
1095
+ created_at_local: { required: false, timestamp: true },
1096
+ modified_at: { required: false, timestamp: true },
1097
+ modified_at_local: { required: false, timestamp: true },
1098
+ viewed_by_me_at: { required: false, timestamp: true },
1099
+ visibility: { required: false, timestamp: false },
1100
+ start: { required: false, timestamp: false },
1101
+ end: { required: false, timestamp: false },
1102
+ status: { required: false, timestamp: false },
1103
+ snippet: { required: false, timestamp: false },
1104
+ state: { required: true, timestamp: false },
1105
+ timestamp_basis: { required: true, timestamp: false }
1106
+ });
1107
+ var RESOURCE_ROW_REQUIRED_KEYS = Object.entries(RESOURCE_ROW_KEY_RULES).flatMap(([key, rule]) => rule.required ? [key] : []);
1108
+ var RESOURCE_ROW_KEYS = new Set(Object.keys(RESOURCE_ROW_KEY_RULES));
1109
+ var RESOURCE_ROW_TIMESTAMP_KEYS = Object.entries(RESOURCE_ROW_KEY_RULES).flatMap(([key, rule]) => rule.timestamp ? [key] : []);
1110
+
1111
+ // packages/ceal-client-protocol/src/resource-read-result.ts
1112
+ var CEAL_RESOURCE_GET_COVERAGE_NEXT_ACTIONS = vocabulary(["reduce_request_size", "read_resource_again"]);
1113
+
1114
+ // packages/ceal-client-protocol/src/excluded-target-coverage-contract.ts
1115
+ var CEAL_EXCLUDED_TARGET_REASONS = vocabulary(["audience_narrower_than_place", "visibility_unknown"]);
1116
+
1117
+ // packages/ceal-client-protocol/src/excluded-target-coverage.ts
1118
+ var CEAL_EXCLUDED_TARGET_COVERAGE_MAX_ENTRIES = 64;
1119
+ function cealExcludedTargetCoverageJsonSchema() {
1120
+ const target = {
1121
+ target_ref: { type: "string", minLength: 8, maxLength: 134, pattern: "^target:[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$" },
1122
+ connector_kind: { type: "string", minLength: 1, maxLength: 64, pattern: "^[a-z][a-z0-9-]{0,63}$" },
1123
+ label: { type: "string", minLength: 1, maxLength: CEAL_PUBLIC_DISPLAY_NAME_MAX_BYTES },
1124
+ reason: { type: "string", enum: [...CEAL_EXCLUDED_TARGET_REASONS] }
1125
+ };
1126
+ return {
1127
+ type: "array",
1128
+ minItems: 1,
1129
+ maxItems: CEAL_EXCLUDED_TARGET_COVERAGE_MAX_ENTRIES,
1130
+ items: { type: "object", additionalProperties: false, maxProperties: 4, properties: target, required: ["target_ref", "reason"] }
1131
+ };
1132
+ }
1133
+
1134
+ // packages/ceal-client-protocol/src/write-safety-finding.ts
1135
+ var CEAL_WRITE_SAFETY_FINDING_STATUSES = vocabulary(["warning", "unchecked"]);
1136
+ var CEAL_WRITE_SAFETY_AUDIENCES = vocabulary(["workspace", "person", "members", "unknown"]);
1137
+ var CEAL_WRITE_SAFETY_REFERENCE_REASONS = vocabulary(["not_published_to_audience", "audience_access_unknown"]);
1138
+ var CEAL_WRITE_SAFETY_UNCHECKED_REASONS = vocabulary(["authority_unavailable"]);
1139
+
720
1140
  // packages/ceal-client-protocol/src/operation-occurrence.ts
721
1141
  var MAX_RECEIPT_REVISION = Number.MAX_SAFE_INTEGER - 1;
722
1142
 
1143
+ // packages/ceal-client-protocol/src/leased-artifact-contract.ts
1144
+ var CEAL_LEASED_CONSUMER_ARTIFACT_CHUNK_MAX_BYTES = 12 * 1024;
1145
+
723
1146
  // packages/ceal-client-protocol/src/leased-resource-stream.ts
724
1147
  var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_MAGIC = new Uint8Array([67, 69, 65, 76, 82, 83, 50, 0]);
725
1148
  var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_RECORD_PREFIX_BYTES = 8;
@@ -729,13 +1152,14 @@ var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_MAX_RECORD_BYTES = CEAL_LEASED_CONSUM
729
1152
  var CEAL_ATTACHMENT_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "digest_mismatch"]);
730
1153
 
731
1154
  // packages/ceal-client-protocol/src/request-validation-primitives.ts
732
- import { createHash } from "node:crypto";
1155
+ import { createHash as createHash2 } from "node:crypto";
733
1156
  var DIGEST = /^[a-f0-9]{64}$/u;
1157
+ var CEAL_SHA256_DIGEST_PATTERN = DIGEST.source;
734
1158
  function isCealDigest(value) {
735
1159
  return typeof value === "string" && DIGEST.test(value);
736
1160
  }
737
1161
  function cealRequestSha256(value) {
738
- return createHash("sha256").update(cealCanonicalJson(value), "utf8").digest("hex");
1162
+ return createHash2("sha256").update(cealCanonicalJson(value), "utf8").digest("hex");
739
1163
  }
740
1164
  function operationRecord(value, message) {
741
1165
  requireOperationRecord(value, message);
@@ -757,7 +1181,7 @@ var CANCELLATION_STATES = vocabulary(["requested", "cancelled"]);
757
1181
  var CEAL_REQUEST_KEYS = Object.freeze(["schema_version", "ceal_request_ref", "created_at", "authority", "prompt_ref", "host_session_ref", "host_turn_ref", "host_source_ref"]);
758
1182
  var CEAL_REQUEST_JSON_SCHEMA = {
759
1183
  type: "object",
760
- maxProperties: 9,
1184
+ maxProperties: 10,
761
1185
  additionalProperties: false,
762
1186
  properties: {
763
1187
  schema_version: { type: "string", const: CEAL_REQUEST_SCHEMA_VERSION, maxLength: 32 },
@@ -780,7 +1204,8 @@ var CEAL_REQUEST_JSON_SCHEMA = {
780
1204
  host_session_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
781
1205
  host_turn_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
782
1206
  host_input_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
783
- host_source_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source }
1207
+ host_source_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
1208
+ requester_timezone: { type: "string", minLength: 1, maxLength: 128, description: "IANA timezone observed for the requester on this Request." }
784
1209
  },
785
1210
  required: CEAL_REQUEST_KEYS
786
1211
  };
@@ -830,21 +1255,26 @@ var REQUEST_NODE_STANDING_OCCURRENCE_SCHEMA = {
830
1255
  },
831
1256
  required: ["schema_version", "node_ref", "operation_id", "correlation_ref", "occurrence_ref", "graph_revision", "graph_revision_digest", "admitted_input_sha256", "reason"]
832
1257
  };
1258
+ var REQUEST_EXECUTION_PREPARE_REFUSAL_PROPERTIES = {
1259
+ schema_version: { type: "string", const: CEAL_OPERATION_ERROR_SCHEMA_VERSION, maxLength: 64 },
1260
+ code: REQUEST_ACTION_SAFE_REF_SCHEMA,
1261
+ message: { type: "string", minLength: 1, maxLength: 2048 },
1262
+ property: { type: "string", minLength: 1, maxLength: 256 },
1263
+ next_action: REQUEST_ACTION_SAFE_REF_SCHEMA,
1264
+ retryable: { type: "boolean" },
1265
+ source: { type: "string", enum: ["provider", "gateway"] },
1266
+ retry_after_ms: { type: "integer", minimum: 0, maximum: CEAL_RETRY_AFTER_MAX_MS },
1267
+ excluded_targets: cealExcludedTargetCoverageJsonSchema(),
1268
+ repaired_input: {},
1269
+ unrepaired_pointers: { type: "array", maxItems: 128, items: { type: "string", minLength: 1, maxLength: 256 } },
1270
+ provider_handoff: { type: "string", const: "not_offered", maxLength: 32 },
1271
+ cause: { type: "string", enum: [...CEAL_OPERATION_WITHHELD_CAUSES] }
1272
+ };
833
1273
  var REQUEST_EXECUTION_PREPARE_REFUSAL_SCHEMA = {
834
1274
  type: "object",
835
1275
  additionalProperties: false,
836
- maxProperties: 9,
837
- properties: {
838
- schema_version: { type: "string", const: CEAL_OPERATION_ERROR_SCHEMA_VERSION, maxLength: 64 },
839
- code: REQUEST_ACTION_SAFE_REF_SCHEMA,
840
- message: { type: "string", minLength: 1, maxLength: 2048 },
841
- property: { type: "string", minLength: 1, maxLength: 256 },
842
- next_action: REQUEST_ACTION_SAFE_REF_SCHEMA,
843
- retryable: { type: "boolean" },
844
- repaired_input: {},
845
- unrepaired_pointers: { type: "array", maxItems: 128, items: { type: "string", minLength: 1, maxLength: 256 } },
846
- provider_handoff: { type: "string", const: "not_offered", maxLength: 32 }
847
- },
1276
+ maxProperties: Object.keys(REQUEST_EXECUTION_PREPARE_REFUSAL_PROPERTIES).length,
1277
+ properties: REQUEST_EXECUTION_PREPARE_REFUSAL_PROPERTIES,
848
1278
  required: ["schema_version", "code", "message", "next_action", "retryable"]
849
1279
  };
850
1280
  var CEAL_REQUEST_EXECUTION_ORDERS = vocabulary(["graph_dependency", "caller"]);
@@ -1021,16 +1451,14 @@ var CEAL_REQUEST_GRAPH_NODE_PREPARE_READINESS_JSON_SCHEMA = {
1021
1451
  };
1022
1452
 
1023
1453
  // packages/ceal-client-protocol/src/client-result-materialization.ts
1024
- var REQUIRED_FIELDS = Object.freeze(["schema_version", "operation_id", "local_path", "content_json_pointer", "size_bytes", "sha256", "read_argv"]);
1025
- var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS, "local_result_root", "model_disclosure"]);
1454
+ var CEAL_MODEL_VISIBLE_COMMAND_OUTPUT_MAX_BYTES = 32 * 1024;
1455
+ var REQUIRED_FIELDS2 = Object.freeze(["schema_version", "operation_id", "read_argv"]);
1456
+ var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "local_result_root"]);
1026
1457
 
1027
1458
  // packages/ceal-client-protocol/src/session-start-affordance.ts
1028
1459
  var CEAL_SESSION_ENTRY_INVOCATION = "ceal";
1029
1460
  var CEAL_LINK_RESOURCE_PRECEDENCE = `When the user asks to use Ceal or provides a link to information that may be available through installed organizational capabilities, run bare \`${CEAL_SESSION_ENTRY_INVOCATION}\`. The Host supplies the current user prompt without exposing it to the client command, and the Gateway returns the applicable entry in that one response. Treat a supplied link as a candidate Ceal resource rather than a public web-search target. Reach for a generic web fetch or web search only when the Gateway offered nothing.`;
1030
1461
 
1031
- // packages/ceal-client-protocol/src/discovery-manifest.ts
1032
- var CEAL_DISCOVERY_MANIFEST_CONNECTOR_KINDS = vocabulary(["github", "google-workspace", "notion", "slack"]);
1033
-
1034
1462
  // packages/ceal-client-protocol/src/conversation-contracts.ts
1035
1463
  var CEAL_APPROVAL_POLICY_KINDS = vocabulary(["requester_only", "named_users", "role_based"]);
1036
1464
  var CEAL_APPROVAL_TARGET_KINDS = vocabulary([
@@ -1073,38 +1501,18 @@ var CEAL_GATEWAY_ANNOUNCEMENT_POLICY_NON_CLAIMS = vocabulary([
1073
1501
 
1074
1502
  // packages/ceal-client-protocol/src/gateway-discovery-response-validation.ts
1075
1503
  var ANNOUNCEMENT_POLICY_CAPABILITY_BINDINGS = Object.freeze({
1076
- "github.repository.get": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1077
- "collection.search": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1078
- "github.issue.get": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1079
- "github.pull_request.get": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1504
+ "repository.get": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1505
+ "resource.search": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1080
1506
  "github.workflow_run.get": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1081
1507
  "message.search": [{ effect: "read", scopeStatementKind: "slack_public_app_member_channels_only", providerAuthorityKind: "slack_app" }],
1082
- "message.get": [{ effect: "read", scopeStatementKind: "slack_public_app_member_channels_only", providerAuthorityKind: "slack_app" }],
1083
- "resource.resolve": [
1084
- { effect: "read", scopeStatementKind: "slack_public_app_member_channels_only", providerAuthorityKind: "slack_app" },
1085
- { effect: "read", scopeStatementKind: "notion_connected_logical_area", providerAuthorityKind: "notion_integration" }
1086
- ],
1087
- "conversation.thread.get": [{ effect: "read", scopeStatementKind: "slack_public_app_member_channels_only", providerAuthorityKind: "slack_app" }],
1088
1508
  "notion.search": [{ effect: "read", scopeStatementKind: "notion_connected_logical_area", providerAuthorityKind: "notion_integration" }],
1089
- "notion.page.get": [{ effect: "read", scopeStatementKind: "notion_connected_logical_area", providerAuthorityKind: "notion_integration" }],
1090
- "calendar.availability": [{ effect: "read", scopeStatementKind: "google_workspace_calendar_read_only", providerAuthorityKind: "google_service_account" }],
1091
- "calendar.event.search": [{ effect: "read", scopeStatementKind: "google_workspace_calendar_read_only", providerAuthorityKind: "google_service_account" }],
1092
- "calendar.event.get": [{ effect: "read", scopeStatementKind: "google_workspace_calendar_read_only", providerAuthorityKind: "google_service_account" }],
1093
- "file.search": [{ effect: "read", scopeStatementKind: "google_workspace_ceal_drive_or_direct_share_metadata", providerAuthorityKind: "google_service_account" }],
1094
- "sheets.values.read": [{ effect: "read", scopeStatementKind: "google_workspace_ceal_drive_or_direct_share_sheet_ranges", providerAuthorityKind: "google_service_account" }],
1095
- "sheets.tabs.list": [{ effect: "read", scopeStatementKind: "google_workspace_ceal_drive_or_direct_share_sheet_tabs", providerAuthorityKind: "google_service_account" }],
1096
- "sheets.values.update": [{ effect: "write", scopeStatementKind: "google_workspace_ceal_drive_or_direct_share_editable_sheet_ranges", providerAuthorityKind: "google_service_account" }],
1097
- "sheets.values.clear": [{ effect: "write", scopeStatementKind: "google_workspace_ceal_drive_or_direct_share_editable_sheet_clear_ranges", providerAuthorityKind: "google_service_account" }]
1098
- });
1099
- var ANNOUNCEMENT_SCOPE_STATEMENTS = Object.freeze({
1100
- github_app_installation_repositories: "Repositories in the installed GitHub App installation.",
1101
- slack_public_app_member_channels_only: "Public channels where the installed Slack app is a member; private channels, direct messages, multi-person direct messages, and requester membership are not declared by this connector.",
1102
- notion_connected_logical_area: "Connected Notion logical area under provider-enforced sharing; descendant inventory is not declared.",
1103
- google_workspace_calendar_read_only: "Approved Calendar availability and event reads only; Calendar mutation is not declared.",
1104
- google_workspace_ceal_drive_or_direct_share_metadata: "Metadata search for files in the organization shared drive named Ceal Drive and files directly shared with the provider application; file-content read and mutation are not declared.",
1105
- google_workspace_ceal_drive_or_direct_share_sheet_ranges: "Bounded values reads from governed Google Sheets in the organization shared drive named Ceal Drive and directly shared files; file mutation is not declared.",
1106
- google_workspace_ceal_drive_or_direct_share_editable_sheet_ranges: "Bounded values updates in governed editable Google Sheets in the organization shared drive named Ceal Drive and directly shared files; Docs, Slides, and other Drive file mutation are not declared.",
1107
- google_workspace_ceal_drive_or_direct_share_editable_sheet_clear_ranges: "Bounded values clears in governed editable Google Sheets in the organization shared drive named Ceal Drive and directly shared files; Docs, Slides, and other Drive file mutation are not declared."
1509
+ "resource.get": [{ effect: "read", scopeStatementKind: "notion_connected_logical_area", providerAuthorityKind: "notion_integration" }],
1510
+ "availability.get": [{ effect: "read", scopeStatementKind: "google_workspace_calendar_read_only", providerAuthorityKind: "google_service_account" }],
1511
+ "event.search": [{ effect: "read", scopeStatementKind: "google_workspace_calendar_read_only", providerAuthorityKind: "google_service_account" }],
1512
+ "file.search": [{ effect: "read", scopeStatementKind: "google_workspace_admitted_drive_target_metadata", providerAuthorityKind: "google_service_account" }],
1513
+ "cell_range.get": [{ effect: "read", scopeStatementKind: "google_workspace_admitted_drive_target_sheet_ranges", providerAuthorityKind: "google_service_account" }],
1514
+ "sheet.list": [{ effect: "read", scopeStatementKind: "google_workspace_admitted_drive_target_sheet_tabs", providerAuthorityKind: "google_service_account" }],
1515
+ "cell_range.update": [{ effect: "write", scopeStatementKind: "google_workspace_admitted_drive_target_editable_sheet_ranges", providerAuthorityKind: "google_service_account" }]
1108
1516
  });
1109
1517
 
1110
1518
  // packages/ceal-client-protocol/src/gateway-write-identity.ts
@@ -1161,90 +1569,6 @@ var ADMIN_LINEAGE_NODE_KINDS = vocabulary(["source_read", "synthesis_preview", "
1161
1569
  // packages/ceal-client-protocol/src/actor-kind.ts
1162
1570
  var CEAL_ACTOR_KINDS = vocabulary(["human", "bot", "app", "unknown"]);
1163
1571
 
1164
- // packages/ceal-client-protocol/src/leased-consumer-vocabulary.ts
1165
- var CEAL_TERMINAL_DISPOSITIONS = vocabulary(["completed", "failed", "cancelled"]);
1166
- var CEAL_LEASE_DISPOSITIONS = vocabulary([...CEAL_TERMINAL_DISPOSITIONS, "deferred"]);
1167
- var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["initial"]);
1168
- var CEAL_LEASED_MESSAGE_DELIVERY_CAPABILITY_IDS = vocabulary(["message.create", "message.update", "message.delete"]);
1169
- var CEAL_REPOSITORY_VISIBILITIES = vocabulary(["public", "private", "internal"]);
1170
- var CEAL_RESULT_DELIVERY_OFFERS = vocabulary(["pending", "offered", "transport_lost"]);
1171
- var CEAL_RESULT_DELIVERY_STATES = vocabulary(["unavailable", ...CEAL_RESULT_DELIVERY_OFFERS]);
1172
- var CEAL_PROVIDER_OUTCOMES = vocabulary(["not_attempted", "outcome_unknown", "verified"]);
1173
- var CEAL_ACTIVITY_GAP_CODES = vocabulary([
1174
- "provider_page_budget",
1175
- "related_item_budget",
1176
- "provider_cursor_unavailable",
1177
- "malformed_provider_page",
1178
- "visibility_incomplete",
1179
- "unsupported_event_kind"
1180
- ]);
1181
- var CEAL_ACTIVITY_COVERAGE_STATUSES = vocabulary(["complete_for_target", "continuation_required", "blocked"]);
1182
- var CEAL_ACTIVITY_EVENT_KINDS = vocabulary([
1183
- "slack.message",
1184
- "slack.reply",
1185
- "github.commit.authored",
1186
- "github.issue.opened",
1187
- "github.pull_request.opened",
1188
- "github.review.submitted",
1189
- "github.issue_comment.created",
1190
- "github.review_comment.created",
1191
- "calendar.organized",
1192
- "calendar.accepted_invite",
1193
- "calendar.recorded"
1194
- ]);
1195
- var CEAL_ACTIVITY_TIMESTAMP_BASES = vocabulary([
1196
- "message_created",
1197
- "commit_authored",
1198
- "resource_created",
1199
- "review_submitted",
1200
- "comment_created",
1201
- "event_start",
1202
- "all_day_start"
1203
- ]);
1204
- var CEAL_ARTIFACT_STAGE_TERMINALS = vocabulary(["chunk_accepted", "artifact_ready", "idempotency_replayed"]);
1205
- var CEAL_READ_ITEM_KINDS = vocabulary(["conversation", "identity", "usergroup", "message", "file", "document"]);
1206
- var CEAL_RESOURCE_RESOLVE_KINDS = vocabulary(["conversation", "identity", "usergroup", "permalink"]);
1207
- var CEAL_OPAQUE_HANDLE_KINDS = vocabulary(["target", "message", "thread", "artifact", "document", "object"]);
1208
- var CEAL_WRITE_OBJECT_KINDS = vocabulary(["document", "comment", "cell_range"]);
1209
- var CEAL_CONVERSATION_KINDS = vocabulary(["channel", "dm", "group"]);
1210
- var CEAL_FILE_TYPE_FAMILIES = vocabulary(["all", "image", "pdf"]);
1211
- var CEAL_GITHUB_ISSUE_STATES = vocabulary(["open", "closed", "all"]);
1212
- var CEAL_NOTION_UPDATABLE_BLOCK_TYPES = vocabulary([
1213
- "paragraph",
1214
- "heading_1",
1215
- "heading_2",
1216
- "heading_3",
1217
- "bulleted_list_item",
1218
- "numbered_list_item",
1219
- "to_do",
1220
- "code"
1221
- ]);
1222
- var CEAL_NOTION_NEUTRAL_TYPES = vocabulary([
1223
- "text",
1224
- "number",
1225
- "boolean",
1226
- "date",
1227
- "select",
1228
- "multi_select",
1229
- "people",
1230
- "url",
1231
- "email",
1232
- "phone",
1233
- "unsupported"
1234
- ]);
1235
- var CEAL_NOTION_IDENTITY_GAP_REASONS = vocabulary([
1236
- "identity_unavailable",
1237
- "identity_stale",
1238
- "identity_ambiguous",
1239
- "identity_revoked",
1240
- "identity_unlinked"
1241
- ]);
1242
- var CEAL_NOTION_STRING_VALUE_TYPES = vocabulary(["text", "select", "url", "email", "phone"]);
1243
- var CEAL_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "permission_denied"]);
1244
- var CEAL_PLAN_ITEM_STATUSES = vocabulary(["pending", "active", "completed"]);
1245
- var CEAL_FINAL_PRESENTATION_INTENTS = vocabulary(["final", "stop", "transient_notice"]);
1246
- var CEAL_PRESENTATION_INTENTS = vocabulary(["progress", ...CEAL_FINAL_PRESENTATION_INTENTS]);
1247
-
1248
1572
  // packages/ceal-client-protocol/src/personal-client-vocabulary.ts
1249
1573
  var CEAL_PERSONAL_CLIENT_BINDING_KEYS = vocabulary([
1250
1574
  "access_group_ref",
@@ -1267,7 +1591,7 @@ var CEAL_REFRESH_FAILURE_CODES = vocabulary([
1267
1591
  ]);
1268
1592
 
1269
1593
  // packages/ceal-client-protocol/src/device-enrollment.ts
1270
- var CEAL_DEVICE_ENROLLMENT_POLL_FAILURE_CODES = Object.freeze(["unsupported_feature", "recovery_required", "expired"]);
1594
+ var CEAL_DEVICE_ENROLLMENT_POLL_FAILURE_CODES = Object.freeze(["unsupported_feature", "recovery_required", "expired", "denied"]);
1271
1595
  var POLL_RESULT_KEYS = Object.freeze(["retry_after_ms", "schema_version", "status"]);
1272
1596
 
1273
1597
  // packages/ceal-client-protocol/src/personal-client-session.ts
@@ -1279,7 +1603,6 @@ var MAX_ARGUMENT_BYTES = 16 * 1024;
1279
1603
  var HANDSHAKE_IDENTITY_KEYS = Object.freeze(["membership_ref", "registration_ref", "client_ref", "subject_ref", "instance_ref"]);
1280
1604
  var AUDIT_IDENTITY_KEYS = Object.freeze(["event_ref", "membership_ref", "registration_ref", "client_ref", "subject_ref", "instance_ref"]);
1281
1605
  var FAILURE_RESPONSE_KEYS = Object.freeze(["error", "ok", "proof_ref_or_unavailable", "protocol_version", "request_id"]);
1282
- var MAX_RECOVERY_RETRY_AFTER_MS = 60 * 60 * 1e3;
1283
1606
 
1284
1607
  // host/abortable-wait.ts
1285
1608
  function waitForAbort(signal, milliseconds) {
@@ -1295,13 +1618,6 @@ function waitForAbort(signal, milliseconds) {
1295
1618
  });
1296
1619
  }
1297
1620
 
1298
- // host/absolute-path.ts
1299
- import { posix, win32 } from "node:path";
1300
- function isAbsoluteNormalizedNonRootPath(value, flavor = process.platform, allowRoot = false) {
1301
- const pathApi = flavor === "win32" || flavor === "windows" ? win32 : posix;
1302
- return typeof value === "string" && value.length <= 4096 && !value.includes("\0") && pathApi.isAbsolute(value) && pathApi.normalize(value) === value && (allowRoot || pathApi.parse(value).root !== value);
1303
- }
1304
-
1305
1621
  // host/producer-service.ts
1306
1622
  var MAX_CONFIG_BYTES = 32 * 1024;
1307
1623
  var SAFE_REF2 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
@@ -1319,7 +1635,15 @@ function parseHostProducerServeArgs(args, platform = process.platform) {
1319
1635
  return parseProducerServeArgs(args, platform, hostProducerError);
1320
1636
  }
1321
1637
  async function readHostProducerConfig(descriptor, configPath, platform = process.platform) {
1322
- return decodeHostProducerConfigText(descriptor, await readProducerConfigText(configPath, platform, hostProducerError), platform);
1638
+ const config = decodeHostProducerConfigText(descriptor, await readProducerConfigText(configPath, platform, hostProducerError), platform);
1639
+ const path = platform === "win32" ? win323 : posix3;
1640
+ const root = path.resolve(config.outbox_dir, "../../../../..");
1641
+ try {
1642
+ assertHostProducerSourcePaths(root, config, descriptor.producer_id, platform);
1643
+ } catch (error) {
1644
+ throw hostProducerError("invalid_config", error instanceof Error ? error.message : "Host producer source tuple is invalid.");
1645
+ }
1646
+ return config;
1323
1647
  }
1324
1648
  function decodeHostProducerConfigText(descriptor, text, platform = process.platform) {
1325
1649
  const extraPaths = descriptor.extra_paths ?? [];
@@ -1688,6 +2012,9 @@ function errorCode(error) {
1688
2012
  return typeof error === "object" && error !== null && "code" in error ? String(error.code) : null;
1689
2013
  }
1690
2014
 
2015
+ // host/relay/src/relay-request-binding-store.ts
2016
+ var MAX_STATE_BYTES = 8 * 1024 * 1024;
2017
+
1691
2018
  // host/relay/src/relay-quarantine-store.ts
1692
2019
  var RELAY_QUARANTINE_MAX_BYTES = 16 * 1024 * 1024;
1693
2020
 
@@ -1696,9 +2023,6 @@ var DEFAULT_LIMITS = { global_count: 8192, global_bytes: 64 * 1024 * 1024, produ
1696
2023
  var RETRY_SECONDS = [1, 2, 4, 8, 16, 32, 60];
1697
2024
  var MAX_RETRYABLE_ATTEMPTS = RETRY_SECONDS.length + 10;
1698
2025
 
1699
- // host/relay/src/relay-request-binding-store.ts
1700
- var MAX_STATE_BYTES = 8 * 1024 * 1024;
1701
-
1702
2026
  // host/relay/src/relay-ipc.ts
1703
2027
  import { createConnection, createServer } from "node:net";
1704
2028
 
@@ -1724,13 +2048,53 @@ var HOST_RELAY_REQUEST_BINDING_KEYS = Object.freeze([
1724
2048
  var HOST_RELAY_IPC_RESPONSE_SCHEMA = "ceal.host_relay_admission.v1";
1725
2049
  var HOST_RELAY_IPC_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
1726
2050
  var HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES = 4096;
2051
+ var HOST_RELAY_INVOCATION_MINT_REFUSAL_REASONS = vocabulary([
2052
+ "context_stale",
2053
+ "context_expired",
2054
+ "host_source_refused",
2055
+ "host_credential_refused",
2056
+ "gateway_unavailable",
2057
+ "gateway_refused",
2058
+ "gateway_response_invalid",
2059
+ "deadline",
2060
+ "cancelled",
2061
+ "mint_failed",
2062
+ "relay_failed"
2063
+ ]);
2064
+ var HOST_RELAY_INVOCATION_MINT_OUTCOMES = vocabulary(["completed", "caller_cancelled", "deadline", "failed", "no_binding"]);
2065
+ var HOST_RELAY_EXCHANGE_FAILURES = vocabulary([
2066
+ "permission_denied",
2067
+ "socket_missing",
2068
+ "connection_refused",
2069
+ "closed_early",
2070
+ "response_invalid",
2071
+ "timed_out",
2072
+ "cancelled",
2073
+ "unavailable"
2074
+ ]);
1727
2075
  var HostRelayIpcError = class extends Error {
1728
2076
  code;
1729
- constructor(code3, message = code3) {
2077
+ /** Set only when the client-side socket exchange itself failed. */
2078
+ failure;
2079
+ constructor(code3, message = code3, failure) {
1730
2080
  super(message);
1731
2081
  this.code = code3;
2082
+ this.failure = failure;
1732
2083
  }
1733
2084
  };
2085
+ function socketErrorFailure(error) {
2086
+ switch (errorCode2(error)) {
2087
+ case "EACCES":
2088
+ case "EPERM":
2089
+ return "permission_denied";
2090
+ case "ENOENT":
2091
+ return "socket_missing";
2092
+ case "ECONNREFUSED":
2093
+ return "connection_refused";
2094
+ default:
2095
+ return "unavailable";
2096
+ }
2097
+ }
1734
2098
  var HostRelayIpcAdmissionPort = class {
1735
2099
  endpoint;
1736
2100
  timeout_ms;
@@ -1752,7 +2116,7 @@ function exchange(endpoint, encoded, timeoutMs, decode, signal) {
1752
2116
  const socket = createConnection(endpoint);
1753
2117
  let buffer = Buffer.alloc(0);
1754
2118
  let settled = false;
1755
- const aborted = () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC was cancelled."));
2119
+ const aborted = () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC was cancelled.", "cancelled"));
1756
2120
  const finish = (error, response2) => {
1757
2121
  if (settled) return;
1758
2122
  settled = true;
@@ -1761,13 +2125,16 @@ function exchange(endpoint, encoded, timeoutMs, decode, signal) {
1761
2125
  if (error !== null) reject(error);
1762
2126
  else if (response2 !== void 0) resolve(response2);
1763
2127
  };
1764
- if (timeoutMs !== void 0) socket.setTimeout(timeoutMs, () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC timed out.")));
2128
+ if (timeoutMs !== void 0) socket.setTimeout(timeoutMs, () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC timed out.", "timed_out")));
1765
2129
  if (signal?.aborted === true) {
1766
2130
  aborted();
1767
2131
  return;
1768
2132
  }
1769
2133
  signal?.addEventListener("abort", aborted, { once: true });
1770
- socket.once("error", () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC is unavailable.")));
2134
+ socket.once("error", (error) => {
2135
+ const failure = socketErrorFailure(error);
2136
+ finish(new HostRelayIpcError("relay_unavailable", `Host Relay IPC is unavailable: ${failure}.`, failure));
2137
+ });
1771
2138
  socket.once("connect", () => socket.write(encoded));
1772
2139
  socket.on("data", (chunk) => {
1773
2140
  try {
@@ -1775,11 +2142,11 @@ function exchange(endpoint, encoded, timeoutMs, decode, signal) {
1775
2142
  const decoded = decode(buffer);
1776
2143
  if (decoded !== null) finish(null, decoded);
1777
2144
  } catch (error) {
1778
- finish(error instanceof Error ? error : new HostRelayIpcError("relay_unavailable"));
2145
+ finish(new HostRelayIpcError("relay_unavailable", error instanceof Error ? error.message : "Host Relay IPC response is invalid.", "response_invalid"));
1779
2146
  }
1780
2147
  });
1781
2148
  socket.once("end", () => {
1782
- if (!settled) finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC closed without a response."));
2149
+ if (!settled) finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC closed without a response.", "closed_early"));
1783
2150
  });
1784
2151
  });
1785
2152
  }
@@ -1819,6 +2186,9 @@ function decodeResponseBuffer(buffer) {
1819
2186
  if (buffer.length !== length + HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC returned trailing bytes: ${refusalFacts([{ name: "declared_bytes", value: length, expected: `the received message length minus ${HOST_RELAY_IPC_LENGTH_BYTES}` }, { name: "received_bytes", value: buffer.byteLength, expected: `exactly ${length + HOST_RELAY_IPC_LENGTH_BYTES}` }])}.`);
1820
2187
  return decodeHostRelayIpcResponse(buffer);
1821
2188
  }
2189
+ function errorCode2(error) {
2190
+ return record2(error) && typeof error.code === "string" ? error.code : null;
2191
+ }
1822
2192
 
1823
2193
  // host/claude/src/claude-producer.ts
1824
2194
  import { mkdir as mkdir3, readFile as readFile2, rename as rename2, writeFile } from "node:fs/promises";
@@ -2190,6 +2560,7 @@ async function drainClaudeProducerOnce(options) {
2190
2560
  var CLAUDE_PRODUCER_CONFIG_SCHEMA = "ceal.claude_producer_config.v1";
2191
2561
  var CLAUDE_PRODUCER_DESCRIPTOR = {
2192
2562
  schema: CLAUDE_PRODUCER_CONFIG_SCHEMA,
2563
+ producer_id: "claude",
2193
2564
  config: (shared) => shared,
2194
2565
  runtime_options: (config) => Object.freeze({
2195
2566
  outbox_dir: config.outbox_dir,
@@ -2204,12 +2575,60 @@ function runClaudeProducerCli(args, signal, dependencies = {}) {
2204
2575
  return runHostProducerCli(CLAUDE_PRODUCER_DESCRIPTOR, args, signal, dependencies);
2205
2576
  }
2206
2577
 
2578
+ // host/service-log.ts
2579
+ import { copyFile, open as open4, stat, truncate } from "node:fs/promises";
2580
+ import { isAbsolute } from "node:path";
2581
+ var HOST_SERVICE_LOG_ENVIRONMENT = "CEAL_HOST_SERVICE_LOG";
2582
+ var HOST_SERVICE_LOG_MAX_BYTES = 1024 * 1024;
2583
+ var HOST_SERVICE_LOG_CHECK_INTERVAL_MS = 6e4;
2584
+ function hostServiceLogPreviousPath(path) {
2585
+ return `${path}.1`;
2586
+ }
2587
+ async function rotateHostServiceLog(path, maxBytes = HOST_SERVICE_LOG_MAX_BYTES) {
2588
+ let size;
2589
+ try {
2590
+ size = (await stat(path)).size;
2591
+ } catch (error) {
2592
+ if (isNotFound(error)) return false;
2593
+ throw error;
2594
+ }
2595
+ if (size <= maxBytes) return false;
2596
+ await copyFile(path, hostServiceLogPreviousPath(path));
2597
+ await truncate(path, 0);
2598
+ return true;
2599
+ }
2600
+ function boundHostServiceLog(environment = process.env) {
2601
+ const path = environment[HOST_SERVICE_LOG_ENVIRONMENT];
2602
+ if (path === void 0 || !isAbsolute(path)) return () => void 0;
2603
+ let reported = false;
2604
+ const check = () => {
2605
+ rotateHostServiceLog(path).catch((error) => {
2606
+ if (reported) return;
2607
+ reported = true;
2608
+ process.stderr.write(`[host-service-log] rotation_failed code=${errorCode3(error)}
2609
+ `);
2610
+ });
2611
+ };
2612
+ check();
2613
+ const timer = setInterval(check, HOST_SERVICE_LOG_CHECK_INTERVAL_MS);
2614
+ timer.unref();
2615
+ return () => clearInterval(timer);
2616
+ }
2617
+ var HOST_SERVICE_LOG_TAIL_BYTES = 64 * 1024;
2618
+ function isNotFound(error) {
2619
+ return errorCode3(error) === "ENOENT";
2620
+ }
2621
+ function errorCode3(error) {
2622
+ return typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : "unknown";
2623
+ }
2624
+
2207
2625
  // host/producer-command.ts
2208
2626
  async function runProducerCommand(schemaVersion, run) {
2209
2627
  const controller = new AbortController();
2210
2628
  const stop = () => controller.abort();
2211
2629
  process.once("SIGINT", stop);
2212
2630
  process.once("SIGTERM", stop);
2631
+ const stopLogBound = boundHostServiceLog();
2213
2632
  try {
2214
2633
  await run(process.argv.slice(2), controller.signal);
2215
2634
  } catch (error) {
@@ -2218,6 +2637,7 @@ async function runProducerCommand(schemaVersion, run) {
2218
2637
  `);
2219
2638
  process.exitCode = 1;
2220
2639
  } finally {
2640
+ stopLogBound();
2221
2641
  process.removeListener("SIGINT", stop);
2222
2642
  process.removeListener("SIGTERM", stop);
2223
2643
  }