@corca-org/ceal-host-win32-x64 1.0.10 → 1.0.11

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,18 +2,6 @@
2
2
  import { createRequire as __cealCreateRequire } from "node:module";
3
3
  const require = __cealCreateRequire(import.meta.url);
4
4
 
5
- // host/direct-invocation.ts
6
- import { realpathSync } from "node:fs";
7
- import { fileURLToPath } from "node:url";
8
- function isDirectInvocation(importMetaUrl, argv1 = process.argv[1]) {
9
- if (!argv1) return false;
10
- try {
11
- return realpathSync(fileURLToPath(importMetaUrl)) === realpathSync(argv1);
12
- } catch {
13
- return false;
14
- }
15
- }
16
-
17
5
  // host/claude/src/claude-types.ts
18
6
  var CLAUDE_HOOK_EVENTS = ["SessionStart", "UserPromptSubmit", "Stop", "StopFailure"];
19
7
  var CLAUDE_HOST_ERROR_CODES = ["invalid_input", "storage", "configuration"];
@@ -97,6 +85,46 @@ var client_wire_contract_default = {
97
85
  schema_version: "ceal.command_request.v1",
98
86
  absolute_transport_max_bytes: 65536
99
87
  },
88
+ command_resolution: {
89
+ schema_version: "ceal.gateway_command_resolution.v1",
90
+ authority: {
91
+ anonymous: {
92
+ state: "anonymous",
93
+ fields: [
94
+ "state"
95
+ ]
96
+ },
97
+ authenticated: {
98
+ state: "authenticated",
99
+ fields: [
100
+ "state",
101
+ "principal_kind",
102
+ "organization_ref",
103
+ "instance_ref",
104
+ "access_group_ref",
105
+ "principal_ref",
106
+ "authority_revision_ref"
107
+ ]
108
+ }
109
+ },
110
+ semantic_options: {
111
+ inspection: {
112
+ values: [
113
+ "default",
114
+ "full"
115
+ ]
116
+ },
117
+ cache_mode: {
118
+ values: [
119
+ "default",
120
+ "bypass"
121
+ ]
122
+ },
123
+ compact: {
124
+ type: "boolean"
125
+ }
126
+ }
127
+ },
100
128
  command_response: {
101
129
  schema_version: "ceal.command_response.v1",
102
130
  descriptor_field: "verified_artifact",
@@ -110,12 +138,15 @@ var client_wire_contract_default = {
110
138
  ],
111
139
  bare_document_fields: [
112
140
  "invocation",
113
- "required_action_sequence",
114
141
  "entrypoints",
115
142
  "common_concepts",
116
143
  "operations",
117
144
  "catalog_revision"
118
145
  ],
146
+ bare_document_optional_fields: [
147
+ "required_action_sequence",
148
+ "withheld"
149
+ ],
119
150
  prompt_field: "prompt",
120
151
  prompt_schema_version: "ceal.prompt.v1",
121
152
  focused_prompt_document_fields: [
@@ -128,7 +159,7 @@ var client_wire_contract_default = {
128
159
  "prompt"
129
160
  ],
130
161
  discovery_command: "discovery",
131
- discovery_manifest_schema_version: "ceal.discovery_manifest.v1",
162
+ discovery_manifest_schema_version: "ceal.discovery_manifest.v2",
132
163
  discovery_manifest_document_fields: [
133
164
  "discovery_manifest"
134
165
  ],
@@ -136,11 +167,29 @@ var client_wire_contract_default = {
136
167
  bare_document_max_bytes: 65536,
137
168
  complete_max_bytes: 66019,
138
169
  absolute_transport_max_bytes: 4194304
170
+ },
171
+ resource_stream: {
172
+ path: "/api/ceal/v2/resources",
173
+ request_schema_version: "ceal.resource_stream_request.v1",
174
+ ref_pattern: "^resource:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
175
+ media_type_pattern: "^[a-z0-9][a-z0-9!#$&^_.+-]{0,63}/[a-z0-9][a-z0-9!#$&^_.+-]{0,63}$",
176
+ filename_max_bytes: 512,
177
+ max_bytes: 9007199254740991,
178
+ deadline_ms: 6e5,
179
+ fetch_argv: [
180
+ "resource",
181
+ "fetch"
182
+ ],
183
+ ref_flag: "--ref"
139
184
  }
140
185
  };
141
186
 
142
187
  // packages/ceal-client-protocol/src/client-wire-contract.ts
143
188
  var CEAL_CLIENT_WIRE_CONTRACT = Object.freeze(client_wire_contract_default);
189
+ var commandResolution = CEAL_CLIENT_WIRE_CONTRACT.command_resolution;
190
+ var commandResolutionAuthority = commandResolution.authority;
191
+ var commandResolutionSemanticOptions = commandResolution.semantic_options;
192
+ var CEAL_GATEWAY_COMMAND_RESOLUTION_SCHEMA_VERSION = commandResolution.schema_version;
144
193
  var artifact = CEAL_CLIENT_WIRE_CONTRACT.artifact_descriptor;
145
194
  var request = CEAL_CLIENT_WIRE_CONTRACT.command_request;
146
195
  var response = CEAL_CLIENT_WIRE_CONTRACT.command_response;
@@ -161,6 +210,7 @@ var CEAL_COMMAND_REQUEST_MAX_BYTES = request.absolute_transport_max_bytes;
161
210
  var CEAL_COMMAND_RESPONSE_BARE_DOCUMENT_MAX_BYTES = response.bare_document_max_bytes;
162
211
  var CEAL_COMMAND_RESPONSE_PROMPT_FIELD = response.prompt_field;
163
212
  var CEAL_COMMAND_RESPONSE_PROMPT_SCHEMA_VERSION = response.prompt_schema_version;
213
+ var CEAL_COMMAND_RESPONSE_BARE_DOCUMENT_OPTIONAL_FIELDS = Object.freeze([...response.bare_document_optional_fields]);
164
214
  var CEAL_COMMAND_RESPONSE_PROMPT_DOCUMENT_FIELDS = Object.freeze([...response.bare_document_fields, response.prompt_field]);
165
215
  var CEAL_COMMAND_RESPONSE_FOCUSED_PROMPT_DOCUMENT_FIELDS = Object.freeze([...response.focused_prompt_document_fields]);
166
216
  var CEAL_COMMAND_RESPONSE_FOCUSED_PROMPT_CONTINUATION_DOCUMENT_FIELDS = Object.freeze([...response.focused_prompt_continuation_document_fields]);
@@ -174,9 +224,50 @@ function vocabulary(words) {
174
224
  return Object.freeze(words);
175
225
  }
176
226
 
227
+ // packages/ceal-client-protocol/src/gateway-response-types.ts
228
+ var CEAL_OPERATION_READINESS_VALUES = vocabulary(["ready", "degraded", "unavailable", "unknown"]);
229
+ var CEAL_TARGET_REQUIREMENTS = vocabulary(["required", "optional", "none"]);
230
+ var CEAL_AUDIT_OUTCOMES = vocabulary(["succeeded", "denied", "failed"]);
231
+ var CEAL_GATEWAY_PROVIDER_STEP_OUTCOMES = vocabulary(["completed", "rejected", "throttled", "failed"]);
232
+ 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"]);
233
+ var CEAL_GATEWAY_READ_REUSE_UNAVAILABLE_REASONS = vocabulary(["not_reported", "storage_unavailable", "coverage_incomplete", "freshness_refresh_required", "not_reusable", "bypassed"]);
234
+ var CEAL_POLICY_DECISIONS = vocabulary(["allowed", "denied", "not_evaluated"]);
235
+ var CEAL_CONNECTOR_ROUTE_PHASES = vocabulary(["scope_observation", "target_selection", "route_resolution"]);
236
+ var CEAL_CONNECTOR_ROUTE_CAUSES = vocabulary(["provider_throttled", "provider_unavailable", "binding_invalid", "scope_limit_exceeded"]);
237
+ var CEAL_WRITE_SOURCE_KINDS = vocabulary(["authenticated_registered_client", "agent_lease_admission", "provider_authenticated_event"]);
238
+ var CEAL_REFRESH_DELIVERIES = vocabulary(["initial", "recovery", "replay", "terminal_failure", "recovery_unavailable"]);
239
+ var CEAL_CLIENT_OPERATIONS = vocabulary(["handshake", "discover", "call", "readback"]);
240
+ var CEAL_WRITE_IDEMPOTENCY_POSTURES = vocabulary(["required", "optional", "not_required"]);
241
+ var CEAL_WRITE_PROVIDER_READBACK_POSTURES = vocabulary(["required", "best_effort", "not_available"]);
242
+ var CEAL_WRITE_ATTRIBUTIONS = vocabulary(["subject", "requester_event", "connector_integration"]);
243
+ var CEAL_WRITE_RECEIPT_PROVIDER_STATES = vocabulary(["outcome_unknown", "verified", "not_dispatched"]);
244
+ var CEAL_WRITE_RECEIPT_PROVIDER_READBACKS = vocabulary(["outcome_unknown", "verified", "not_applied"]);
245
+ var CEAL_PROTOCOL_VERSION = "1.4.0";
246
+ var CEAL_GATEWAY_ANNOUNCEMENT_SCOPE_STATEMENTS = Object.freeze({
247
+ github_app_installation_repositories: "Repositories in the installed GitHub App installation.",
248
+ 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.",
249
+ notion_connected_logical_area: "Connected Notion logical area under provider-enforced sharing; descendant inventory is not declared.",
250
+ google_workspace_calendar_read_only: "Approved Calendar availability and event reads only; Calendar mutation is not declared.",
251
+ 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.",
252
+ 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.",
253
+ 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.",
254
+ 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."
255
+ });
256
+ var CEAL_OPERATION_ACCESS_SCHEMA_VERSION = "ceal.operation_access.v1";
257
+ var CEAL_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["connector_kind", "phase", "schema_version"]);
258
+ var CEAL_CLASSIFIED_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["cause", ...CEAL_CONNECTOR_ROUTE_FAILURE_KEYS]);
259
+ var CEAL_UNCLASSIFIED_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["connector_kind", "error_class", "phase", "schema_version"]);
260
+ var CEAL_GATEWAY_ORGANIZATION_ROUTE_FACT_CALL_KEYS = Object.freeze([
261
+ "connector_ref",
262
+ "connector_revision",
263
+ "policy_decision_revision"
264
+ ]);
265
+
177
266
  // packages/ceal-client-protocol/src/operation-contract-types.ts
