@cleocode/contracts 2026.6.13 → 2026.6.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/operation-def.test.js +4 -1
- package/dist/__tests__/operation-def.test.js.map +1 -1
- package/dist/__tests__/provider-def.test.d.ts +12 -0
- package/dist/__tests__/provider-def.test.d.ts.map +1 -0
- package/dist/__tests__/provider-def.test.js +84 -0
- package/dist/__tests__/provider-def.test.js.map +1 -0
- package/dist/__tests__/service-provider.test.d.ts +17 -0
- package/dist/__tests__/service-provider.test.d.ts.map +1 -0
- package/dist/__tests__/service-provider.test.js +108 -0
- package/dist/__tests__/service-provider.test.js.map +1 -0
- package/dist/boundary.d.ts +52 -0
- package/dist/boundary.d.ts.map +1 -1
- package/dist/boundary.js +23 -0
- package/dist/boundary.js.map +1 -1
- package/dist/conduit.d.ts +171 -0
- package/dist/conduit.d.ts.map +1 -1
- package/dist/config/index.d.ts +23 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +22 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.d.ts +21 -0
- package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.d.ts.map +1 -0
- package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.js +84 -0
- package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.js.map +1 -0
- package/dist/dispatch/identity.d.ts +1 -1
- package/dist/dispatch/identity.d.ts.map +1 -1
- package/dist/dispatch/identity.js +20 -0
- package/dist/dispatch/identity.js.map +1 -1
- package/dist/dispatch/operation-def.d.ts +20 -0
- package/dist/dispatch/operation-def.d.ts.map +1 -1
- package/dist/dispatch/operations-registry.d.ts.map +1 -1
- package/dist/dispatch/operations-registry.js +1030 -46
- package/dist/dispatch/operations-registry.js.map +1 -1
- package/dist/index.d.ts +15 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/lease-ipc/__tests__/freeze.test.js +92 -0
- package/dist/lease-ipc/__tests__/freeze.test.js.map +1 -1
- package/dist/lease-ipc/index.d.ts +2 -2
- package/dist/lease-ipc/index.d.ts.map +1 -1
- package/dist/lease-ipc/index.js +1 -1
- package/dist/lease-ipc/index.js.map +1 -1
- package/dist/lease-ipc/messages.d.ts +167 -3
- package/dist/lease-ipc/messages.d.ts.map +1 -1
- package/dist/lease-ipc/messages.js +93 -0
- package/dist/lease-ipc/messages.js.map +1 -1
- package/dist/llm/catalog-schema.d.ts +242 -0
- package/dist/llm/catalog-schema.d.ts.map +1 -0
- package/dist/llm/catalog-schema.js +153 -0
- package/dist/llm/catalog-schema.js.map +1 -0
- package/dist/llm/catalog-schema.json +139 -0
- package/dist/llm/index.d.ts +15 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +14 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/oauth.d.ts +16 -2
- package/dist/llm/oauth.d.ts.map +1 -1
- package/dist/llm/onboarding.d.ts +126 -0
- package/dist/llm/onboarding.d.ts.map +1 -0
- package/dist/llm/onboarding.js +34 -0
- package/dist/llm/onboarding.js.map +1 -0
- package/dist/llm/provider-def.d.ts +254 -0
- package/dist/llm/provider-def.d.ts.map +1 -0
- package/dist/llm/provider-def.js +93 -0
- package/dist/llm/provider-def.js.map +1 -0
- package/dist/llm/system-resolver.d.ts +42 -0
- package/dist/llm/system-resolver.d.ts.map +1 -1
- package/dist/operations/admin.d.ts +124 -1
- package/dist/operations/admin.d.ts.map +1 -1
- package/dist/operations/entities.d.ts +110 -0
- package/dist/operations/entities.d.ts.map +1 -0
- package/dist/operations/entities.js +695 -0
- package/dist/operations/entities.js.map +1 -0
- package/dist/operations/llm.d.ts +15 -0
- package/dist/operations/llm.d.ts.map +1 -1
- package/dist/operations/output-contracts-data.d.ts.map +1 -1
- package/dist/operations/output-contracts-data.js +230 -0
- package/dist/operations/output-contracts-data.js.map +1 -1
- package/dist/operations/service.d.ts +68 -0
- package/dist/operations/service.d.ts.map +1 -0
- package/dist/operations/service.js +336 -0
- package/dist/operations/service.js.map +1 -0
- package/dist/operations/tasks.d.ts +109 -0
- package/dist/operations/tasks.d.ts.map +1 -1
- package/dist/operations/tasks.js.map +1 -1
- package/dist/playbook.d.ts +56 -0
- package/dist/playbook.d.ts.map +1 -1
- package/dist/release/plan.d.ts +5 -5
- package/dist/vault/service-provider.d.ts +343 -0
- package/dist/vault/service-provider.d.ts.map +1 -0
- package/dist/vault/service-provider.js +857 -0
- package/dist/vault/service-provider.js.map +1 -0
- package/dist/workgraph.d.ts +12 -12
- package/package.json +10 -2
- package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
- package/src/__tests__/operation-def.test.ts +6 -1
- package/src/__tests__/provider-def.test.ts +93 -0
- package/src/__tests__/service-provider.test.ts +129 -0
- package/src/boundary.ts +69 -0
- package/src/conduit.ts +200 -0
- package/src/config/index.ts +35 -0
- package/src/config.ts +2 -1
- package/src/dispatch/__tests__/tasks-gateway-crud-ops.test.ts +99 -0
- package/src/dispatch/identity.ts +20 -0
- package/src/dispatch/operation-def.ts +21 -0
- package/src/dispatch/operations-registry.ts +1062 -36
- package/src/index.ts +137 -1
- package/src/lease-ipc/__tests__/freeze.test.ts +96 -0
- package/src/lease-ipc/index.ts +12 -0
- package/src/lease-ipc/messages.ts +117 -0
- package/src/llm/catalog-schema.json +139 -0
- package/src/llm/catalog-schema.ts +184 -0
- package/src/llm/index.ts +29 -0
- package/src/llm/oauth.ts +16 -2
- package/src/llm/onboarding.ts +131 -0
- package/src/llm/provider-def.ts +291 -0
- package/src/llm/system-resolver.ts +45 -0
- package/src/operations/admin.ts +144 -0
- package/src/operations/entities.ts +758 -0
- package/src/operations/llm.ts +15 -0
- package/src/operations/output-contracts-data.ts +264 -0
- package/src/operations/service.ts +360 -0
- package/src/operations/tasks.ts +119 -0
- package/src/playbook.ts +56 -0
- package/src/vault/service-provider.ts +1137 -0
package/src/index.ts
CHANGED
|
@@ -140,12 +140,14 @@ export type {
|
|
|
140
140
|
export type {
|
|
141
141
|
BoundaryEntry,
|
|
142
142
|
CanonicalHome,
|
|
143
|
+
ChannelBoundaryEntry,
|
|
144
|
+
ChannelTrustPosture,
|
|
143
145
|
PerfBudget,
|
|
144
146
|
SafetyBudget,
|
|
145
147
|
ThroughputThreshold,
|
|
146
148
|
WorkloadIntent,
|
|
147
149
|
} from './boundary.js';
|
|
148
|
-
export { BOUNDARY_REGISTRY } from './boundary.js';
|
|
150
|
+
export { BOUNDARY_REGISTRY, CHANNEL_BOUNDARY_REGISTRY } from './boundary.js';
|
|
149
151
|
// === Brain/Memory Types ===
|
|
150
152
|
export type {
|
|
151
153
|
BackupRecoverBrainResult,
|
|
@@ -213,6 +215,11 @@ export type {
|
|
|
213
215
|
} from './code-symbol.js';
|
|
214
216
|
// === Conduit Protocol (agent-to-agent communication) ===
|
|
215
217
|
export type {
|
|
218
|
+
ChannelAdapter,
|
|
219
|
+
ChannelConfig,
|
|
220
|
+
ChannelHealth,
|
|
221
|
+
ChannelHealthStatus,
|
|
222
|
+
ChannelSession,
|
|
216
223
|
Conduit,
|
|
217
224
|
ConduitConfig,
|
|
218
225
|
ConduitMessage,
|
|
@@ -223,6 +230,8 @@ export type {
|
|
|
223
230
|
ConduitTopicPublishOptions,
|
|
224
231
|
ConduitTopicSubscribeOptions,
|
|
225
232
|
ConduitUnsubscribe,
|
|
233
|
+
InboundMsg,
|
|
234
|
+
OutboundReply,
|
|
226
235
|
} from './conduit.js';
|
|
227
236
|
// === Config Manifest (T9876 / Saga T9855) ===
|
|
228
237
|
export type {
|
|
@@ -759,6 +768,10 @@ export type {
|
|
|
759
768
|
LeaseRenewRequest,
|
|
760
769
|
LeaseRevokedResponse,
|
|
761
770
|
LeaseScope,
|
|
771
|
+
QueueAdmitDisposition,
|
|
772
|
+
QueueAdmitRequest,
|
|
773
|
+
QueueAdmitResultResponse,
|
|
774
|
+
QueuePriorityClass,
|
|
762
775
|
RateCheckRequest,
|
|
763
776
|
RateResultResponse,
|
|
764
777
|
ToolGrantedResponse,
|
|
@@ -786,11 +799,38 @@ export {
|
|
|
786
799
|
LeaseRenewRequestSchema,
|
|
787
800
|
LeaseRevokedResponseSchema,
|
|
788
801
|
LeaseScopeSchema,
|
|
802
|
+
QueueAdmitDispositionSchema,
|
|
803
|
+
QueueAdmitRequestSchema,
|
|
804
|
+
QueueAdmitResultResponseSchema,
|
|
805
|
+
QueuePriorityClassSchema,
|
|
789
806
|
RateCheckRequestSchema,
|
|
790
807
|
RateResultResponseSchema,
|
|
791
808
|
ToolGrantedResponseSchema,
|
|
792
809
|
ToolGrantRequestSchema,
|
|
793
810
|
} from './lease-ipc/index.js';
|
|
811
|
+
export type {
|
|
812
|
+
CatalogAuthType,
|
|
813
|
+
CatalogModelEntry,
|
|
814
|
+
CatalogModelStatus,
|
|
815
|
+
CatalogProvider,
|
|
816
|
+
CuratedCatalog,
|
|
817
|
+
ModelsCatalogRowInsert,
|
|
818
|
+
ModelsCatalogRowSelect,
|
|
819
|
+
} from './llm/catalog-schema.js';
|
|
820
|
+
// === E8 Curated Models Catalog (T11731 · offline-first catalog SSoT) ===
|
|
821
|
+
export {
|
|
822
|
+
CATALOG_AUTH_TYPES,
|
|
823
|
+
CATALOG_MODEL_STATUSES,
|
|
824
|
+
catalogCostSchema,
|
|
825
|
+
catalogLimitSchema,
|
|
826
|
+
catalogModalitiesSchema,
|
|
827
|
+
catalogModelEntrySchema,
|
|
828
|
+
catalogModelProviderSchema,
|
|
829
|
+
catalogProviderSchema,
|
|
830
|
+
curatedCatalogSchema,
|
|
831
|
+
modelsCatalogRowInsertSchema,
|
|
832
|
+
modelsCatalogRowSelectSchema,
|
|
833
|
+
} from './llm/catalog-schema.js';
|
|
794
834
|
// === LLM Error Taxonomy (T9270 — Hermes FailoverReason port) ===
|
|
795
835
|
export type { ClassifiedError, FailoverReason } from './llm/failover-reason.js';
|
|
796
836
|
// === Phase 4 Unified Architecture (T9281 / ADR-072) — Session + Executor interfaces ===
|
|
@@ -826,6 +866,14 @@ export type {
|
|
|
826
866
|
} from './llm/normalized-response.js';
|
|
827
867
|
// === OAuth types — SSoT shared between core and cleo (T9302) ===
|
|
828
868
|
export type { OAuthMode, OAuthTokens, PkceFlowConfig, ProviderOAuthConfig } from './llm/oauth.js';
|
|
869
|
+
// === Onboarding login engine result envelope (T11724 · M3) ===
|
|
870
|
+
export type {
|
|
871
|
+
OnboardingAuthMode,
|
|
872
|
+
OnboardingResult,
|
|
873
|
+
OnboardingStepName,
|
|
874
|
+
OnboardingStepResult,
|
|
875
|
+
OnboardingStepStatus,
|
|
876
|
+
} from './llm/onboarding.js';
|
|
829
877
|
// === Phase 4/5 Plugin LLM facade types (T9305 / T9313) ===
|
|
830
878
|
export type { PluginLlmComplete, PluginLlmContext } from './llm/plugin-llm.js';
|
|
831
879
|
export {
|
|
@@ -834,6 +882,23 @@ export {
|
|
|
834
882
|
PluginModelGateError,
|
|
835
883
|
PluginRateLimitedError,
|
|
836
884
|
} from './llm/plugin-llm.js';
|
|
885
|
+
export type {
|
|
886
|
+
AiSdkEndpoint,
|
|
887
|
+
AnthropicMessagesEndpoint,
|
|
888
|
+
OAuthFlowDef,
|
|
889
|
+
OpenAICompletionsEndpoint,
|
|
890
|
+
OpenAIResponsesEndpoint,
|
|
891
|
+
ProviderDef,
|
|
892
|
+
ProviderEndpoint,
|
|
893
|
+
ProviderTransport,
|
|
894
|
+
RequestQuirk,
|
|
895
|
+
RequestQuirkKind,
|
|
896
|
+
} from './llm/provider-def.js';
|
|
897
|
+
// === M3 Provider SSoT (T11702 · epic T11667) — declarative ProviderDef ===
|
|
898
|
+
export {
|
|
899
|
+
PROVIDER_TRANSPORTS,
|
|
900
|
+
REQUEST_QUIRK_KINDS,
|
|
901
|
+
} from './llm/provider-def.js';
|
|
837
902
|
// === Phase 4 Unified Architecture (T9281 / ADR-072) — Provider identity ===
|
|
838
903
|
export type { ApiMode, BuiltinProviderId, ProviderId } from './llm/provider-id.js';
|
|
839
904
|
// === Provider Profile + Plugin Contracts (T9262 — Phase 3 T-LLM-CRED) ===
|
|
@@ -1045,10 +1110,19 @@ export type {
|
|
|
1045
1110
|
AdminBackupListParams,
|
|
1046
1111
|
AdminBackupMutateParams,
|
|
1047
1112
|
AdminCleanupParams,
|
|
1113
|
+
AdminConfigGetParams,
|
|
1114
|
+
AdminConfigGetResult,
|
|
1115
|
+
AdminConfigListParams,
|
|
1116
|
+
AdminConfigListResult,
|
|
1048
1117
|
AdminConfigPresetsParams,
|
|
1118
|
+
AdminConfigScope,
|
|
1049
1119
|
AdminConfigSetParams,
|
|
1050
1120
|
AdminConfigSetPresetParams,
|
|
1051
1121
|
AdminConfigShowParams,
|
|
1122
|
+
AdminConfigUnsetParams,
|
|
1123
|
+
AdminConfigUnsetResult,
|
|
1124
|
+
AdminConfigValidateParams,
|
|
1125
|
+
AdminConfigValidateResult,
|
|
1052
1126
|
AdminContextInjectParams,
|
|
1053
1127
|
AdminContextParams,
|
|
1054
1128
|
AdminContextPullParams,
|
|
@@ -1143,6 +1217,35 @@ export {
|
|
|
1143
1217
|
taskTreeEntrySchema,
|
|
1144
1218
|
taskTreeSchema,
|
|
1145
1219
|
} from './operations/ensures-schema-registry.js';
|
|
1220
|
+
// 5-entity provider-experience op contracts (T11700 · epic T11666) — INPUT
|
|
1221
|
+
// contracts consumed by core's INPUT_CONTRACTS registry; OUTPUT contracts already
|
|
1222
|
+
// register into OUTPUT_CONTRACTS above.
|
|
1223
|
+
export {
|
|
1224
|
+
accountAddInputContract,
|
|
1225
|
+
accountAddOutputContract,
|
|
1226
|
+
accountListInputContract,
|
|
1227
|
+
accountListOutputContract,
|
|
1228
|
+
accountRemoveInputContract,
|
|
1229
|
+
accountRemoveOutputContract,
|
|
1230
|
+
modelQueryInputContract,
|
|
1231
|
+
modelQueryOutputContract,
|
|
1232
|
+
modelShowInputContract,
|
|
1233
|
+
modelShowOutputContract,
|
|
1234
|
+
profileCreateInputContract,
|
|
1235
|
+
profileCreateOutputContract,
|
|
1236
|
+
profileListInputContract,
|
|
1237
|
+
profileListOutputContract,
|
|
1238
|
+
profilePinInputContract,
|
|
1239
|
+
profilePinOutputContract,
|
|
1240
|
+
profileUseInputContract,
|
|
1241
|
+
profileUseOutputContract,
|
|
1242
|
+
providerConnectInputContract,
|
|
1243
|
+
providerConnectOutputContract,
|
|
1244
|
+
providerListInputContract,
|
|
1245
|
+
providerListOutputContract,
|
|
1246
|
+
providerShowInputContract,
|
|
1247
|
+
providerShowOutputContract,
|
|
1248
|
+
} from './operations/entities.js';
|
|
1146
1249
|
// === Operations Types (API wire format, namespaced to avoid collision with domain types) ===
|
|
1147
1250
|
export * as ops from './operations/index.js';
|
|
1148
1251
|
// === Operation Input Contracts (T9914 / Saga T9855 / E7) ===
|
|
@@ -1473,6 +1576,19 @@ export type {
|
|
|
1473
1576
|
ProposeRunResult,
|
|
1474
1577
|
SentientOps,
|
|
1475
1578
|
} from './operations/sentient.js';
|
|
1579
|
+
// Service-vault CLI op contracts (T11941 · epic T11765 · M2-W4) — INPUT contracts
|
|
1580
|
+
// consumed by core's INPUT_CONTRACTS registry; OUTPUT contracts already register
|
|
1581
|
+
// into OUTPUT_CONTRACTS above.
|
|
1582
|
+
export {
|
|
1583
|
+
serviceConnectInputContract,
|
|
1584
|
+
serviceConnectOutputContract,
|
|
1585
|
+
serviceListInputContract,
|
|
1586
|
+
serviceListOutputContract,
|
|
1587
|
+
serviceRevokeInputContract,
|
|
1588
|
+
serviceRevokeOutputContract,
|
|
1589
|
+
serviceStatusInputContract,
|
|
1590
|
+
serviceStatusOutputContract,
|
|
1591
|
+
} from './operations/service.js';
|
|
1476
1592
|
// Session operation param/result types — re-exported at top level for typed-dispatch consumers
|
|
1477
1593
|
// (T975 Wave D · ADR-051 migration)
|
|
1478
1594
|
export type {
|
|
@@ -2385,6 +2501,26 @@ export {
|
|
|
2385
2501
|
validatorRejectionSchema,
|
|
2386
2502
|
validatorVerdictSchema,
|
|
2387
2503
|
} from './validator/index.js';
|
|
2504
|
+
// === Universal Service Vault — declarative service-provider registry (T11937 seed + T11938 breadth, epic T11765) ===
|
|
2505
|
+
export type {
|
|
2506
|
+
CredentialHeaderRule,
|
|
2507
|
+
HostAuthStrategy,
|
|
2508
|
+
InjectionRule,
|
|
2509
|
+
InjectionValueSource,
|
|
2510
|
+
MetadataHeaderRule,
|
|
2511
|
+
RefreshBodyFormat,
|
|
2512
|
+
RefreshClientAuth,
|
|
2513
|
+
RefreshConfig,
|
|
2514
|
+
RefreshKind,
|
|
2515
|
+
ServiceAuthKind,
|
|
2516
|
+
ServiceHostRule,
|
|
2517
|
+
ServiceProviderDef,
|
|
2518
|
+
} from './vault/service-provider.js';
|
|
2519
|
+
export {
|
|
2520
|
+
REFRESH_KINDS,
|
|
2521
|
+
SERVICE_AUTH_KINDS,
|
|
2522
|
+
SERVICE_PROVIDERS,
|
|
2523
|
+
} from './vault/service-provider.js';
|
|
2388
2524
|
export type {
|
|
2389
2525
|
TasksFrontierParamsInput,
|
|
2390
2526
|
TasksRollupParamsInput,
|
|
@@ -44,6 +44,8 @@ describe('lease-ipc v1.1 freeze guard (T11627)', () => {
|
|
|
44
44
|
'lease_renew',
|
|
45
45
|
'rate_check',
|
|
46
46
|
'tool_grant',
|
|
47
|
+
'queue_admit',
|
|
48
|
+
'worker_heartbeat',
|
|
47
49
|
]);
|
|
48
50
|
});
|
|
49
51
|
|
|
@@ -56,6 +58,8 @@ describe('lease-ipc v1.1 freeze guard (T11627)', () => {
|
|
|
56
58
|
'tool_granted',
|
|
57
59
|
'lease_revoked',
|
|
58
60
|
'child_killed_unresponsive',
|
|
61
|
+
'queue_admit_result',
|
|
62
|
+
'heartbeat_ack',
|
|
59
63
|
'error',
|
|
60
64
|
]);
|
|
61
65
|
});
|
|
@@ -81,6 +85,8 @@ describe('lease-ipc v1.1 freeze guard (T11627)', () => {
|
|
|
81
85
|
'lease_renew',
|
|
82
86
|
'rate_check',
|
|
83
87
|
'tool_grant',
|
|
88
|
+
'queue_admit',
|
|
89
|
+
'worker_heartbeat',
|
|
84
90
|
'lease_granted',
|
|
85
91
|
'lease_queued',
|
|
86
92
|
'lease_denied',
|
|
@@ -88,6 +94,8 @@ describe('lease-ipc v1.1 freeze guard (T11627)', () => {
|
|
|
88
94
|
'tool_granted',
|
|
89
95
|
'lease_revoked',
|
|
90
96
|
'child_killed_unresponsive',
|
|
97
|
+
'queue_admit_result',
|
|
98
|
+
'heartbeat_ack',
|
|
91
99
|
'error',
|
|
92
100
|
]);
|
|
93
101
|
});
|
|
@@ -162,6 +170,74 @@ describe('lease-ipc v1.1 wire-shape parity with Rust serde (T11627)', () => {
|
|
|
162
170
|
expect(LeaseIpcEnvelopeSchema.safeParse(wire).success).toBe(true);
|
|
163
171
|
});
|
|
164
172
|
|
|
173
|
+
it('parses the exact JSON a Rust queue_admit request envelope serializes (T11630)', () => {
|
|
174
|
+
const wire = {
|
|
175
|
+
protocol_version: '1.1.0',
|
|
176
|
+
id: 'qa-1',
|
|
177
|
+
direction: 'request',
|
|
178
|
+
request: {
|
|
179
|
+
kind: 'queue_admit',
|
|
180
|
+
provider: 'anthropic',
|
|
181
|
+
priority_class: 'lead',
|
|
182
|
+
est_tokens: 1024,
|
|
183
|
+
child_id: 'worker-1',
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
const parsed = LeaseIpcEnvelopeSchema.safeParse(wire);
|
|
187
|
+
expect(parsed.success).toBe(true);
|
|
188
|
+
if (parsed.success && parsed.data.direction === 'request') {
|
|
189
|
+
expect(parsed.data.request.kind).toBe('queue_admit');
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('parses the exact JSON a Rust queue_admit_result response envelope serializes (T11630)', () => {
|
|
194
|
+
const wire = {
|
|
195
|
+
protocol_version: '1.1.0',
|
|
196
|
+
id: 'qa-1',
|
|
197
|
+
direction: 'response',
|
|
198
|
+
response: {
|
|
199
|
+
kind: 'queue_admit_result',
|
|
200
|
+
disposition: 'deferred',
|
|
201
|
+
retry_after_ms: 250,
|
|
202
|
+
tokens_remaining: 0,
|
|
203
|
+
queue_position: 2,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
expect(LeaseIpcEnvelopeSchema.safeParse(wire).success).toBe(true);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('parses the exact JSON a Rust worker_heartbeat request envelope serializes (T11628)', () => {
|
|
210
|
+
const wire = {
|
|
211
|
+
protocol_version: '1.1.0',
|
|
212
|
+
id: 'hb-1',
|
|
213
|
+
direction: 'request',
|
|
214
|
+
request: {
|
|
215
|
+
kind: 'worker_heartbeat',
|
|
216
|
+
child_id: 'worker-7',
|
|
217
|
+
in_flight_llm: true,
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
const parsed = LeaseIpcEnvelopeSchema.safeParse(wire);
|
|
221
|
+
expect(parsed.success).toBe(true);
|
|
222
|
+
if (parsed.success && parsed.data.direction === 'request') {
|
|
223
|
+
expect(parsed.data.request.kind).toBe('worker_heartbeat');
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('parses the exact JSON a Rust heartbeat_ack response envelope serializes (T11628)', () => {
|
|
228
|
+
const wire = {
|
|
229
|
+
protocol_version: '1.1.0',
|
|
230
|
+
id: 'hb-1',
|
|
231
|
+
direction: 'response',
|
|
232
|
+
response: { kind: 'heartbeat_ack' },
|
|
233
|
+
};
|
|
234
|
+
const parsed = LeaseIpcEnvelopeSchema.safeParse(wire);
|
|
235
|
+
expect(parsed.success).toBe(true);
|
|
236
|
+
if (parsed.success && parsed.data.direction === 'response') {
|
|
237
|
+
expect(parsed.data.response.kind).toBe('heartbeat_ack');
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
|
|
165
241
|
it('rejects an unknown message kind (proves the union is closed)', () => {
|
|
166
242
|
const wire = {
|
|
167
243
|
protocol_version: '1.1.0',
|
|
@@ -212,6 +288,16 @@ function sampleRequestFor(kind: (typeof LEASE_IPC_REQUEST_KINDS)[number]): unkno
|
|
|
212
288
|
return { kind, scope: 'global', lane: 'bulk', est_bytes: 4096 };
|
|
213
289
|
case 'tool_grant':
|
|
214
290
|
return { kind, tool: 'browser', holder_id: 'h' };
|
|
291
|
+
case 'queue_admit':
|
|
292
|
+
return {
|
|
293
|
+
kind,
|
|
294
|
+
provider: 'anthropic',
|
|
295
|
+
priority_class: 'lead',
|
|
296
|
+
est_tokens: 1024,
|
|
297
|
+
child_id: 'worker-1',
|
|
298
|
+
};
|
|
299
|
+
case 'worker_heartbeat':
|
|
300
|
+
return { kind, child_id: 'worker-1', in_flight_llm: true };
|
|
215
301
|
}
|
|
216
302
|
}
|
|
217
303
|
|
|
@@ -240,6 +326,16 @@ function sampleResponseFor(kind: (typeof LEASE_IPC_RESPONSE_KINDS)[number]): unk
|
|
|
240
326
|
return { kind, scope: 'project', lane: 'tasks', holder_id: 'h', reason: 'ttl expired' };
|
|
241
327
|
case 'child_killed_unresponsive':
|
|
242
328
|
return { kind, child_id: 'w1', holder_id: 'h', scope: 'project', reason: 'unresponsive' };
|
|
329
|
+
case 'queue_admit_result':
|
|
330
|
+
return {
|
|
331
|
+
kind,
|
|
332
|
+
disposition: 'deferred',
|
|
333
|
+
retry_after_ms: 250,
|
|
334
|
+
tokens_remaining: 0,
|
|
335
|
+
queue_position: 2,
|
|
336
|
+
};
|
|
337
|
+
case 'heartbeat_ack':
|
|
338
|
+
return { kind };
|
|
243
339
|
case 'error':
|
|
244
340
|
return { kind, code: 'E_X', message: 'x' };
|
|
245
341
|
}
|
package/src/lease-ipc/index.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
export type {
|
|
16
16
|
ChildKilledUnresponsiveResponse,
|
|
17
|
+
HeartbeatAckResponse,
|
|
17
18
|
LeaseAcquireRequest,
|
|
18
19
|
LeaseDeniedResponse,
|
|
19
20
|
LeaseErrorResponse,
|
|
@@ -29,14 +30,20 @@ export type {
|
|
|
29
30
|
LeaseRenewRequest,
|
|
30
31
|
LeaseRevokedResponse,
|
|
31
32
|
LeaseScope,
|
|
33
|
+
QueueAdmitDisposition,
|
|
34
|
+
QueueAdmitRequest,
|
|
35
|
+
QueueAdmitResultResponse,
|
|
36
|
+
QueuePriorityClass,
|
|
32
37
|
RateCheckRequest,
|
|
33
38
|
RateResultResponse,
|
|
34
39
|
ToolGrantedResponse,
|
|
35
40
|
ToolGrantRequest,
|
|
41
|
+
WorkerHeartbeatRequest,
|
|
36
42
|
} from './messages.js';
|
|
37
43
|
|
|
38
44
|
export {
|
|
39
45
|
ChildKilledUnresponsiveResponseSchema,
|
|
46
|
+
HeartbeatAckResponseSchema,
|
|
40
47
|
LEASE_IPC_MESSAGE_KINDS,
|
|
41
48
|
LEASE_IPC_REQUEST_KINDS,
|
|
42
49
|
LEASE_IPC_RESPONSE_KINDS,
|
|
@@ -55,9 +62,14 @@ export {
|
|
|
55
62
|
LeaseRenewRequestSchema,
|
|
56
63
|
LeaseRevokedResponseSchema,
|
|
57
64
|
LeaseScopeSchema,
|
|
65
|
+
QueueAdmitDispositionSchema,
|
|
66
|
+
QueueAdmitRequestSchema,
|
|
67
|
+
QueueAdmitResultResponseSchema,
|
|
68
|
+
QueuePriorityClassSchema,
|
|
58
69
|
RateCheckRequestSchema,
|
|
59
70
|
RateResultResponseSchema,
|
|
60
71
|
ToolGrantedResponseSchema,
|
|
61
72
|
ToolGrantRequestSchema,
|
|
73
|
+
WorkerHeartbeatRequestSchema,
|
|
62
74
|
} from './messages.js';
|
|
63
75
|
export { isFrozenLeaseIpcVersion, LEASE_IPC_PROTOCOL_VERSION } from './version.js';
|
|
@@ -169,6 +169,66 @@ export const ToolGrantRequestSchema = z
|
|
|
169
169
|
/** Tool-grant request payload (inferred from {@link ToolGrantRequestSchema}). */
|
|
170
170
|
export type ToolGrantRequest = z.infer<typeof ToolGrantRequestSchema>;
|
|
171
171
|
|
|
172
|
+
/**
|
|
173
|
+
* The priority class of a `queue_admit` request (T11630). Mirrors the Rust
|
|
174
|
+
* `QueuePriorityClass` enum and `cleo_supervisor::llm_queue::PriorityClass`.
|
|
175
|
+
*
|
|
176
|
+
* `lead > worker > background` — a lead/orchestrator agent is never starved by a
|
|
177
|
+
* background consolidation (AC1).
|
|
178
|
+
*/
|
|
179
|
+
export const QueuePriorityClassSchema = z.enum(['lead', 'worker', 'background']);
|
|
180
|
+
|
|
181
|
+
/** A `queue_admit` priority class (inferred from {@link QueuePriorityClassSchema}). */
|
|
182
|
+
export type QueuePriorityClass = z.infer<typeof QueuePriorityClassSchema>;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Admit (or defer) an outbound LLM call through the supervisor's priority
|
|
186
|
+
* scheduler + per-provider rate governor (T11630 · AC1-AC4). Mirrors
|
|
187
|
+
* `QueueAdmitReq`. `[wired]`
|
|
188
|
+
*/
|
|
189
|
+
export const QueueAdmitRequestSchema = z
|
|
190
|
+
.object({
|
|
191
|
+
/** Tag discriminating this request variant. */
|
|
192
|
+
kind: z.literal('queue_admit'),
|
|
193
|
+
/** The LLM provider id the call targets (rate budget is per-provider). */
|
|
194
|
+
provider: z.string().min(1),
|
|
195
|
+
/** The caller's priority class (lead > worker > background). */
|
|
196
|
+
priority_class: QueuePriorityClassSchema,
|
|
197
|
+
/** The caller's estimate of the request's token cost (debited on admit). */
|
|
198
|
+
est_tokens: z.number().int().nonnegative(),
|
|
199
|
+
/** The child the call belongs to (in-flight tracking — the watchdog seam). */
|
|
200
|
+
child_id: z.string().min(1),
|
|
201
|
+
})
|
|
202
|
+
.strict();
|
|
203
|
+
|
|
204
|
+
/** Queue-admit request payload (inferred from {@link QueueAdmitRequestSchema}). */
|
|
205
|
+
export type QueueAdmitRequest = z.infer<typeof QueueAdmitRequestSchema>;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* A liveness heartbeat from a managed worker (T11628). Mirrors
|
|
209
|
+
* `WorkerHeartbeatReq`. `[wired]`
|
|
210
|
+
*
|
|
211
|
+
* The worker sends this periodically (well inside the watchdog's NORMAL
|
|
212
|
+
* deadline) so the supervisor knows it is alive. `in_flight_llm` is the worker's
|
|
213
|
+
* OWN view of whether it is currently waiting on an LLM call: when true the
|
|
214
|
+
* watchdog grants the EXTENDED deadline even if the call never went through the
|
|
215
|
+
* `queue_admit` seam, so a slow-but-healthy long call is never false-killed
|
|
216
|
+
* (AC2 · RISK-7).
|
|
217
|
+
*/
|
|
218
|
+
export const WorkerHeartbeatRequestSchema = z
|
|
219
|
+
.object({
|
|
220
|
+
/** Tag discriminating this request variant. */
|
|
221
|
+
kind: z.literal('worker_heartbeat'),
|
|
222
|
+
/** The logical id of the heartbeating child (matches the registry key). */
|
|
223
|
+
child_id: z.string().min(1),
|
|
224
|
+
/** The worker's own view of whether it is currently inside an LLM call. */
|
|
225
|
+
in_flight_llm: z.boolean(),
|
|
226
|
+
})
|
|
227
|
+
.strict();
|
|
228
|
+
|
|
229
|
+
/** Worker-heartbeat request payload (inferred from {@link WorkerHeartbeatRequestSchema}). */
|
|
230
|
+
export type WorkerHeartbeatRequest = z.infer<typeof WorkerHeartbeatRequestSchema>;
|
|
231
|
+
|
|
172
232
|
/**
|
|
173
233
|
* The discriminated union of all client → arbiter lease requests. The `kind`
|
|
174
234
|
* field selects the variant, matching the serde `#[serde(tag = "kind")]`
|
|
@@ -180,6 +240,8 @@ export const LeaseIpcRequestSchema = z.discriminatedUnion('kind', [
|
|
|
180
240
|
LeaseRenewRequestSchema,
|
|
181
241
|
RateCheckRequestSchema,
|
|
182
242
|
ToolGrantRequestSchema,
|
|
243
|
+
QueueAdmitRequestSchema,
|
|
244
|
+
WorkerHeartbeatRequestSchema,
|
|
183
245
|
]);
|
|
184
246
|
|
|
185
247
|
/** Any lease IPC request (inferred from {@link LeaseIpcRequestSchema}). */
|
|
@@ -334,6 +396,55 @@ export const ChildKilledUnresponsiveResponseSchema = z
|
|
|
334
396
|
/** Child-killed event payload (inferred from {@link ChildKilledUnresponsiveResponseSchema}). */
|
|
335
397
|
export type ChildKilledUnresponsiveResponse = z.infer<typeof ChildKilledUnresponsiveResponseSchema>;
|
|
336
398
|
|
|
399
|
+
/**
|
|
400
|
+
* The disposition of a `queue_admit` request (T11630). Mirrors
|
|
401
|
+
* `QueueAdmitDisposition` in Rust — `admitted` (execute now) or `deferred`
|
|
402
|
+
* (back off `retry_after_ms` and re-request; AC4 — never a silent drop).
|
|
403
|
+
*/
|
|
404
|
+
export const QueueAdmitDispositionSchema = z.enum(['admitted', 'deferred']);
|
|
405
|
+
|
|
406
|
+
/** A `queue_admit` disposition (inferred from {@link QueueAdmitDispositionSchema}). */
|
|
407
|
+
export type QueueAdmitDisposition = z.infer<typeof QueueAdmitDispositionSchema>;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Reply to a `queue_admit`: the LLM call was admitted or deferred (T11630).
|
|
411
|
+
* Mirrors `QueueAdmitResult`.
|
|
412
|
+
*/
|
|
413
|
+
export const QueueAdmitResultResponseSchema = z
|
|
414
|
+
.object({
|
|
415
|
+
/** Tag discriminating this response variant. */
|
|
416
|
+
kind: z.literal('queue_admit_result'),
|
|
417
|
+
/** Whether the LLM call was admitted or deferred. */
|
|
418
|
+
disposition: QueueAdmitDispositionSchema,
|
|
419
|
+
/** Back-off in ms before re-requesting (0 when admitted). */
|
|
420
|
+
retry_after_ms: z.number().int().nonnegative(),
|
|
421
|
+
/** Remaining provider token budget after this decision. */
|
|
422
|
+
tokens_remaining: z.number().int().nonnegative(),
|
|
423
|
+
/** Number of higher/equal-priority waiters ahead (0 when admitted). */
|
|
424
|
+
queue_position: z.number().int().nonnegative(),
|
|
425
|
+
})
|
|
426
|
+
.strict();
|
|
427
|
+
|
|
428
|
+
/** Queue-admit result payload (inferred from {@link QueueAdmitResultResponseSchema}). */
|
|
429
|
+
export type QueueAdmitResultResponse = z.infer<typeof QueueAdmitResultResponseSchema>;
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Acknowledge a `worker_heartbeat` (T11628). Mirrors `HeartbeatAck`.
|
|
433
|
+
*
|
|
434
|
+
* Deliberately carries only its `kind` — the ack's presence (correlated by id)
|
|
435
|
+
* is the signal that the watchdog recorded the beat and reset the child's
|
|
436
|
+
* deadline. Matches the Rust unit-struct wire shape `{ "kind": "heartbeat_ack" }`.
|
|
437
|
+
*/
|
|
438
|
+
export const HeartbeatAckResponseSchema = z
|
|
439
|
+
.object({
|
|
440
|
+
/** Tag discriminating this response variant. */
|
|
441
|
+
kind: z.literal('heartbeat_ack'),
|
|
442
|
+
})
|
|
443
|
+
.strict();
|
|
444
|
+
|
|
445
|
+
/** Heartbeat-ack response payload (inferred from {@link HeartbeatAckResponseSchema}). */
|
|
446
|
+
export type HeartbeatAckResponse = z.infer<typeof HeartbeatAckResponseSchema>;
|
|
447
|
+
|
|
337
448
|
/**
|
|
338
449
|
* An error response correlated to a request. Mirrors the v1.0
|
|
339
450
|
* `crate::ipc::ErrorResult` shape reused by the Rust `LeaseResponse::Error`
|
|
@@ -366,6 +477,8 @@ export const LeaseIpcResponseSchema = z.discriminatedUnion('kind', [
|
|
|
366
477
|
ToolGrantedResponseSchema,
|
|
367
478
|
LeaseRevokedResponseSchema,
|
|
368
479
|
ChildKilledUnresponsiveResponseSchema,
|
|
480
|
+
QueueAdmitResultResponseSchema,
|
|
481
|
+
HeartbeatAckResponseSchema,
|
|
369
482
|
LeaseErrorResponseSchema,
|
|
370
483
|
]);
|
|
371
484
|
|
|
@@ -444,6 +557,8 @@ export const LEASE_IPC_REQUEST_KINDS = [
|
|
|
444
557
|
'lease_renew',
|
|
445
558
|
'rate_check',
|
|
446
559
|
'tool_grant',
|
|
560
|
+
'queue_admit',
|
|
561
|
+
'worker_heartbeat',
|
|
447
562
|
] as const;
|
|
448
563
|
|
|
449
564
|
/**
|
|
@@ -458,6 +573,8 @@ export const LEASE_IPC_RESPONSE_KINDS = [
|
|
|
458
573
|
'tool_granted',
|
|
459
574
|
'lease_revoked',
|
|
460
575
|
'child_killed_unresponsive',
|
|
576
|
+
'queue_admit_result',
|
|
577
|
+
'heartbeat_ack',
|
|
461
578
|
'error',
|
|
462
579
|
] as const;
|
|
463
580
|
|