178
267
  var CEAL_JSON_SCHEMA_2020_12 = "https://json-schema.org/draft/2020-12/schema";
179
268
  var CEAL_OPERATION_ERROR_SCHEMA_VERSION = "ceal.operation_error.v1";
269
+ var CEAL_OPERATION_WITHHELD_CAUSES = vocabulary(["provider_permission", "access_level", "personal_authorization_required"]);
270
+ var CEAL_RETRY_AFTER_MAX_MS = 60 * 60 * 1e3;
180
271
  var CEAL_JSON_SCHEMA_TYPES = vocabulary(["object", "array", "string", "integer", "number", "boolean", "null"]);
181
272
  var OBSERVATION_POSTURES = vocabulary(["direct_readback", "approved_no_readback", "operator_mediated", "excluded"]);
182
273
  var EFFECT_DOMAINS = vocabulary(["none", "gateway_state", "provider", "external_world"]);
@@ -212,27 +303,6 @@ var CEAL_OPERATION_APPROVAL_DISPOSITIONS = vocabulary([
212
303
  "interactive_unavailable"
213
304
  ]);
214
305
 
215
- // packages/ceal-client-protocol/src/gateway-response-types.ts
216
- var CEAL_CAPABILITY_READINESS_VALUES = vocabulary(["ready", "degraded", "unavailable", "unknown"]);
217
- var CEAL_TARGET_REQUIREMENTS = vocabulary(["required", "optional", "none"]);
218
- var CEAL_AUDIT_OUTCOMES = vocabulary(["succeeded", "denied", "failed"]);
219
- var CEAL_GATEWAY_PROVIDER_STEP_OUTCOMES = vocabulary(["completed", "rejected", "throttled", "failed"]);
220
- 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"]);
221
- var CEAL_GATEWAY_READ_REUSE_UNAVAILABLE_REASONS = vocabulary(["not_reported", "storage_unavailable", "coverage_incomplete", "freshness_refresh_required", "not_reusable", "bypassed"]);
222
- var CEAL_POLICY_DECISIONS = vocabulary(["allowed", "denied", "not_evaluated"]);
223
- var CEAL_CONNECTOR_ROUTE_PHASES = vocabulary(["scope_observation", "target_selection", "route_resolution"]);
224
- var CEAL_CONNECTOR_ROUTE_CAUSES = vocabulary(["provider_throttled", "provider_unavailable", "binding_invalid", "scope_limit_exceeded"]);
225
- var CEAL_WRITE_SOURCE_KINDS = vocabulary(["authenticated_registered_client", "agent_lease_admission", "provider_authenticated_event"]);
226
- var CEAL_REFRESH_DELIVERIES = vocabulary(["initial", "recovery", "replay", "terminal_failure", "recovery_unavailable"]);
227
- var CEAL_CLIENT_OPERATIONS = vocabulary(["handshake", "discover", "call", "readback"]);
228
- var CEAL_WRITE_IDEMPOTENCY_POSTURES = vocabulary(["required", "optional", "not_required"]);
229
- var CEAL_WRITE_PROVIDER_READBACK_POSTURES = vocabulary(["required", "best_effort", "not_available"]);
230
- var CEAL_WRITE_ATTRIBUTIONS = vocabulary(["subject", "requester_event", "connector_integration"]);
231
- var CEAL_PROTOCOL_VERSION = "1.4.0";
232
- var CEAL_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["connector_kind", "phase", "schema_version"]);
233
- var CEAL_CLASSIFIED_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["cause", ...CEAL_CONNECTOR_ROUTE_FAILURE_KEYS]);
234
- var CEAL_UNCLASSIFIED_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["connector_kind", "error_class", "phase", "schema_version"]);
235
-
236
306
  // packages/ceal-client-protocol/src/gateway-validation-primitives.ts
237
307
  var CealProtocolValidationError = class extends Error {
238
308
  name = "CealProtocolValidationError";
@@ -249,6 +319,7 @@ var SAFE_CONNECTOR_KIND = new RegExp(`^[a-z][a-z0-9-]{0,${MAX_SAFE_TOKEN_LENGTH
249
319
  var FORBIDDEN_SECRET_KEY = /^(?:[a-z0-9_]*(?:token|secret|password|credential(?:s)?|private_?key)|api_?key|authorization|bearer|raw_?provider_?payload|provider_?payload)$/iu;
250
320
  var FORBIDDEN_AUTHORITY_KEY = /^(?:actor_?ref|owner_?ref|registration_?ref|runner_?ref|auth_?decision|policy_?decision|host_?decision)$/iu;
251
321
  var TEXT_ENCODER = new TextEncoder();
322
+ var CEAL_WIRE_SAFE_ARRAY_MAX_ITEMS = 128;
252
323
  var CEAL_WIRE_SAFE_TEXT_MAX_BYTES = 8 * 1024;
253
324
  function assertSafeJsonValue(value, options, depth = 0, count = { value: 0 }) {
254
325
  count.value += 1;
@@ -268,12 +339,12 @@ function assertSafeJsonString(value, options) {
268
339
  if (byteLength(value) > CEAL_WIRE_SAFE_TEXT_MAX_BYTES || firstDisallowedControl(value, "multi_line") !== null) invalidByContext(options);
269
340
  }
270
341
  function assertSafeJsonArray(value, options, depth, count) {
271
- if (value.length > 128) invalidByContext(options);
342
+ if (value.length > CEAL_WIRE_SAFE_ARRAY_MAX_ITEMS) invalidByContext(options);
272
343
  for (const item of value) assertSafeJsonValue(item, options, depth + 1, count);
273
344
  }
274
345
  function assertSafeJsonRecord(record7, options, depth, count) {
275
346
  const entries = Object.entries(record7);
276
- if (entries.length > 128) invalidByContext(options);
347
+ if (entries.length > CEAL_WIRE_SAFE_ARRAY_MAX_ITEMS) invalidByContext(options);
277
348
  const sourceUrlColumn = options.allowHttpsUrl ? compactSourceUrlColumn(record7.fields) : null;
278
349
  for (const [key, child] of entries) {
279
350
  if (key === "credential_material_included" && child !== false) invalidByContext(options);
@@ -299,9 +370,9 @@ function compactSourceUrlColumn(fields) {
299
370
  return index < 0 ? null : index;
300
371
  }
301
372
  function assertSafeJsonCompactRows(value, sourceUrlColumn, options, depth, count) {
302
- if (!Array.isArray(value) || value.length > 128) invalidByContext(options);
373
+ if (!Array.isArray(value) || value.length > CEAL_WIRE_SAFE_ARRAY_MAX_ITEMS) invalidByContext(options);
303
374
  for (const row of value) {
304
- if (!Array.isArray(row) || row.length > 128) invalidByContext(options);
375
+ if (!Array.isArray(row) || row.length > CEAL_WIRE_SAFE_ARRAY_MAX_ITEMS) invalidByContext(options);
305
376
  for (const [index, cell] of row.entries()) {
306
377
  if (index === sourceUrlColumn && (cell === null || isSafeExternalHttpsUrl(cell))) continue;
307
378
  assertSafeJsonValue(cell, options, depth + 2, count);
@@ -334,6 +405,7 @@ function isSafeResultContent(value, key) {
334
405
  const maximum = key === "text" ? 8192 : 1024;
335
406
  return typeof value === "string" && byteLength(value) <= maximum && firstDisallowedControl(value, "multi_line") === null;
336
407
  }
408
+ var CEAL_PUBLIC_DISPLAY_NAME_MAX_BYTES = 512;
337
409
  function normalizeCealSingleLineText(value) {
338
410
  return value.split("").map((character) => hasControlCharacter(character) ? " " : character).join("").trim();
339
411
  }
@@ -442,6 +514,28 @@ function cut(text) {
442
514
  return text.length <= REFUSAL_VALUE_MAX_CHARS ? text : `${text.slice(0, REFUSAL_VALUE_MAX_CHARS)}...(+${text.length - REFUSAL_VALUE_MAX_CHARS} chars)`;
443
515
  }
444
516
 
517
+ // packages/ceal-client-protocol/src/operation-access-class.ts
518
+ var CEAL_OPERATION_ACCESS_CLASSES = vocabulary(["read", "write"]);
519
+
520
+ // packages/ceal-client-protocol/src/domain-vocabulary.ts
521
+ var CEAL_INTEGRATION_KINDS = vocabulary(["github", "google-workspace", "notion", "slack"]);
522
+ var CEAL_CONNECTOR_STATUSES = vocabulary(["active", "disabled", "disconnected"]);
523
+ var CEAL_CONNECTOR_CUSTODIES = vocabulary(["organization", "personal"]);
524
+ var CEAL_PROVIDER_BOUNDARY_KINDS = vocabulary([
525
+ "github_account",
526
+ "github_organization",
527
+ "google_workspace_domain",
528
+ "notion_workspace",
529
+ "slack_workspace"
530
+ ]);
531
+ var CEAL_PROVIDER_BOUNDARY_EVIDENCE = vocabulary(["provider_readback", "operator_stated"]);
532
+ var CEAL_ACCESS_LEVELS = vocabulary(["none", "read", "read_write"]);
533
+ var CEAL_PERSONAL_ACCESS_CEILINGS = vocabulary(["disabled", "read", "read_write"]);
534
+ var CEAL_TARGET_VISIBILITIES = vocabulary(["public", "private"]);
535
+ var CEAL_PRINCIPAL_KINDS = vocabulary(["human", "service", "runtime"]);
536
+ var CEAL_ORGANIZATION_ROLES = vocabulary(["member", "admin"]);
537
+ var LABEL_EXPECTATION = `public-safe display text of at most ${CEAL_PUBLIC_DISPLAY_NAME_MAX_BYTES} bytes`;
538
+
445
539
  // packages/ceal-client-protocol/src/safe-json-budget.ts
446
540
  var SAFE_JSON_MIN_BYTES_PER_NODE = 4;
447
541
  function safeJsonNodeBudgetForBytes(maxBytes) {
@@ -471,7 +565,9 @@ var CEAL_OPERATION_JSON_SCHEMA_BUDGET = Object.freeze({
471
565
  });
472
566
 
473
567
  // packages/ceal-client-protocol/src/operation-validation-primitives.ts
474
- var ISO_TIMESTAMP = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/u;
568
+ 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;
569
+ var CEAL_CALENDAR_DATE_PATTERN_SOURCE = "^\\d{4}-\\d{2}-\\d{2}$";
570
+ var CEAL_CALENDAR_DATE = new RegExp(CEAL_CALENDAR_DATE_PATTERN_SOURCE, "u");
475
571
  function isOperationRecord(value) {
476
572
  if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
477
573
  const prototype = Object.getPrototypeOf(value);
@@ -483,8 +579,56 @@ function requireOperationRecord(value, message) {
483
579
  function requireClosedValue(value, members, message) {
484
580
  if (typeof value !== "string" || !members.includes(value)) throw new TypeError(message);
485
581
  }
582
+ function isCealIsoTimestamp(value) {
583
+ return typeof value === "string" && parseCealIsoTimestamp(value) !== null;
584
+ }
585
+ function parseCealIsoTimestamp(value) {
586
+ const fields = parseCealIsoTimestampFields(value);
587
+ if (fields === null || !validCalendarDate(fields) || !validClockTime(fields) || !validUtcOffset(fields)) return null;
588
+ const epochMilliseconds = cealFieldsEpochMilliseconds(fields);
589
+ if (!Number.isFinite(epochMilliseconds)) return null;
590
+ return {
591
+ epochNanoseconds: BigInt(epochMilliseconds) * 1000000n + BigInt(fields.fraction.padEnd(9, "0") || "0")
592
+ };
593
+ }
594
+ function parseCealIsoTimestampFields(value) {
595
+ const match = ISO_TIMESTAMP.exec(value);
596
+ if (match === null) return null;
597
+ return {
598
+ year: Number(match[1]),
599
+ month: Number(match[2]),
600
+ day: Number(match[3]),
601
+ hour: Number(match[4]),
602
+ minute: Number(match[5]),
603
+ second: Number(match[6]),
604
+ fraction: match[7] ?? "",
605
+ offsetSign: match[9] === void 0 ? 0 : match[9] === "+" ? 1 : -1,
606
+ offsetHour: Number(match[10] ?? 0),
607
+ offsetMinute: Number(match[11] ?? 0)
608
+ };
609
+ }
610
+ function validCalendarDate({ year, month, day }) {
611
+ return month >= 1 && month <= 12 && day >= 1 && day <= daysInMonth(year, month);
612
+ }
613
+ function validClockTime({ hour, minute, second }) {
614
+ return hour <= 23 && minute <= 59 && second <= 59;
615
+ }
616
+ function validUtcOffset({ offsetHour, offsetMinute }) {
617
+ return offsetHour <= 23 && offsetMinute <= 59;
618
+ }
619
+ function cealFieldsEpochMilliseconds(fields) {
620
+ const shiftedYear = fields.year < 100 ? fields.year + 400 : fields.year;
621
+ const cycleMilliseconds = fields.year < 100 ? (400 * 365 + 97) * 24 * 60 * 60 * 1e3 : 0;
622
+ const localMilliseconds = Date.UTC(shiftedYear, fields.month - 1, fields.day, fields.hour, fields.minute, fields.second, 0) - cycleMilliseconds;
623
+ const offsetMilliseconds = fields.offsetSign * (fields.offsetHour * 60 + fields.offsetMinute) * 6e4;
624
+ return localMilliseconds - offsetMilliseconds;
625
+ }
626
+ function daysInMonth(year, month) {
627
+ const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
628
+ return [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1] ?? 0;
629
+ }
486
630
  function requireIsoTimestamp(value, message) {
487
- if (typeof value !== "string" || !ISO_TIMESTAMP.test(value) || !Number.isFinite(Date.parse(value))) throw new TypeError(message);
631
+ if (!isCealIsoTimestamp(value)) throw new TypeError(message);
488
632
  }
489
633
 
490
634
  // packages/ceal-client-protocol/src/operation-json-schema.ts
@@ -506,7 +650,7 @@ var CLIENT_AUDIENCE_SET = new Set(CLIENT_AUDIENCES);
506
650
  // packages/ceal-client-protocol/src/schema-literals.ts
507
651
  var CEAL_SCHEMA_LITERALS = [
508
652
  "ceal.activation_transport.v1",
509
- "ceal.capability_access.v1",
653
+ CEAL_OPERATION_ACCESS_SCHEMA_VERSION,
510
654
  CEAL_OPERATION_CATALOG_SCHEMA_VERSION,
511
655
  "ceal.client_refresh_request.v2",
512
656
  "ceal.client_refresh_result.v2",
@@ -529,7 +673,6 @@ var CEAL_SCHEMA_LITERALS = [
529
673
  "ceal.enrollment_exchange.v1",
530
674
  "ceal.enrollment_result.v1",
531
675
  "ceal.first_activation_causal_join.v1",
532
- "ceal.gateway_aggregate_authorization_snapshot.v2",
533
676
  "ceal.gateway_announcement_policy.v1",
534
677
  "ceal.gateway_audit_call_detail.v1",
535
678
  "ceal.gateway_audit_event.v1",
@@ -537,7 +680,7 @@ var CEAL_SCHEMA_LITERALS = [
537
680
  "ceal.gateway_authorization_snapshot.v1",
538
681
  "ceal.gateway_cache_origin.v1",
539
682
  "ceal.gateway_call_result.v1",
540
- "ceal.gateway_command_resolution.v1",
683
+ CEAL_GATEWAY_COMMAND_RESOLUTION_SCHEMA_VERSION,
541
684
  "ceal.gateway_connector_route_failure.v1",
542
685
  "ceal.gateway_discovery.v3",
543
686
  "ceal.gateway_handshake.v1",
@@ -572,7 +715,7 @@ var CEAL_SCHEMA_LITERALS = [
572
715
  "ceal.operation_receipt.v1",
573
716
  "ceal.operation_result.v1",
574
717
  "ceal.operation_result.compact.v1",
575
- "ceal.local_result_materialization.v1",
718
+ "ceal.local_result_materialization.v2",
576
719
  "ceal.local_result_root.v1",
577
720
  "ceal.owner_bootstrap_exchange_request.v1",
578
721
  "ceal.owner_bootstrap_exchange_result.v1",
@@ -582,7 +725,8 @@ var CEAL_SCHEMA_LITERALS = [
582
725
  "ceal.request_cancellation.v1",
583
726
  "ceal.request_graph_revision.v1",
584
727
  "ceal.request_occurrence_correlation.v1",
585
- "ceal.request_projection.v1"
728
+ "ceal.request_projection.v1",
729
+ "ceal.write_safety_finding.v1"
586
730
  ];
587
731
  var CEAL_SCHEMA_LITERAL_SET = new Set(CEAL_SCHEMA_LITERALS);
588
732
 
@@ -597,21 +741,14 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
597
741
  thread_run_events: (root) => join(root, "run-events.jsonl"),
598
742
  bounded_store_sidecar: (root) => `${root}.jsonl`,
599
743
  gateway_audit_archive: (root) => `${root}.jsonl`,
600
- gateway_capability_audit: (root) => join(root, "capability-audit.jsonl"),
601
- gateway_retrieval_waste_partition: (root) => `${root}.jsonl`,
602
- gateway_access_policy_publication: (root) => join(root, "access-policy-publications.jsonl"),
603
744
  gateway_access_group_connector_control_audit: (root) => `${root}.audit.jsonl`,
604
745
  gateway_access_group_connector_scope_audit: (root) => join(root, "profile-connector-scope-audit.jsonl"),
605
746
  gateway_access_group_connector_activity_scope_audit: (root) => join(root, "profile-connector-activity-scope-audit.jsonl"),
747
+ gateway_access_group_connector_calendar_scope_audit: (root) => join(root, "profile-connector-calendar-scope-audit.jsonl"),
606
748
  gateway_access_group_connector_readiness_audit: (root) => join(root, "profile-connector-readiness.audit.jsonl"),
607
749
  gateway_organization_audit_ledger: (root) => join(root, "organization-ledger.jsonl"),
608
750
  gateway_personal_client_audit: (root) => join(root, "audit.jsonl"),
609
- gateway_personal_client_access_audit: (root) => join(root, "access-audit.jsonl"),
610
- gateway_admin_enrollment: (root) => join(root, "enrollments.jsonl"),
611
- gateway_admin_login: (root) => join(root, "logins.jsonl"),
612
- gateway_admin_family: (root) => join(root, "families.jsonl"),
613
- gateway_admin_refresh_token: (root) => join(root, "refresh-tokens.jsonl"),
614
- gateway_admin_access_token: (root) => join(root, "access-tokens.jsonl")
751
+ gateway_personal_client_access_audit: (root) => join(root, "access-audit.jsonl")
615
752
  });
616
753
 
617
754
  // packages/ceal-client-protocol/src/gateway-installation-activation.ts
@@ -619,8 +756,20 @@ var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS = 32;
619
756
  var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS = 8;
620
757
  var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_COMPACT_CHARACTERS = CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS + CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS;
621
758
 
759
+ // packages/ceal-client-protocol/src/gateway-entrypoint-commands.ts
760
+ var GATEWAY_ENTRYPOINT_COMMANDS = Object.freeze([
761
+ Object.freeze({ id: "controlPlane", path: Object.freeze(["control-plane"]) }),
762
+ Object.freeze({ id: "originShow", path: Object.freeze(["origin", "show"]) }),
763
+ Object.freeze({ id: "credentialsImport", path: Object.freeze(["credentials", "import"]) }),
764
+ Object.freeze({ id: "initialize", path: Object.freeze(["init"]) })
765
+ ]);
766
+
622
767
  // packages/ceal-client-protocol/src/host-registration.ts
623
768
  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"]);
769
+ 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}";
770
+ var CEAL_HOST_REGISTRATION_ATTEMPT_REF_PATTERN = new RegExp(`^host-registration-attempt:${CEAL_LOWERCASE_UUID_PATTERN}$`, "u");
771
+ var CEAL_HOST_INSTALLATION_REF_PATTERN = new RegExp(`^host-installation:${CEAL_LOWERCASE_UUID_PATTERN}$`, "u");
772
+ var CEAL_HOST_SOURCE_REF_PATTERN = new RegExp(`^host-source:${CEAL_LOWERCASE_UUID_PATTERN}$`, "u");
624
773
 
625
774
  // packages/ceal-client-protocol/src/agent-session-handoff.ts
626
775
  var CEAL_AGENT_ADMISSION_PHASES = vocabulary([
@@ -652,12 +801,19 @@ var CEAL_AGENT_SERVICE_SESSION_RECORD_KEYS = vocabulary([
652
801
  var CEAL_AGENT_SESSION_COMMIT_KEYS = vocabulary(["attempt_ref", "expected_session_revision", "session_revision"]);
653
802
 
654
803
  // packages/ceal-client-protocol/src/operation-next-actions.ts
804
+ var CEAL_REPEAT_REQUEST_NEXT_ACTION = "repeat_request";
805
+ var CEAL_INSPECT_RECEIPT_NEXT_ACTION = "inspect_receipt";
655
806
  var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
656
807
  "select_did_you_mean",
657
808
  "choose_new_output_path",
658
809
  "choose_new_idempotency_key",
659
810
  "restart_search",
660
811
  "repeat_original_arguments",
812
+ // The occurrence this call addressed is settled and cannot move again -- a
813
+ // denied effect approval, an expired continuation -- so the caller runs the
814
+ // same call again as a new request. The refusal names the re-request; this
815
+ // word is the re-request.
816
+ CEAL_REPEAT_REQUEST_NEXT_ACTION,
661
817
  "choose_new_request_identity",
662
818
  // A refusal that names the argument (invalid_argument with `property`) tells the caller exactly what to change.
663
819
  "correct_argument",
@@ -676,10 +832,35 @@ var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
676
832
  "use_original_input",
677
833
  // The same mismatch on the Request binding rather than the input: the
678
834
  // occurrence was admitted under one binding and the replay presents another.
679
- "use_original_request_binding"
835
+ "use_original_request_binding",
836
+ // The client's own filesystem write was refused -- EACCES, EPERM, or a
837
+ // read-only mount -- which is how an agent sandbox fences writes outside its
838
+ // workspace. The caller reruns the same command with unsandboxed or escalated
839
+ // execution; re-adopting the session cannot help, because the sandbox refuses
840
+ // that write too.
841
+ "rerun_outside_agent_sandbox",
842
+ // The refusal names the one Operation to read next in `describe_command`:
843
+ // an absent Operation id with a sole catalog-ranked candidate, or a known
844
+ // Operation invoked without its input. Describing only reads the verified
845
+ // contract and dispatches nothing, and the caller then retries with the
846
+ // named Operation or input, so it is guidance the scorer counts.
847
+ "describe_operation",
848
+ // The refusal names the caller's own personal connect Operation in
849
+ // `required_action_sequence`: the Operation asked for, or the credential
850
+ // the call ran on, needs a personal connection the caller does not hold
851
+ // (never connected, revoked, or expired). The caller runs that exact
852
+ // Operation, completes the consent it hands back, and retries the same call.
853
+ "connect_personal_account",
854
+ // The provider or Gateway named a bounded wait; the caller waits that long
855
+ // and submits the same read again.
856
+ "retry_after"
680
857
  ];
681
858
  var CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS = Object.freeze(CALLER_RECOVERABLE_NEXT_ACTION_VALUES);
682
859
  var NON_REMEDY_NEXT_ACTION_VALUES = [
860
+ // Only an administrator can take the named step -- approving a place for an
861
+ // Operation, granting a withheld capability -- so a non-administrator asks
862
+ // one. The refusal names the administrator step; this word is the ask.
863
+ "ask_admin",
683
864
  "await_pending_approval",
684
865
  "check_gateway",
685
866
  "inspect_context_store",
@@ -694,9 +875,13 @@ var NON_REMEDY_NEXT_ACTION_VALUES = [
694
875
  "inspect_local_command",
695
876
  "inspect_local_output",
696
877
  "inspect_local_route",
697
- "inspect_receipt",
878
+ CEAL_INSPECT_RECEIPT_NEXT_ACTION,
698
879
  "inspect_request",
699
880
  "none",
881
+ // The provider refused because of its own configuration -- an API not
882
+ // enabled, an app scope missing -- which an operator changes in that
883
+ // provider's console. No caller edit and no retry fixes it.
884
+ "operator_action",
700
885
  "recover",
701
886
  "reconcile",
702
887
  // Reconciliation of one named occurrence, not of the deployment: a legacy
@@ -704,6 +889,10 @@ var NON_REMEDY_NEXT_ACTION_VALUES = [
704
889
  // no edit to the call changes that. `reconcile` is the deployment-wide word.
705
890
  "reconcile_occurrence",
706
891
  "reduce_request_size",
892
+ // The Host's invocation context for this turn is stale or expired at the
893
+ // Gateway. The Host's next turn rebinds it and the same call then succeeds;
894
+ // nothing in the call changes, so it is not a remedy the scorer may count.
895
+ "refresh_host_invocation_context",
707
896
  "repair_or_adopt_session",
708
897
  "retry",
709
898
  // The owner -- a correlation hook, an approval hook -- is not serving right
@@ -717,10 +906,23 @@ var NON_REMEDY_NEXT_ACTION_VALUES = [
717
906
  var CEAL_NON_REMEDY_NEXT_ACTIONS = Object.freeze(NON_REMEDY_NEXT_ACTION_VALUES);
718
907
  var DECLARED = /* @__PURE__ */ new Set([...CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS, ...CEAL_NON_REMEDY_NEXT_ACTIONS]);
719
908
  var RECOVERABLE = new Set(CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS);
909
+ var CEAL_OPERATION_WITHHELD_NEXT_ACTIONS = Object.freeze({
910
+ provider_permission: "ask_admin",
911
+ access_level: "ask_admin",
912
+ personal_authorization_required: "connect_personal_account"
913
+ });
720
914
 
721
915
  // packages/ceal-client-protocol/src/operation-contract-artifact.ts
722
916
  var CATALOG_REVISION = new RegExp(CEAL_VERIFIED_ARTIFACT_CATALOG_REVISION_PATTERN, "u");
723
917
  var SHA256 = new RegExp(CEAL_VERIFIED_ARTIFACT_DIGEST_PATTERN, "u");
918
+ var CEAL_OPERATION_INVOKE_COMMAND = "invoke";
919
+ var CEAL_OPERATION_INPUT_FLAG = "--input";
920
+ var CEAL_OPERATION_ID_PLACEHOLDER = "<operation-id>";
921
+ var CEAL_OPERATION_INPUT_PLACEHOLDER = "<json-object>";
922
+ var CEAL_MODEL_INVOCATION_ARGUMENTS = [CEAL_OPERATION_INVOKE_COMMAND, CEAL_OPERATION_ID_PLACEHOLDER, CEAL_OPERATION_INPUT_FLAG, shellSingleQuoted(CEAL_OPERATION_INPUT_PLACEHOLDER)].join(" ");
923
+ function shellSingleQuoted(value) {
924
+ return `'${value.replaceAll("'", "'\\''")}'`;
925
+ }
724
926
  var CEAL_OPERATION_CONTRACT_REQUIRED_FIELDS = Object.freeze(["input_schema", "result_schema"]);
725
927
  var CEAL_OPERATION_CONTRACT_OPTIONAL_FIELDS = Object.freeze(["summary", "input_resolution"]);
726
928
  var CEAL_VERIFIED_ARTIFACT_DESCRIPTOR_JSON_SCHEMA = Object.freeze({
@@ -749,9 +951,178 @@ var CEAL_VERIFIED_ARTIFACT_DESCRIPTOR_JSON_SCHEMA = Object.freeze({
749
951
  }
750
952
  });
751
953
 
954
+ // packages/ceal-client-protocol/src/bare-document.ts
955
+ var REQUIRED_FIELDS = CEAL_CLIENT_WIRE_CONTRACT.command_response.bare_document_fields;
956
+ var OPTIONAL_FIELDS = CEAL_CLIENT_WIRE_CONTRACT.command_response.bare_document_optional_fields;
957
+
958
+ // packages/ceal-client-protocol/src/leased-consumer-vocabulary.ts
959
+ var CEAL_TERMINAL_DISPOSITIONS = vocabulary(["completed", "failed", "cancelled"]);
960
+ var CEAL_LEASE_DISPOSITIONS = vocabulary([...CEAL_TERMINAL_DISPOSITIONS, "deferred"]);
961
+ var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["initial"]);
962
+ var CEAL_LEASED_MESSAGE_DELIVERY_OPERATION_IDS = vocabulary(["message.send", "message.update", "message.delete"]);
963
+ var CEAL_REPOSITORY_VISIBILITIES = vocabulary(["public", "private", "internal"]);
964
+ var CEAL_RESULT_DELIVERY_OFFERS = vocabulary(["pending", "offered", "transport_lost"]);
965
+ var CEAL_RESULT_DELIVERY_STATES = vocabulary(["unavailable", ...CEAL_RESULT_DELIVERY_OFFERS]);
966
+ var CEAL_PROVIDER_OUTCOMES = vocabulary(["not_attempted", "outcome_unknown", "verified"]);
967
+ var CEAL_ACTIVITY_GAP_CODES = vocabulary([
968
+ "provider_page_budget",
969
+ "call_deadline",
970
+ "related_item_budget",
971
+ "provider_cursor_unavailable",
972
+ "malformed_provider_page",
973
+ "visibility_incomplete",
974
+ "unsupported_event_kind"
975
+ ]);
976
+ var CEAL_ACTIVITY_CONNECTOR_KINDS = vocabulary(["slack", "github", "google-calendar", "google-drive", "notion"]);
977
+ var CEAL_ACTIVITY_COVERAGE_STATUSES = vocabulary(["complete_for_target", "continuation_required", "blocked"]);
978
+ var CEAL_ACTIVITY_EVENT_KINDS = vocabulary([
979
+ "slack.message",
980
+ "slack.reply",
981
+ "slack.direct_message",
982
+ "github.commit.authored",
983
+ "github.issue.opened",
984
+ "github.pull_request.opened",
985
+ "github.review.submitted",
986
+ "github.issue_comment.created",
987
+ "github.review_comment.created",
988
+ "calendar.organized",
989
+ "calendar.accepted_invite",
990
+ "calendar.recorded",
991
+ "drive.file.created",
992
+ "drive.file.modified",
993
+ "drive.file.viewed",
994
+ "notion.page.created",
995
+ "notion.page.edited"
996
+ ]);
997
+ var CEAL_ACTIVITY_TIMESTAMP_BASES = vocabulary([
998
+ "message_created",
999
+ "commit_authored",
1000
+ "resource_created",
1001
+ "review_submitted",
1002
+ "comment_created",
1003
+ "event_start",
1004
+ "all_day_start",
1005
+ "file_created",
1006
+ "file_modified",
1007
+ "file_modified_by_me",
1008
+ "file_viewed_by_me",
1009
+ "page_created",
1010
+ "page_last_edited",
1011
+ "resource_modified"
1012
+ ]);
1013
+ var CEAL_ACTIVITY_V3_KINDS = vocabulary(["authored", "edited", "messaged", "responded"]);
1014
+ var CEAL_RESOURCE_TIME_BASES = vocabulary(["created", "modified", "viewed"]);
1015
+ var CEAL_RESOURCE_SEARCH_ORDERS = vocabulary(["relevance", "modified", "viewed", "created"]);
1016
+ var CEAL_RESOURCE_SEARCH_DIRECTIONS = vocabulary(["ascending", "descending"]);
1017
+ var CEAL_RESOURCE_SEARCH_FILTERS = vocabulary(["query", "modified_since", "kinds", "container_ref", "addressed_to_me", "unread"]);
1018
+ var CEAL_ARTIFACT_STAGE_TERMINALS = vocabulary(["chunk_accepted", "artifact_ready", "idempotency_replayed"]);
1019
+ var CEAL_READ_ITEM_KINDS = vocabulary(["conversation", "identity", "usergroup", "message", "file", "document"]);
1020
+ var CEAL_LEASED_MESSAGE_SEARCH_COMPLETENESS = vocabulary(["complete", "continuation_available", "truncated"]);
1021
+ var CEAL_OPAQUE_HANDLE_KINDS = vocabulary(["target", "message", "thread", "artifact", "document", "object"]);
1022
+ var CEAL_WRITE_OBJECT_KINDS = vocabulary(["document", "comment", "cell_range"]);
1023
+ var CEAL_CONVERSATION_KINDS = vocabulary(["channel", "dm", "group"]);
1024
+ var CEAL_FILE_TYPE_FAMILIES = vocabulary(["all", "image", "pdf"]);
1025
+ var CEAL_GITHUB_ISSUE_STATES = vocabulary(["open", "closed", "all"]);
1026
+ var CEAL_NOTION_UPDATABLE_BLOCK_TYPES = vocabulary([
1027
+ "paragraph",
1028
+ "heading_1",
1029
+ "heading_2",
1030
+ "heading_3",
1031
+ "bulleted_list_item",
1032
+ "numbered_list_item",
1033
+ "to_do",
1034
+ "code"
1035
+ ]);
1036
+ var CEAL_NOTION_NEUTRAL_TYPES = vocabulary([
1037
+ "text",
1038
+ "number",
1039
+ "boolean",
1040
+ "date",
1041
+ "select",
1042
+ "multi_select",
1043
+ "people",
1044
+ "url",
1045
+ "email",
1046
+ "phone",
1047
+ "unsupported"
1048
+ ]);
1049
+ var CEAL_NOTION_IDENTITY_GAP_REASONS = vocabulary([
1050
+ "identity_unavailable",
1051
+ "identity_stale",
1052
+ "identity_ambiguous",
1053
+ "identity_revoked",
1054
+ "identity_unlinked"
1055
+ ]);
1056
+ var CEAL_NOTION_STRING_VALUE_TYPES = vocabulary(["text", "select", "url", "email", "phone"]);
1057
+ var CEAL_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "permission_denied"]);
1058
+ var CEAL_PLAN_ITEM_STATUSES = vocabulary(["pending", "active", "completed"]);
1059
+ var CEAL_FINAL_PRESENTATION_INTENTS = vocabulary(["final", "stop", "transient_notice"]);
1060
+ var CEAL_PRESENTATION_INTENTS = vocabulary(["progress", ...CEAL_FINAL_PRESENTATION_INTENTS]);
1061
+
1062
+ // packages/ceal-client-protocol/src/resource-row.ts
1063
+ var RESOURCE_ROW_KEY_RULES = Object.freeze({
1064
+ schema_version: { required: true, timestamp: false },
1065
+ ref: { required: true, timestamp: false },
1066
+ next: { required: true, timestamp: false },
1067
+ kind: { required: true, timestamp: false },
1068
+ title: { required: true, timestamp: false },
1069
+ container_label: { required: true, timestamp: false },
1070
+ container_ref: { required: false, timestamp: false },
1071
+ source: { required: true, timestamp: false },
1072
+ owner: { required: false, timestamp: false },
1073
+ counterparts: { required: false, timestamp: false },
1074
+ created_at: { required: false, timestamp: true },
1075
+ created_at_local: { required: false, timestamp: true },
1076
+ modified_at: { required: false, timestamp: true },
1077
+ modified_at_local: { required: false, timestamp: true },
1078
+ viewed_by_me_at: { required: false, timestamp: true },
1079
+ visibility: { required: false, timestamp: false },
1080
+ start: { required: false, timestamp: false },
1081
+ end: { required: false, timestamp: false },
1082
+ status: { required: false, timestamp: false },
1083
+ snippet: { required: false, timestamp: false },
1084
+ state: { required: true, timestamp: false },
1085
+ timestamp_basis: { required: true, timestamp: false }
1086
+ });
1087
+ var RESOURCE_ROW_REQUIRED_KEYS = Object.entries(RESOURCE_ROW_KEY_RULES).flatMap(([key, rule]) => rule.required ? [key] : []);
1088
+ var RESOURCE_ROW_KEYS = new Set(Object.keys(RESOURCE_ROW_KEY_RULES));
1089
+ var RESOURCE_ROW_TIMESTAMP_KEYS = Object.entries(RESOURCE_ROW_KEY_RULES).flatMap(([key, rule]) => rule.timestamp ? [key] : []);
1090
+
1091
+ // packages/ceal-client-protocol/src/resource-read-result.ts
1092
+ var CEAL_RESOURCE_GET_COVERAGE_NEXT_ACTIONS = vocabulary(["reduce_request_size", "read_resource_again"]);
1093
+
1094
+ // packages/ceal-client-protocol/src/excluded-target-coverage-contract.ts
1095
+ var CEAL_EXCLUDED_TARGET_REASONS = vocabulary(["audience_narrower_than_place", "visibility_unknown"]);
1096
+
1097
+ // packages/ceal-client-protocol/src/excluded-target-coverage.ts
1098
+ var CEAL_EXCLUDED_TARGET_COVERAGE_MAX_ENTRIES = 64;
1099
+ function cealExcludedTargetCoverageJsonSchema() {
1100
+ const target = {
1101
+ target_ref: { type: "string", minLength: 8, maxLength: 134, pattern: "^target:[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$" },
1102
+ connector_kind: { type: "string", minLength: 1, maxLength: 64, pattern: "^[a-z][a-z0-9-]{0,63}$" },
1103
+ label: { type: "string", minLength: 1, maxLength: CEAL_PUBLIC_DISPLAY_NAME_MAX_BYTES },
1104
+ reason: { type: "string", enum: [...CEAL_EXCLUDED_TARGET_REASONS] }
1105
+ };
1106
+ return {
1107
+ type: "array",
1108
+ minItems: 1,
1109
+ maxItems: CEAL_EXCLUDED_TARGET_COVERAGE_MAX_ENTRIES,
1110
+ items: { type: "object", additionalProperties: false, maxProperties: 4, properties: target, required: ["target_ref", "reason"] }
1111
+ };
1112
+ }
1113
+
1114
+ // packages/ceal-client-protocol/src/write-safety-finding.ts
1115
+ var CEAL_WRITE_SAFETY_FINDING_STATUSES = vocabulary(["warning", "unchecked"]);
1116
+ var CEAL_WRITE_SAFETY_AUDIENCES = vocabulary(["workspace", "person", "members", "unknown"]);
1117
+ var CEAL_WRITE_SAFETY_REFERENCE_REASONS = vocabulary(["not_published_to_audience", "audience_access_unknown"]);
1118
+ var CEAL_WRITE_SAFETY_UNCHECKED_REASONS = vocabulary(["authority_unavailable"]);
1119
+
752
1120
  // packages/ceal-client-protocol/src/operation-occurrence.ts
753
1121
  var MAX_RECEIPT_REVISION = Number.MAX_SAFE_INTEGER - 1;
754
1122
 
1123
+ // packages/ceal-client-protocol/src/leased-artifact-contract.ts
1124
+ var CEAL_LEASED_CONSUMER_ARTIFACT_CHUNK_MAX_BYTES = 12 * 1024;
1125
+
755
1126
  // packages/ceal-client-protocol/src/leased-resource-stream.ts
756
1127
  var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_MAGIC = new Uint8Array([67, 69, 65, 76, 82, 83, 50, 0]);
757
1128
  var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_RECORD_PREFIX_BYTES = 8;
@@ -763,6 +1134,7 @@ var CEAL_ATTACHMENT_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_
763
1134
  // packages/ceal-client-protocol/src/request-validation-primitives.ts
764
1135
  import { createHash } from "node:crypto";
765
1136
  var DIGEST = /^[a-f0-9]{64}$/u;
1137
+ var CEAL_SHA256_DIGEST_PATTERN = DIGEST.source;
766
1138
  function isCealDigest(value) {
767
1139
  return typeof value === "string" && DIGEST.test(value);
768
1140
  }
@@ -789,7 +1161,7 @@ var CANCELLATION_STATES = vocabulary(["requested", "cancelled"]);
789
1161
  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"]);
790
1162
  var CEAL_REQUEST_JSON_SCHEMA = {
791
1163
  type: "object",
792
- maxProperties: 9,
1164
+ maxProperties: 10,
793
1165
  additionalProperties: false,
794
1166
  properties: {
795
1167
  schema_version: { type: "string", const: CEAL_REQUEST_SCHEMA_VERSION, maxLength: 32 },
@@ -812,7 +1184,8 @@ var CEAL_REQUEST_JSON_SCHEMA = {
812
1184
  host_session_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
813
1185
  host_turn_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
814
1186
  host_input_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
815
- host_source_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source }
1187
+ host_source_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
1188
+ requester_timezone: { type: "string", minLength: 1, maxLength: 128, description: "IANA timezone observed for the requester on this Request." }
816
1189
  },
817
1190
  required: CEAL_REQUEST_KEYS
818
1191
  };
@@ -862,21 +1235,26 @@ var REQUEST_NODE_STANDING_OCCURRENCE_SCHEMA = {
862
1235
  },
863
1236
  required: ["schema_version", "node_ref", "operation_id", "correlation_ref", "occurrence_ref", "graph_revision", "graph_revision_digest", "admitted_input_sha256", "reason"]
864
1237
  };
1238
+ var REQUEST_EXECUTION_PREPARE_REFUSAL_PROPERTIES = {
1239
+ schema_version: { type: "string", const: CEAL_OPERATION_ERROR_SCHEMA_VERSION, maxLength: 64 },
1240
+ code: REQUEST_ACTION_SAFE_REF_SCHEMA,
1241
+ message: { type: "string", minLength: 1, maxLength: 2048 },
1242
+ property: { type: "string", minLength: 1, maxLength: 256 },
1243
+ next_action: REQUEST_ACTION_SAFE_REF_SCHEMA,
1244
+ retryable: { type: "boolean" },
1245
+ source: { type: "string", enum: ["provider", "gateway"] },
1246
+ retry_after_ms: { type: "integer", minimum: 0, maximum: CEAL_RETRY_AFTER_MAX_MS },
1247
+ excluded_targets: cealExcludedTargetCoverageJsonSchema(),
1248
+ repaired_input: {},
1249
+ unrepaired_pointers: { type: "array", maxItems: 128, items: { type: "string", minLength: 1, maxLength: 256 } },
1250
+ provider_handoff: { type: "string", const: "not_offered", maxLength: 32 },
1251
+ cause: { type: "string", enum: [...CEAL_OPERATION_WITHHELD_CAUSES] }
1252
+ };
865
1253
  var REQUEST_EXECUTION_PREPARE_REFUSAL_SCHEMA = {
866
1254
  type: "object",
867
1255
  additionalProperties: false,
868
- maxProperties: 9,
869
- properties: {
870
- schema_version: { type: "string", const: CEAL_OPERATION_ERROR_SCHEMA_VERSION, maxLength: 64 },
871
- code: REQUEST_ACTION_SAFE_REF_SCHEMA,
872
- message: { type: "string", minLength: 1, maxLength: 2048 },
873
- property: { type: "string", minLength: 1, maxLength: 256 },
874
- next_action: REQUEST_ACTION_SAFE_REF_SCHEMA,
875
- retryable: { type: "boolean" },
876
- repaired_input: {},
877
- unrepaired_pointers: { type: "array", maxItems: 128, items: { type: "string", minLength: 1, maxLength: 256 } },
878
- provider_handoff: { type: "string", const: "not_offered", maxLength: 32 }
879
- },
1256
+ maxProperties: Object.keys(REQUEST_EXECUTION_PREPARE_REFUSAL_PROPERTIES).length,
1257
+ properties: REQUEST_EXECUTION_PREPARE_REFUSAL_PROPERTIES,
880
1258
  required: ["schema_version", "code", "message", "next_action", "retryable"]
881
1259
  };
882
1260
  var CEAL_REQUEST_EXECUTION_ORDERS = vocabulary(["graph_dependency", "caller"]);
@@ -1063,16 +1441,14 @@ var CEAL_REQUEST_GRAPH_NODE_PREPARE_READINESS_JSON_SCHEMA = {
1063
1441
  };
1064
1442
 
1065
1443
  // packages/ceal-client-protocol/src/client-result-materialization.ts
1066
- var REQUIRED_FIELDS = Object.freeze(["schema_version", "operation_id", "local_path", "content_json_pointer", "size_bytes", "sha256", "read_argv"]);
1067
- var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS, "local_result_root", "model_disclosure"]);
1444
+ var CEAL_MODEL_VISIBLE_COMMAND_OUTPUT_MAX_BYTES = 32 * 1024;
1445
+ var REQUIRED_FIELDS2 = Object.freeze(["schema_version", "operation_id", "read_argv"]);
1446
+ var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "local_result_root"]);
1068
1447
 
1069
1448
  // packages/ceal-client-protocol/src/session-start-affordance.ts
1070
1449
  var CEAL_SESSION_ENTRY_INVOCATION = "ceal";
1071
1450
  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.`;
1072
1451
 
1073
- // packages/ceal-client-protocol/src/discovery-manifest.ts
1074
- var CEAL_DISCOVERY_MANIFEST_CONNECTOR_KINDS = vocabulary(["github", "google-workspace", "notion", "slack"]);
1075
-
1076
1452
  // packages/ceal-client-protocol/src/conversation-contracts.ts
1077
1453
  var CEAL_APPROVAL_POLICY_KINDS = vocabulary(["requester_only", "named_users", "role_based"]);
1078
1454
  var CEAL_APPROVAL_TARGET_KINDS = vocabulary([
@@ -1115,38 +1491,18 @@ var CEAL_GATEWAY_ANNOUNCEMENT_POLICY_NON_CLAIMS = vocabulary([
1115
1491
 
1116
1492
  // packages/ceal-client-protocol/src/gateway-discovery-response-validation.ts
1117
1493
  var ANNOUNCEMENT_POLICY_CAPABILITY_BINDINGS = Object.freeze({
1118
- "github.repository.get": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1119
- "collection.search": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1120
- "github.issue.get": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1121
- "github.pull_request.get": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1494
+ "repository.get": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1495
+ "resource.search": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1122
1496
  "github.workflow_run.get": [{ effect: "read", scopeStatementKind: "github_app_installation_repositories", providerAuthorityKind: "github_app" }],
1123
1497
  "message.search": [{ effect: "read", scopeStatementKind: "slack_public_app_member_channels_only", providerAuthorityKind: "slack_app" }],
1124
- "message.get": [{ effect: "read", scopeStatementKind: "slack_public_app_member_channels_only", providerAuthorityKind: "slack_app" }],
1125
- "resource.resolve": [
1126
- { effect: "read", scopeStatementKind: "slack_public_app_member_channels_only", providerAuthorityKind: "slack_app" },
1127
- { effect: "read", scopeStatementKind: "notion_connected_logical_area", providerAuthorityKind: "notion_integration" }
1128
- ],
1129
- "conversation.thread.get": [{ effect: "read", scopeStatementKind: "slack_public_app_member_channels_only", providerAuthorityKind: "slack_app" }],
1130
1498
  "notion.search": [{ effect: "read", scopeStatementKind: "notion_connected_logical_area", providerAuthorityKind: "notion_integration" }],
1131
- "notion.page.get": [{ effect: "read", scopeStatementKind: "notion_connected_logical_area", providerAuthorityKind: "notion_integration" }],
1132
- "calendar.availability": [{ effect: "read", scopeStatementKind: "google_workspace_calendar_read_only", providerAuthorityKind: "google_service_account" }],
1133
- "calendar.event.search": [{ effect: "read", scopeStatementKind: "google_workspace_calendar_read_only", providerAuthorityKind: "google_service_account" }],
1134
- "calendar.event.get": [{ effect: "read", scopeStatementKind: "google_workspace_calendar_read_only", providerAuthorityKind: "google_service_account" }],
1135
- "file.search": [{ effect: "read", scopeStatementKind: "google_workspace_ceal_drive_or_direct_share_metadata", providerAuthorityKind: "google_service_account" }],
1136
- "sheets.values.read": [{ effect: "read", scopeStatementKind: "google_workspace_ceal_drive_or_direct_share_sheet_ranges", providerAuthorityKind: "google_service_account" }],
1137
- "sheets.tabs.list": [{ effect: "read", scopeStatementKind: "google_workspace_ceal_drive_or_direct_share_sheet_tabs", providerAuthorityKind: "google_service_account" }],
1138
- "sheets.values.update": [{ effect: "write", scopeStatementKind: "google_workspace_ceal_drive_or_direct_share_editable_sheet_ranges", providerAuthorityKind: "google_service_account" }],
1139
- "sheets.values.clear": [{ effect: "write", scopeStatementKind: "google_workspace_ceal_drive_or_direct_share_editable_sheet_clear_ranges", providerAuthorityKind: "google_service_account" }]
1140
- });
1141
- var ANNOUNCEMENT_SCOPE_STATEMENTS = Object.freeze({
1142
- github_app_installation_repositories: "Repositories in the installed GitHub App installation.",
1143
- 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.",
1144
- notion_connected_logical_area: "Connected Notion logical area under provider-enforced sharing; descendant inventory is not declared.",
1145
- google_workspace_calendar_read_only: "Approved Calendar availability and event reads only; Calendar mutation is not declared.",
1146
- 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.",
1147
- 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.",
1148
- 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.",
1149
- 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."
1499
+ "resource.get": [{ effect: "read", scopeStatementKind: "notion_connected_logical_area", providerAuthorityKind: "notion_integration" }],
1500
+ "availability.get": [{ effect: "read", scopeStatementKind: "google_workspace_calendar_read_only", providerAuthorityKind: "google_service_account" }],
1501
+ "event.search": [{ effect: "read", scopeStatementKind: "google_workspace_calendar_read_only", providerAuthorityKind: "google_service_account" }],
1502
+ "file.search": [{ effect: "read", scopeStatementKind: "google_workspace_admitted_drive_target_metadata", providerAuthorityKind: "google_service_account" }],
1503
+ "cell_range.get": [{ effect: "read", scopeStatementKind: "google_workspace_admitted_drive_target_sheet_ranges", providerAuthorityKind: "google_service_account" }],
1504
+ "sheet.list": [{ effect: "read", scopeStatementKind: "google_workspace_admitted_drive_target_sheet_tabs", providerAuthorityKind: "google_service_account" }],
1505
+ "cell_range.update": [{ effect: "write", scopeStatementKind: "google_workspace_admitted_drive_target_editable_sheet_ranges", providerAuthorityKind: "google_service_account" }]
1150
1506
  });
1151
1507
 
1152
1508
  // packages/ceal-client-protocol/src/gateway-write-identity.ts
@@ -1203,90 +1559,6 @@ var ADMIN_LINEAGE_NODE_KINDS = vocabulary(["source_read", "synthesis_preview", "
1203
1559
  // packages/ceal-client-protocol/src/actor-kind.ts
1204
1560
  var CEAL_ACTOR_KINDS = vocabulary(["human", "bot", "app", "unknown"]);
1205
1561
 
1206
- // packages/ceal-client-protocol/src/leased-consumer-vocabulary.ts
1207
- var CEAL_TERMINAL_DISPOSITIONS = vocabulary(["completed", "failed", "cancelled"]);
1208
- var CEAL_LEASE_DISPOSITIONS = vocabulary([...CEAL_TERMINAL_DISPOSITIONS, "deferred"]);
1209
- var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["initial"]);
1210
- var CEAL_LEASED_MESSAGE_DELIVERY_CAPABILITY_IDS = vocabulary(["message.create", "message.update", "message.delete"]);
1211
- var CEAL_REPOSITORY_VISIBILITIES = vocabulary(["public", "private", "internal"]);
1212
- var CEAL_RESULT_DELIVERY_OFFERS = vocabulary(["pending", "offered", "transport_lost"]);
1213
- var CEAL_RESULT_DELIVERY_STATES = vocabulary(["unavailable", ...CEAL_RESULT_DELIVERY_OFFERS]);
1214
- var CEAL_PROVIDER_OUTCOMES = vocabulary(["not_attempted", "outcome_unknown", "verified"]);
1215
- var CEAL_ACTIVITY_GAP_CODES = vocabulary([
1216
- "provider_page_budget",
1217
- "related_item_budget",
1218
- "provider_cursor_unavailable",
1219
- "malformed_provider_page",
1220
- "visibility_incomplete",
1221
- "unsupported_event_kind"
1222
- ]);
1223
- var CEAL_ACTIVITY_COVERAGE_STATUSES = vocabulary(["complete_for_target", "continuation_required", "blocked"]);
1224
- var CEAL_ACTIVITY_EVENT_KINDS = vocabulary([
1225
- "slack.message",
1226
- "slack.reply",
1227
- "github.commit.authored",
1228
- "github.issue.opened",
1229
- "github.pull_request.opened",
1230
- "github.review.submitted",
1231
- "github.issue_comment.created",
1232
- "github.review_comment.created",
1233
- "calendar.organized",
1234
- "calendar.accepted_invite",
1235
- "calendar.recorded"
1236
- ]);
1237
- var CEAL_ACTIVITY_TIMESTAMP_BASES = vocabulary([
1238
- "message_created",
1239
- "commit_authored",
1240
- "resource_created",
1241
- "review_submitted",
1242
- "comment_created",
1243
- "event_start",
1244
- "all_day_start"
1245
- ]);
1246
- var CEAL_ARTIFACT_STAGE_TERMINALS = vocabulary(["chunk_accepted", "artifact_ready", "idempotency_replayed"]);
1247
- var CEAL_READ_ITEM_KINDS = vocabulary(["conversation", "identity", "usergroup", "message", "file", "document"]);
1248
- var CEAL_RESOURCE_RESOLVE_KINDS = vocabulary(["conversation", "identity", "usergroup", "permalink"]);
1249
- var CEAL_OPAQUE_HANDLE_KINDS = vocabulary(["target", "message", "thread", "artifact", "document", "object"]);
1250
- var CEAL_WRITE_OBJECT_KINDS = vocabulary(["document", "comment", "cell_range"]);
1251
- var CEAL_CONVERSATION_KINDS = vocabulary(["channel", "dm", "group"]);
1252
- var CEAL_FILE_TYPE_FAMILIES = vocabulary(["all", "image", "pdf"]);
1253
- var CEAL_GITHUB_ISSUE_STATES = vocabulary(["open", "closed", "all"]);
1254
- var CEAL_NOTION_UPDATABLE_BLOCK_TYPES = vocabulary([
1255
- "paragraph",
1256
- "heading_1",
1257
- "heading_2",
1258
- "heading_3",
1259
- "bulleted_list_item",
1260
- "numbered_list_item",
1261
- "to_do",
1262
- "code"
1263
- ]);
1264
- var CEAL_NOTION_NEUTRAL_TYPES = vocabulary([
1265
- "text",
1266
- "number",
1267
- "boolean",
1268
- "date",
1269
- "select",
1270
- "multi_select",
1271
- "people",
1272
- "url",
1273
- "email",
1274
- "phone",
1275
- "unsupported"
1276
- ]);
1277
- var CEAL_NOTION_IDENTITY_GAP_REASONS = vocabulary([
1278
- "identity_unavailable",
1279
- "identity_stale",
1280
- "identity_ambiguous",
1281
- "identity_revoked",
1282
- "identity_unlinked"
1283
- ]);
1284
- var CEAL_NOTION_STRING_VALUE_TYPES = vocabulary(["text", "select", "url", "email", "phone"]);
1285
- var CEAL_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "permission_denied"]);
1286
- var CEAL_PLAN_ITEM_STATUSES = vocabulary(["pending", "active", "completed"]);
1287
- var CEAL_FINAL_PRESENTATION_INTENTS = vocabulary(["final", "stop", "transient_notice"]);
1288
- var CEAL_PRESENTATION_INTENTS = vocabulary(["progress", ...CEAL_FINAL_PRESENTATION_INTENTS]);
1289
-
1290
1562
  // packages/ceal-client-protocol/src/personal-client-vocabulary.ts
1291
1563
  var CEAL_PERSONAL_CLIENT_BINDING_KEYS = vocabulary([
1292
1564
  "access_group_ref",
@@ -1309,7 +1581,7 @@ var CEAL_REFRESH_FAILURE_CODES = vocabulary([
1309
1581
  ]);
1310
1582
 
1311
1583
  // packages/ceal-client-protocol/src/device-enrollment.ts
1312
- var CEAL_DEVICE_ENROLLMENT_POLL_FAILURE_CODES = Object.freeze(["unsupported_feature", "recovery_required", "expired"]);
1584
+ var CEAL_DEVICE_ENROLLMENT_POLL_FAILURE_CODES = Object.freeze(["unsupported_feature", "recovery_required", "expired", "denied"]);
1313
1585
  var POLL_RESULT_KEYS = Object.freeze(["retry_after_ms", "schema_version", "status"]);
1314
1586
 
1315
1587
  // packages/ceal-client-protocol/src/personal-client-session.ts
@@ -1321,7 +1593,6 @@ var MAX_ARGUMENT_BYTES = 16 * 1024;
1321
1593
  var HANDSHAKE_IDENTITY_KEYS = Object.freeze(["membership_ref", "registration_ref", "client_ref", "subject_ref", "instance_ref"]);
1322
1594
  var AUDIT_IDENTITY_KEYS = Object.freeze(["event_ref", "membership_ref", "registration_ref", "client_ref", "subject_ref", "instance_ref"]);
1323
1595
  var FAILURE_RESPONSE_KEYS = Object.freeze(["error", "ok", "proof_ref_or_unavailable", "protocol_version", "request_id"]);
1324
- var MAX_RECOVERY_RETRY_AFTER_MS = 60 * 60 * 1e3;
1325
1596
 
1326
1597
  // host/claude/src/claude-decoder.ts
1327
1598
  var MAX_HOOK_BYTES = 256 * 1024;
@@ -1653,6 +1924,9 @@ function errorCode(error) {
1653
1924
  return typeof error === "object" && error !== null && "code" in error ? String(error.code) : null;
1654
1925
  }
1655
1926
 
1927
+ // host/relay/src/relay-request-binding-store.ts
1928
+ var MAX_STATE_BYTES = 8 * 1024 * 1024;
1929
+
1656
1930
  // host/relay/src/relay-quarantine-store.ts
1657
1931
  var RELAY_QUARANTINE_MAX_BYTES = 16 * 1024 * 1024;
1658
1932
 
@@ -1661,9 +1935,6 @@ var DEFAULT_LIMITS = { global_count: 8192, global_bytes: 64 * 1024 * 1024, produ
1661
1935
  var RETRY_SECONDS = [1, 2, 4, 8, 16, 32, 60];
1662
1936
  var MAX_RETRYABLE_ATTEMPTS = RETRY_SECONDS.length + 10;
1663
1937
 
1664
- // host/relay/src/relay-request-binding-store.ts
1665
- var MAX_STATE_BYTES = 8 * 1024 * 1024;
1666
-
1667
1938
  // host/relay/src/relay-ipc.ts
1668
1939
  import { createConnection, createServer } from "node:net";
1669
1940
 
@@ -1691,13 +1962,53 @@ var HOST_RELAY_CURRENT_PROMPT_REGISTER_SCHEMA = "ceal.host_relay_current_prompt_
1691
1962
  var HOST_RELAY_CURRENT_PROMPT_RESULT_SCHEMA = "ceal.host_relay_current_prompt_result.v1";
1692
1963
  var HOST_RELAY_IPC_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
1693
1964
  var HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES = 4096;
1965
+ var HOST_RELAY_INVOCATION_MINT_REFUSAL_REASONS = vocabulary([
1966
+ "context_stale",
1967
+ "context_expired",
1968
+ "host_source_refused",
1969
+ "host_credential_refused",
1970
+ "gateway_unavailable",
1971
+ "gateway_refused",
1972
+ "gateway_response_invalid",
1973
+ "deadline",
1974
+ "cancelled",
1975
+ "mint_failed",
1976
+ "relay_failed"
1977
+ ]);
1978
+ var HOST_RELAY_INVOCATION_MINT_OUTCOMES = vocabulary(["completed", "caller_cancelled", "deadline", "failed", "no_binding"]);
1979
+ var HOST_RELAY_EXCHANGE_FAILURES = vocabulary([
1980
+ "permission_denied",
1981
+ "socket_missing",
1982
+ "connection_refused",
1983
+ "closed_early",
1984
+ "response_invalid",
1985
+ "timed_out",
1986
+ "cancelled",
1987
+ "unavailable"
1988
+ ]);
1694
1989
  var HostRelayIpcError = class extends Error {
1695
1990
  code;
1696
- constructor(code3, message = code3) {
1991
+ /** Set only when the client-side socket exchange itself failed. */
1992
+ failure;
1993
+ constructor(code3, message = code3, failure) {
1697
1994
  super(message);
1698
1995
  this.code = code3;
1996
+ this.failure = failure;
1699
1997
  }
1700
1998
  };
1999
+ function socketErrorFailure(error) {
2000
+ switch (errorCode2(error)) {
2001
+ case "EACCES":
2002
+ case "EPERM":
2003
+ return "permission_denied";
2004
+ case "ENOENT":
2005
+ return "socket_missing";
2006
+ case "ECONNREFUSED":
2007
+ return "connection_refused";
2008
+ default:
2009
+ return "unavailable";
2010
+ }
2011
+ }
1701
2012
  var HostRelayIpcAdmissionPort = class {
1702
2013
  endpoint;
1703
2014
  timeout_ms;
@@ -1732,7 +2043,7 @@ function exchange(endpoint, encoded, timeoutMs, decode, signal) {
1732
2043
  const socket = createConnection(endpoint);
1733
2044
  let buffer = Buffer.alloc(0);
1734
2045
  let settled = false;
1735
- const aborted = () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC was cancelled."));
2046
+ const aborted = () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC was cancelled.", "cancelled"));
1736
2047
  const finish = (error, response2) => {
1737
2048
  if (settled) return;
1738
2049
  settled = true;
@@ -1741,13 +2052,16 @@ function exchange(endpoint, encoded, timeoutMs, decode, signal) {
1741
2052
  if (error !== null) reject(error);
1742
2053
  else if (response2 !== void 0) resolve(response2);
1743
2054
  };
1744
- if (timeoutMs !== void 0) socket.setTimeout(timeoutMs, () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC timed out.")));
2055
+ if (timeoutMs !== void 0) socket.setTimeout(timeoutMs, () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC timed out.", "timed_out")));
1745
2056
  if (signal?.aborted === true) {
1746
2057
  aborted();
1747
2058
  return;
1748
2059
  }
1749
2060
  signal?.addEventListener("abort", aborted, { once: true });
1750
- socket.once("error", () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC is unavailable.")));
2061
+ socket.once("error", (error) => {
2062
+ const failure = socketErrorFailure(error);
2063
+ finish(new HostRelayIpcError("relay_unavailable", `Host Relay IPC is unavailable: ${failure}.`, failure));
2064
+ });
1751
2065
  socket.once("connect", () => socket.write(encoded));
1752
2066
  socket.on("data", (chunk) => {
1753
2067
  try {
@@ -1755,11 +2069,11 @@ function exchange(endpoint, encoded, timeoutMs, decode, signal) {
1755
2069
  const decoded = decode(buffer);
1756
2070
  if (decoded !== null) finish(null, decoded);
1757
2071
  } catch (error) {
1758
- finish(error instanceof Error ? error : new HostRelayIpcError("relay_unavailable"));
2072
+ finish(new HostRelayIpcError("relay_unavailable", error instanceof Error ? error.message : "Host Relay IPC response is invalid.", "response_invalid"));
1759
2073
  }
1760
2074
  });
1761
2075
  socket.once("end", () => {
1762
- if (!settled) finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC closed without a response."));
2076
+ if (!settled) finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC closed without a response.", "closed_early"));
1763
2077
  });
1764
2078
  });
1765
2079
  }
@@ -1827,6 +2141,9 @@ function encodeLengthPrefixed(value) {
1827
2141
  function exactKeys2(value, keys) {
1828
2142
  return Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
1829
2143
  }
2144
+ function errorCode2(error) {
2145
+ return record3(error) && typeof error.code === "string" ? error.code : null;
2146
+ }
1830
2147
 
1831
2148
  // host/invocation-context.ts
1832
2149
  var HOST_INVOCATION_IDENTITY_KEYS = ["host_session_ref", "host_turn_ref", "host_source_ref"];
@@ -2274,8 +2591,11 @@ import { homedir } from "node:os";
2274
2591
  import { join as join4 } from "node:path";
2275
2592
 
2276
2593
  // host/producer-service.ts
2277
- import { constants } from "node:fs";
2278
- import { lstat as lstat2, open as open3 } from "node:fs/promises";
2594
+ import { posix as posix3, win32 as win323 } from "node:path";
2595
+
2596
+ // host/runtime-source-paths.ts
2597
+ import { createHash as createHash4 } from "node:crypto";
2598
+ import { posix as posix2, win32 as win322 } from "node:path";
2279
2599
 
2280
2600
  // host/absolute-path.ts
2281
2601
  import { posix, win32 } from "node:path";
@@ -2284,7 +2604,35 @@ function isAbsoluteNormalizedNonRootPath(value, flavor = process.platform, allow
2284
2604
  return typeof value === "string" && value.length <= 4096 && !value.includes("\0") && pathApi.isAbsolute(value) && pathApi.normalize(value) === value && (allowRoot || pathApi.parse(value).root !== value);
2285
2605
  }
2286
2606
 
2607
+ // host/runtime-source-paths.ts
2608
+ var HOST_SOURCE_ID = /^host-source:([0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})$/u;
2609
+ function hostSourceUuid(sourceRef) {
2610
+ return HOST_SOURCE_ID.exec(sourceRef)?.[1] ?? null;
2611
+ }
2612
+ function hostRuntimeSourcePaths(stateRoot, sourceRef, platform = process.platform) {
2613
+ const sourceId = hostSourceUuid(sourceRef);
2614
+ if (!isAbsoluteNormalizedNonRootPath(stateRoot, platform) || sourceId === null) throw new TypeError("Host runtime source identity is invalid.");
2615
+ const path = platform === "win32" ? win322 : posix2;
2616
+ const sourcesRoot = path.join(stateRoot, "sources");
2617
+ const sourceRoot = path.join(sourcesRoot, sourceId);
2618
+ const runtimeRoot = path.join(stateRoot, "run");
2619
+ const endpoint = platform === "win32" ? `\\\\.\\pipe\\ceal-host-${createHash4("sha256").update(`${stateRoot}\0${sourceRef}`).digest("hex").slice(0, 24)}` : path.join(runtimeRoot, `${sourceId}.sock`);
2620
+ assertHostRuntimeIpcLength(endpoint, platform);
2621
+ 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 };
2622
+ }
2623
+ function assertHostRuntimeIpcLength(endpoint, platform) {
2624
+ if (platform === "win32") return;
2625
+ const maximum = platform === "linux" ? 107 : 103;
2626
+ 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" });
2627
+ }
2628
+ function assertHostProducerSourcePaths(stateRoot, config, producer, platform = process.platform) {
2629
+ const paths = hostRuntimeSourcePaths(stateRoot, config.host_source_ref, platform);
2630
+ 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.");
2631
+ }
2632
+
2287
2633
  // host/producer-service.ts
2634
+ import { constants } from "node:fs";
2635
+ import { lstat as lstat2, open as open3 } from "node:fs/promises";
2288
2636
  var MAX_CONFIG_BYTES = 32 * 1024;
2289
2637
  var SAFE_REF5 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
2290
2638
  var HOST_PRODUCER_CONFIG_FLAG = "--ceal-host-config";
@@ -2301,7 +2649,15 @@ function parseHostProducerConfigFlag(args, platform = process.platform) {
2301
2649
  return parseProducerHostConfigFlag(args, HOST_PRODUCER_CONFIG_FLAG, platform, hostProducerError);
2302
2650
  }
2303
2651
  async function readHostProducerConfig(descriptor, configPath, platform = process.platform) {
2304
- return decodeHostProducerConfigText(descriptor, await readProducerConfigText(configPath, platform, hostProducerError), platform);
2652
+ const config = decodeHostProducerConfigText(descriptor, await readProducerConfigText(configPath, platform, hostProducerError), platform);
2653
+ const path = platform === "win32" ? win323 : posix3;
2654
+ const root = path.resolve(config.outbox_dir, "../../../../..");
2655
+ try {
2656
+ assertHostProducerSourcePaths(root, config, descriptor.producer_id, platform);
2657
+ } catch (error) {
2658
+ throw hostProducerError("invalid_config", error instanceof Error ? error.message : "Host producer source tuple is invalid.");
2659
+ }
2660
+ return config;
2305
2661
  }
2306
2662
  function decodeHostProducerConfigText(descriptor, text, platform = process.platform) {
2307
2663
  const extraPaths = descriptor.extra_paths ?? [];
@@ -2440,6 +2796,7 @@ function boundedMilliseconds(value) {
2440
2796
  var CLAUDE_PRODUCER_CONFIG_SCHEMA = "ceal.claude_producer_config.v1";
2441
2797
  var CLAUDE_PRODUCER_DESCRIPTOR = {
2442
2798
  schema: CLAUDE_PRODUCER_CONFIG_SCHEMA,
2799
+ producer_id: "claude",
2443
2800
  config: (shared) => shared,
2444
2801
  runtime_options: (config) => Object.freeze({
2445
2802
  outbox_dir: config.outbox_dir,
@@ -2525,12 +2882,13 @@ var execFileAsync = promisify(execFile);
2525
2882
 
2526
2883
  // host/claude/src/claude-installer.ts
2527
2884
  var CLAUDE_LOCAL_CAPABILITY_ACTIVATION = Object.freeze({ environment: "CLAUDE_CODE_ENTRYPOINT", value: "cli" });
2885
+ var CLAUDE_CLIENT_ALLOW_RULE = `Bash(${CEAL_SESSION_ENTRY_INVOCATION}:*)`;
2528
2886
 
2529
2887
  // host/claude/bin/ceal-claude-hook.ts
2530
2888
  async function main() {
2531
2889
  return runClaudeHookCli();
2532
2890
  }
2533
- if (isDirectInvocation(import.meta.url)) process.exitCode = await main();
2891
+ if (import.meta.main) process.exitCode = await main();
2534
2892
  export {
2535
2893
  main
2536
2894
  };