@constal/sdk 3.8.0 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -181,6 +181,32 @@ array. Declare its normal `needs` and `maxEffect` when loading uses Resources.
181
181
  source when supplied, and content hash. These are ordinary authorized Tool calls.
182
182
  Skill instructions do not grant additional authority.
183
183
 
184
+ ## Session schedules
185
+
186
+ Schedule a future invocation of the current Agent and Session:
187
+
188
+ ```ts
189
+ await ctx.schedule("check-pr-42", {
190
+ after: "10m",
191
+ input: { kind: "check-pr", repository: "acme/api", pullRequest: 42 },
192
+ });
193
+ ```
194
+
195
+ The current Run can finish. The Session retains the schedule and delivers the
196
+ unchanged input to a new Run when due. Use `every: "15m"` for a fixed cadence, or
197
+ `every: "day", at: "09:00", timezone: "America/Los_Angeles"` for a daily check.
198
+ Recurring schedules preserve missed occurrences by default; explicitly request
199
+ `missed: "coalesce"` when one check should cover an accumulated backlog.
200
+
201
+ `ctx.listSchedules()` pages the owning Session's schedules; calling `schedule()`
202
+ again with the same name replaces future work. `ctx.cancelSchedule(name)` stops
203
+ future work and identifies accepted or unresolved deliveries. Another bound
204
+ Agent can be selected with `agent` and an explicit `session`. Use `ctx.await()`
205
+ for sleeping within the current Run.
206
+
207
+ See [Schedule Agent follow-ups](https://constal.ai/docs/agents/schedules) for replay,
208
+ delivery, authority, and cancellation semantics.
209
+
184
210
  ## Model evaluation
185
211
 
186
212
  `ctx.evaluate` judges one state against typed questions through an evaluation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constal/sdk",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "description": "Public TypeScript SDK for authoring Constal agents, integrations, policies, channels, and credential providers",
5
5
  "keywords": [
6
6
  "constal",
package/publish/api.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@constal/sdk",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "exports": [
5
5
  "AGENT_UI_DEFAULTS",
6
6
  "Action",
@@ -147,6 +147,7 @@
147
147
  "EVALUATION_LIMITS",
148
148
  "EffectCeilingExceeded",
149
149
  "EffectClass",
150
+ "EmptyJoin",
150
151
  "EvalComparison",
151
152
  "EvalDivergence",
152
153
  "EvalMode",
@@ -213,6 +214,7 @@
213
214
  "InvocationHandle",
214
215
  "InvokableKind",
215
216
  "InvokeOpts",
217
+ "JoinOutcome",
216
218
  "JsonScalar",
217
219
  "JsonValue",
218
220
  "LabelRequest",
@@ -222,6 +224,7 @@
222
224
  "LeaseLost",
223
225
  "LedgerAddress",
224
226
  "LedgerEvent",
227
+ "ListSchedulesOptions",
225
228
  "LoadedSkill",
226
229
  "LocalResourceRef",
227
230
  "MCP_CLIENT_CAPABILITY",
@@ -333,6 +336,19 @@
333
336
  "SandboxReadFileResult",
334
337
  "SandboxWorkspace",
335
338
  "SandboxWriteFileResult",
339
+ "Schedule",
340
+ "ScheduleCancellation",
341
+ "ScheduleDuration",
342
+ "ScheduleMissed",
343
+ "ScheduleOccurrence",
344
+ "ScheduleOccurrencePage",
345
+ "ScheduleOptions",
346
+ "SchedulePage",
347
+ "ScheduleState",
348
+ "ScheduleTarget",
349
+ "ScheduleTiming",
350
+ "ScheduleTrigger",
351
+ "ScheduleWhen",
336
352
  "ScopedBindingKey",
337
353
  "ScopedCredentialRef",
338
354
  "ScopedMemoryStoreRef",
@@ -444,6 +460,7 @@
444
460
  "agentSetupRequirements",
445
461
  "agentUiBundleManifest",
446
462
  "agentUiDeclaration",
463
+ "all",
447
464
  "analyticsEvent",
448
465
  "approximateTokens",
449
466
  "authProvider",
@@ -522,6 +539,7 @@
522
539
  "parseResourceName",
523
540
  "policy",
524
541
  "policyName",
542
+ "race",
525
543
  "renderTrainingCompletion",
526
544
  "resolveBindingOwner",
527
545
  "resolveContainerImageSource",
@@ -543,6 +561,7 @@
543
561
  "scopedResourceRef",
544
562
  "scoreLevel",
545
563
  "scorerName",
564
+ "select",
546
565
  "selectableResourceLabels",
547
566
  "setupAwait",
548
567
  "setupCredentialReceipt",
@@ -1756,8 +1756,10 @@ interface SandboxWorkspace {
1756
1756
  exec(input: SandboxExecInput, opts?: InvokeOpts): InvocationHandle<SandboxCommandResult>;
1757
1757
  /** Admit ordinary exec without waiting for exit. Readiness is observable via I/O. */
1758
1758
  openProcess(input: SandboxExecInput, opts?: InvokeOpts): Promise<SandboxProcess>;
1759
- /** Resolve a named process already owned by this authenticated Run. */
1760
- resolveProcess(key: string, opts?: InvokeOpts): Promise<SandboxProcess | null>;
1759
+ /** Find an active process by key, or reattach by ID, including after exit. Both require this Run's ownership. */
1760
+ resolveProcess(selector: string | {
1761
+ id: string;
1762
+ }, opts?: InvokeOpts): Promise<SandboxProcess | null>;
1761
1763
  readFile(path: string, options?: SandboxReadFileOptions): Promise<SandboxReadFileResult>;
1762
1764
  writeFile(path: string, content: string, options?: {
1763
1765
  mode?: number;
@@ -1899,6 +1901,144 @@ declare function noulDecision(answer: NoulAnswer, threshold?: number): boolean;
1899
1901
  /** The nearest whole level of a Score answer. Use the expectation itself only for threshold comparisons. */
1900
1902
  declare function scoreLevel(answer: ScoreAnswer): number;
1901
1903
 
1904
+ /** A fixed elapsed duration, for example "10m", "1h", or "250ms". */
1905
+ type ScheduleDuration = string;
1906
+ type ScheduleMissed = "catch-up" | "coalesce";
1907
+ type ScheduleState = "active" | "completed" | "cancelled";
1908
+ type ScheduleWhen = {
1909
+ after: ScheduleDuration;
1910
+ at?: never;
1911
+ every?: never;
1912
+ timezone?: never;
1913
+ missed?: never;
1914
+ } | {
1915
+ at: string;
1916
+ after?: never;
1917
+ every?: never;
1918
+ timezone?: never;
1919
+ missed?: never;
1920
+ } | {
1921
+ every: ScheduleDuration;
1922
+ after?: never;
1923
+ at?: never;
1924
+ timezone?: never;
1925
+ missed?: ScheduleMissed;
1926
+ } | {
1927
+ every: "day";
1928
+ at: string;
1929
+ timezone: string;
1930
+ after?: never;
1931
+ missed?: ScheduleMissed;
1932
+ };
1933
+ /** Future invocations of this Agent, or an explicitly bound Agent in an explicit Session. */
1934
+ type ScheduleOptions<Input = unknown> = ScheduleWhen & {
1935
+ input: Input;
1936
+ /** Omission selects the current Agent and its normal Session routing. */
1937
+ agent?: CRN;
1938
+ /** Omission selects the current Session. Another Agent requires an explicit Session. */
1939
+ session?: string;
1940
+ };
1941
+ type ScheduleTiming = {
1942
+ kind: "after";
1943
+ milliseconds: number;
1944
+ } | {
1945
+ kind: "at";
1946
+ timestamp: number;
1947
+ } | {
1948
+ kind: "interval";
1949
+ milliseconds: number;
1950
+ } | {
1951
+ kind: "daily";
1952
+ time: string;
1953
+ timezone: string;
1954
+ };
1955
+ interface ScheduleTarget {
1956
+ agent: CRN;
1957
+ session: string;
1958
+ deployment: "session" | "pinned";
1959
+ resourceHash: string | null;
1960
+ }
1961
+ /** Provenance for a scheduled Run, separate from the caller's unchanged input. */
1962
+ interface ScheduleTrigger {
1963
+ occurrenceId: string;
1964
+ name: string;
1965
+ generation: number;
1966
+ scheduledAt: number;
1967
+ through: number;
1968
+ count: number;
1969
+ createdBy: {
1970
+ run: string;
1971
+ position: string;
1972
+ };
1973
+ owner: {
1974
+ tenant: string;
1975
+ namespace: string;
1976
+ agent: string;
1977
+ session: string;
1978
+ };
1979
+ target: ScheduleTarget;
1980
+ }
1981
+ interface ScheduleOccurrence {
1982
+ id: string;
1983
+ name: string;
1984
+ generation: number;
1985
+ /** First scheduled instant covered by this occurrence. */
1986
+ scheduledAt: number;
1987
+ /** Last scheduled instant covered; equal to scheduledAt unless coalesced. */
1988
+ through: number;
1989
+ count: number;
1990
+ state: "pending" | "delivering" | "accepted" | "complete" | "failed" | "cancelled" | "cancelling";
1991
+ target: ScheduleTarget;
1992
+ runId: string | null;
1993
+ error: string | null;
1994
+ resultRef: string | null;
1995
+ createdAt: number;
1996
+ updatedAt: number;
1997
+ startedAt: number | null;
1998
+ completedAt: number | null;
1999
+ }
2000
+ interface Schedule<Input = unknown> {
2001
+ name: string;
2002
+ generation: number;
2003
+ state: ScheduleState;
2004
+ timing: ScheduleTiming;
2005
+ missed: ScheduleMissed;
2006
+ target: ScheduleTarget;
2007
+ input: Input;
2008
+ inputRef: string;
2009
+ nextRunAt: number | null;
2010
+ createdAt: number;
2011
+ updatedAt: number;
2012
+ createdBy: {
2013
+ run: string;
2014
+ position: string;
2015
+ };
2016
+ /** Registration time of this definition generation; relative timing is anchored here. */
2017
+ registeredAt: number;
2018
+ lastOccurrence: ScheduleOccurrence | null;
2019
+ }
2020
+ interface ListSchedulesOptions {
2021
+ cursor?: string | null;
2022
+ name?: string;
2023
+ state?: ScheduleState;
2024
+ limit?: number;
2025
+ }
2026
+ interface SchedulePage {
2027
+ schedules: Schedule[];
2028
+ nextCursor: string | null;
2029
+ }
2030
+ interface ScheduleOccurrencePage {
2031
+ occurrences: ScheduleOccurrence[];
2032
+ nextCursor: string | null;
2033
+ }
2034
+ interface ScheduleCancellation {
2035
+ name: string;
2036
+ generation: number | null;
2037
+ cancelled: boolean;
2038
+ /** Handoffs that have crossed the delivery boundary; subsequent pages retain the same filter. */
2039
+ deliveries: ScheduleOccurrencePage;
2040
+ }
2041
+
1902
2042
  type Tier = "scratch" | "standard" | "audit";
1903
2043
  type Mode = "script" | "durable";
1904
2044
  type EffectClass = "read-only" | "idempotent" | "reconcilable" | "non-idempotent";
@@ -2491,7 +2631,7 @@ interface ReduceFact {
2491
2631
  stage: StageInfo;
2492
2632
  }
2493
2633
  type ScopeJournalKind = "turn" | "tool" | "step";
2494
- type LocalJournalKind = "clock" | "random" | "score" | "commit" | "await" | "spawn" | "map" | "reduce" | "view" | "page" | "truncate" | "cancel" | "capability";
2634
+ type LocalJournalKind = "clock" | "random" | "score" | "commit" | "await" | "spawn" | "map" | "reduce" | "view" | "page" | "truncate" | "cancel" | "capability" | "schedule";
2495
2635
  type JournalKind = ScopeJournalKind | LocalJournalKind | "invoke" | "send";
2496
2636
  /** Stable identity available to Agent code. Platform execution and deployment
2497
2637
  * metadata intentionally remain outside the public Agent context. */
@@ -2507,6 +2647,8 @@ interface RunInfo {
2507
2647
  crn: CRN;
2508
2648
  };
2509
2649
  mode: Mode;
2650
+ /** Present for an independently scheduled invocation; input remains unchanged. */
2651
+ schedule?: ScheduleTrigger;
2510
2652
  }
2511
2653
  interface CapabilityRef {
2512
2654
  readonly id: string;
@@ -2580,6 +2722,12 @@ interface Ctx {
2580
2722
  };
2581
2723
  commit<A>(artifact: A, opts?: CommitOpts): Promise<Fact<A>>;
2582
2724
  await<T>(label: string, opts?: AwaitOpts<T>): Handle<T>;
2725
+ /** Register or replace future invocations owned by this Session. Returns after durable registration. */
2726
+ schedule<Input>(name: string, options: ScheduleOptions<Input>): Promise<Schedule<Input>>;
2727
+ /** Cancel future occurrences; report accepted or unresolved handoffs without stopping their Runs. */
2728
+ cancelSchedule(name: string): Promise<ScheduleCancellation>;
2729
+ /** Inspect this Session's schedules through a journaled, paginated read. */
2730
+ listSchedules(options?: ListSchedulesOptions): Promise<SchedulePage>;
2583
2731
  spawn<T>(task: Task<T>, input: unknown, opts?: SpawnOpts): Handle<T>;
2584
2732
  map<I, O, R = never>(f: PartitionFn<I, O, R>, over: Over<I>, opts: MapOpts): Handle<MapFact>;
2585
2733
  reduce<I, O>(g: FoldFn<I, O> | SqlFold, over: Over<I>, opts?: ReduceOpts): Handle<ReduceFact>;
@@ -2623,6 +2771,24 @@ interface AgentDef<S = unknown> {
2623
2771
  }
2624
2772
  type Agent<S = unknown> = AgentDef<S>;
2625
2773
 
2774
+ declare class EmptyJoin extends Error {
2775
+ constructor(message: string);
2776
+ }
2777
+ type JoinOutcome<T> = {
2778
+ ok: true;
2779
+ value: T;
2780
+ } | {
2781
+ ok: false;
2782
+ error: unknown;
2783
+ };
2784
+ declare function select<T>(handles: Handle<T>[]): Promise<{
2785
+ index: number;
2786
+ } & JoinOutcome<T>>;
2787
+ declare function all<T>(handles: Handle<T>[]): Promise<T[]>;
2788
+ declare function race<T>(handles: Handle<T>[], opts?: {
2789
+ win: "first" | "first-success";
2790
+ }): Promise<T>;
2791
+
2626
2792
  interface SkillDescription {
2627
2793
  id: string;
2628
2794
  description?: string;
@@ -4457,5 +4623,5 @@ declare class SessionDeleted extends Error {
4457
4623
  constructor(session: string);
4458
4624
  }
4459
4625
 
4460
- export { AGENT_UI_DEFAULTS, AfterYield, ApiError, CONSTAL_API_CAPABILITY, CONSTAL_API_GET_KINDS, CONSTAL_API_MODEL_TOOL_DESCRIPTIONS, CONSTAL_API_OPERATIONS, CONSTAL_API_OPERATION_SCHEMAS, CONSTAL_API_QUERY_KINDS, CONSTAL_API_VERSION, CommitConflict, CommitGateRejected, CredentialRevoked, CredentialUnavailable, DirectNetworkDenied, EVALUATION_LIMITS, EffectCeilingExceeded, GateExhausted, IntegrationRequestNotSent, LeaseLost, MCP_CLIENT_CAPABILITY, MCP_PROTOCOL_VERSION, MEMORY_OPERATION_DECLARATIONS, MODEL_CHECKPOINT_IMPORT_CAPABILITY, MODEL_COMPLETION_CAPABILITY, MODEL_EVALUATION_CAPABILITY, McpClient, NondeterministicReplay, OutcomeUnknown, PolicyConstraintFailed, PolicyDecisionFailed, RESOURCE_CREDENTIAL_BINDING_SCHEMA, RESOURCE_KINDS, ResourceDisabled, ResourceInvalid, ResourceUnbound, RollbackTargetInvalid, SessionDeleted, SpawnCardinality, SwallowedYield, TRAINING_PROVIDER_CAPABILITY, TerminalIntegrationFailure, ToolUnavailable, UI_ASSET_CONTENT_TYPES, UI_BUNDLE_BOUNDS, UnknownTool, WEB_FETCH_ARGUMENT_SCHEMA, WEB_SEARCH_ARGUMENT_SCHEMA, action, actionPattern, agent, agentResourceBinding, agentSetupMetadata, agentSetupRequirements, agentUiBundleManifest, agentUiDeclaration, analyticsEvent, approximateTokens, authProvider, authProviderName, bindingName, bucketFor, canonicalJson, capabilityContractRef, casTool, channel, channelIngressRequest, channelIngressSource, channelSourceEvidence, channelSubscriptionRequest, channelTarget, checkpointArtifactRef, checkpointDeploymentRequest, checkpointImportMetadata, checkpointImportRequest, codeScorerIR, containerImageReference, containerImageSelection, containerImageSource, credentialEvidence, credentialInteractionAction, credentialInteractionEvent, credentialInteractionResult, credentialName, credentialProvider, credentialProviderConfigSchema, credentialProviderName, credentialProviderSetupMetadata, credentialRotationDefaults, credentialSetupState, customerTenantName, cutBatches, cutPartitions, datasetName, evaluateCodeScorer, evaluatePolicyDefinition, evaluationArguments, evaluationProtocolRequest, evaluationProtocolResult, gateway, gatewayModelOffer, gatewayPackageMetadata, hash, hashValue, immutableContainerImageReference, integrationEgressPolicy, invocationCredentialUses, labelSelector, matchesAction, matchesLabelSelector, matchesResource, mcpToolDescription, mcpToolResult, memoryStoreBinding, modelAdvertisedPricing, modelControls, modelGatewayBinding, modelGatewayEndpoint, modelGenerationOptions, modelLimit, modelMessages, modelPrompt, modelProtocolRequest, modelProtocolResult, murmur3_32, normalizeModelGatewayConfig, normalizeSandboxNetworkPolicy, normalizeSandboxWorkspacePath, noulDecision, opTool, opTools, parseResourceName, policy, policyName, renderTrainingCompletion, resolveBindingOwner, resolveContainerImageSource, resolveGatewayEgress, resolveResourceDependencyRef, resourceContractRef, resourceCredentialBinding, resourceDependencyRef, resourceLabelMap, resourceName, resourceNeed, resourcePattern, resourceSelector, resourceTools, sandboxControls, sandboxLimit, scopedBindingKey, scopedCredentialRef, scopedResourceRef, scoreLevel, scorerName, selectableResourceLabels, setupAwait, setupCredentialReceipt, setupPanelProviderIsCrn, setupScreen, setupScreenView, setupSubmission, sha256Hex, skills, stageOutput, startTrainingRequest, subtask, tableDescribe, tableQuery, trainingProvider, trainingProviderMetadata, trainingRecipe, uiAssetContentType, uiBundle, uiBundleManifest, uiLimit, uiName, validateBatchSpec, validateFoldFn, validateJsonSchema, validateJsonSchemaDefinition, validatePartitionFn, validatePartitionSpec, validateStageOutputSpec, validateTool, validateView, webFetch, webSearch };
4461
- export type { Action, ActionPattern, Actor, AdmissionLimitConstraint, AdmissionLimitInput, AdmissionLimitScope, AdmissionLimitWindow, Agent, AgentCredentialSetupRequirement, AgentDef, AgentDeliveryReceipt, AgentDeployPolicy, AgentResultDelivery, AgentSendOpts, AgentSetupMetadata, AgentSetupRequirement, AgentSetupWorkflow, AgentUiDeclaration, AnalyticsClient, AnalyticsDimensionValue, AnalyticsEventDefinition, AnalyticsIntent, AnalyticsValues, AuthProvider, AuthProviderCRN, AuthProviderContext, AuthProviderRequest, AuthProviderResult, AwaitOpts, AwaitPresentation, BatchSpec, BindingCRN, BindingOwnerContext, BindingOwnerScope, BoundOperation, BoundResourceCapabilities, BranchRef, CRN, CRNKind, CanonicalEvent, CanonicalEventDraft, CapabilityContractRef, CapabilityGrant, CapabilityRef, CaptureCaseRequest, CaseRow, CatalogTool, Channel, ChannelContext, ChannelFailure, ChannelIngressEvent, ChannelIngressSource, ChannelMessage, ChannelProtocol, ChannelReceiveResult, ChannelRequest, ChannelResponse, ChannelSourceEvidence, ChannelSubscriptionRequest, ChannelTarget, CheckpointDeploymentRequest, CheckpointImportMetadata, CheckpointImportRequest, ChoiceAnswer, ChoiceQuestion, CodeScoreResult, CodeScorerIR, CodeScorerRule, CommitOpts, CompareSuitesRequest, Compensation, ConnectionCancelRequest, ConnectionIdentity, ConnectionOperation, ConnectionRecoveryRequest, ConnectionRecoveryResult, ConnectionRequest, ConnectionUsageReport, ConstalApiApplyRequest, ConstalApiChangePlan, ConstalApiChangePlanRef, ConstalApiChangePlanRequest, ConstalApiChangeReceipt, ConstalApiOperationReceipt, ContainerImageReference, ContainerImageSelection, ContainerImageSource, ContainerRegistryRequest, ContainerRegistryResponse, ControlEvent, Cost, CreateSandboxImageOptions, CreateSandboxOptions, CredentialCRN, CredentialDestroyResult, CredentialEvidence, CredentialInteractionAction, CredentialInteractionAdvanceRequest, CredentialInteractionEvent, CredentialInteractionPrimaryAction, CredentialInteractionProof, CredentialInteractionResult, CredentialInteractionStartRequest, CredentialMaterialRequest, CredentialMintRequest, CredentialMintResult, CredentialProviderCRN, CredentialProviderContext, CredentialProviderCredentialSlotSetup, CredentialProviderDefinition, CredentialProviderPackage, CredentialProviderPackageMetadata, CredentialProviderSecretInput, CredentialProviderSetupMetadata, CredentialSetupState, CredentialVerifyResult, Ctx, CustomerTenantCRN, DataManifest, DatasetCRN, DatasetDraft, DatasetRef, DelegatedGrant, DelegationCeiling, DeliveryMode, DeliveryReceipt, DispatchResult, EffectClass, EvalComparison, EvalDivergence, EvalMode, EvalSubject, EvalSubjectSource, EvaluationAnswer, EvaluationAnswerFor, EvaluationAnswers, EvaluationEntry, EvaluationInvocationArgs, EvaluationInvocationResult, EvaluationProtocol, EvaluationQuestion, EvaluationQuestions, EvaluationRecord, EvaluationSpec, EventBase, Fact, FactRef, FileEntry, FixedMemoryStoreRef, FixedModelGatewayRef, FoldFn, GateEvidence, GateResult, GateVerdict, GatewayCancelRequest, GatewayConfigEgressBinding, GatewayContext, GatewayCredentialSlotSetup, GatewayDefinition, GatewayDiscoverySetup, GatewayModelOffer, GatewayOperation, GatewayPackage, GatewayPackageMetadata, GatewayRecoveryRequest, GatewayRecoveryResult, GatewayRequest, GovernanceContractRef, Handle, HandleOutcome, Hash, HistoryView, HmacVerification, IgnoredChannelEvent, IngressRequest, IngressTarget, IntegrationArtifactEgressRequest, IntegrationArtifactEgressResponse, IntegrationAttachment, IntegrationContext, IntegrationEgressPolicy, IntegrationEgressRequest, IntegrationEgressResponse, IntegrationEgressRule, IntegrationLifecycle, IntegrationReleaseContext, IntegrationSecret, IntegrationState, InvocationCredentialUse, InvocationHandle, InvokableKind, InvokeOpts, JsonScalar, JsonValue, LabelRequest, LabelSelector, LabelSelectorOperator, LabelSelectorRequirement, LedgerAddress, LedgerEvent, LoadedSkill, LocalResourceRef, ManifestIndexPage, MapFact, MapOpts, McpClientOptions, McpClientState, McpMessageTransport, MemoryDeleteArgs, MemoryGetArgs, MemoryRecord, MemoryRememberArgs, MemorySearchArgs, MemorySearchHit, MemoryStoreBinding, Mode, ModelAdvertisedPricing, ModelCompletion, ModelCredentialHeader, ModelGatewayBinding, ModelGatewayConfig, ModelGatewayProtocol, ModelGenerationOptions, ModelGovernanceControls, ModelGovernanceMeter, ModelHistoryMessage, ModelInvocationArgs, ModelInvocationResult, ModelTechnicalCapabilities, ModelTool, NormalizedModelGatewayConfig, NoulAnswer, NoulQuestion, Out, Over, PartitionFn, PartitionSpec, Partitioning, PolicyCRN, PolicyConstraint, PolicyContextValue, PolicyDefinition, PolicyInput, PolicyInvocationOrigin, PolicyOutcome, Principal, PrincipalKind, Provenance, RawModelProtocol, Recovery, ReduceFact, ReduceOpts, Ref, RequestLabelRequest, ResourceContractRef, ResourceControlsConstraint, ResourceCredentialBinding, ResourceDependencyRef, ResourceKind, ResourceName, ResourceNameParts, ResourceNeed, ResourcePattern, ResourceSelector, RollbackReport, RunIdentityView, RunInfo, RunStatusDetail, RunSuiteRequest, Sandbox, SandboxCommandCollectionError, SandboxCommandExecution, SandboxCommandResult, SandboxExecInput, SandboxFileResult, SandboxGovernanceControls, SandboxGovernanceMeter, SandboxImage, SandboxMutationResult, SandboxNetworkMode, SandboxNetworkPolicy, SandboxPool, SandboxProcess, SandboxProcessCredentials, SandboxProcessIoOperation, SandboxProcessOperation, SandboxProcessReadInput, SandboxProcessReadResult, SandboxProcessStatus, SandboxProcessWriteResult, SandboxReadFileOptions, SandboxReadFileResult, SandboxWorkspace, SandboxWriteFileResult, ScopedBindingKey, ScopedCredentialRef, ScopedMemoryStoreRef, ScopedModelGatewayRef, ScopedResourceRef, ScoreAnswer, ScoreQuestion, ScoreRequest, ScorerApplies, ScorerCRN, ScorerDef, ScorerEvaluation, ScorerKind, ScorerRef, ScorerVerdictIntent, SetEvalBaselineRequest, SetupAction, SetupCredentialCandidate, SetupCredentialInteractionPanel, SetupCredentialReceipt, SetupFormPanel, SetupPanel, SetupProgressPanel, SetupReviewPanel, SetupScreen, SetupStepStatus, SetupStepSummary, SetupSubmission, SetupTerminalPanel, SetupWorkflowStatus, Skill, SkillDescription, SkillLibrary, SkillSource, SortField, SpawnAttenuation, SpawnBudget, SpawnOpts, SqlFold, StageInfo, StageOutputSpec, StartTrainingRequest, SteerEvent, SuiteFact, TableAggregate, TableDescribeArgs, TableFilter, TableFilterOperation, TableOrder, TableQueryArgs, TableQueryPlan, TableQueryResult, TableScalar, TableSnapshotDescription, Task, Tier, Tool, ToolCallRecord, TrainingJobFact, TrainingJobReference, TrainingJobState, TrainingJobStatus, TrainingMethod, TrainingModelOffer, TrainingProviderDefinition, TrainingProviderMetadata, TrainingProviderPin, TrainingRecipe, TrainingResumePoint, TrainingUsageUnits, TurnDraft, TurnGate, TurnRecord, TurnSpec, UiAccess, UiBundle, UiBundleManifest, UiCRN, UiCapability, UiExecution, UiGovernanceMeter, UiHandler, UiResource, UiRuntimeContext, UiSource, UiSqlResult, UiState, UpstreamPayer, Verdict, VerdictSamplingMode, ViewDef, WaitResolvedEvent };
4626
+ export { AGENT_UI_DEFAULTS, AfterYield, ApiError, CONSTAL_API_CAPABILITY, CONSTAL_API_GET_KINDS, CONSTAL_API_MODEL_TOOL_DESCRIPTIONS, CONSTAL_API_OPERATIONS, CONSTAL_API_OPERATION_SCHEMAS, CONSTAL_API_QUERY_KINDS, CONSTAL_API_VERSION, CommitConflict, CommitGateRejected, CredentialRevoked, CredentialUnavailable, DirectNetworkDenied, EVALUATION_LIMITS, EffectCeilingExceeded, EmptyJoin, GateExhausted, IntegrationRequestNotSent, LeaseLost, MCP_CLIENT_CAPABILITY, MCP_PROTOCOL_VERSION, MEMORY_OPERATION_DECLARATIONS, MODEL_CHECKPOINT_IMPORT_CAPABILITY, MODEL_COMPLETION_CAPABILITY, MODEL_EVALUATION_CAPABILITY, McpClient, NondeterministicReplay, OutcomeUnknown, PolicyConstraintFailed, PolicyDecisionFailed, RESOURCE_CREDENTIAL_BINDING_SCHEMA, RESOURCE_KINDS, ResourceDisabled, ResourceInvalid, ResourceUnbound, RollbackTargetInvalid, SessionDeleted, SpawnCardinality, SwallowedYield, TRAINING_PROVIDER_CAPABILITY, TerminalIntegrationFailure, ToolUnavailable, UI_ASSET_CONTENT_TYPES, UI_BUNDLE_BOUNDS, UnknownTool, WEB_FETCH_ARGUMENT_SCHEMA, WEB_SEARCH_ARGUMENT_SCHEMA, action, actionPattern, agent, agentResourceBinding, agentSetupMetadata, agentSetupRequirements, agentUiBundleManifest, agentUiDeclaration, all, analyticsEvent, approximateTokens, authProvider, authProviderName, bindingName, bucketFor, canonicalJson, capabilityContractRef, casTool, channel, channelIngressRequest, channelIngressSource, channelSourceEvidence, channelSubscriptionRequest, channelTarget, checkpointArtifactRef, checkpointDeploymentRequest, checkpointImportMetadata, checkpointImportRequest, codeScorerIR, containerImageReference, containerImageSelection, containerImageSource, credentialEvidence, credentialInteractionAction, credentialInteractionEvent, credentialInteractionResult, credentialName, credentialProvider, credentialProviderConfigSchema, credentialProviderName, credentialProviderSetupMetadata, credentialRotationDefaults, credentialSetupState, customerTenantName, cutBatches, cutPartitions, datasetName, evaluateCodeScorer, evaluatePolicyDefinition, evaluationArguments, evaluationProtocolRequest, evaluationProtocolResult, gateway, gatewayModelOffer, gatewayPackageMetadata, hash, hashValue, immutableContainerImageReference, integrationEgressPolicy, invocationCredentialUses, labelSelector, matchesAction, matchesLabelSelector, matchesResource, mcpToolDescription, mcpToolResult, memoryStoreBinding, modelAdvertisedPricing, modelControls, modelGatewayBinding, modelGatewayEndpoint, modelGenerationOptions, modelLimit, modelMessages, modelPrompt, modelProtocolRequest, modelProtocolResult, murmur3_32, normalizeModelGatewayConfig, normalizeSandboxNetworkPolicy, normalizeSandboxWorkspacePath, noulDecision, opTool, opTools, parseResourceName, policy, policyName, race, renderTrainingCompletion, resolveBindingOwner, resolveContainerImageSource, resolveGatewayEgress, resolveResourceDependencyRef, resourceContractRef, resourceCredentialBinding, resourceDependencyRef, resourceLabelMap, resourceName, resourceNeed, resourcePattern, resourceSelector, resourceTools, sandboxControls, sandboxLimit, scopedBindingKey, scopedCredentialRef, scopedResourceRef, scoreLevel, scorerName, select, selectableResourceLabels, setupAwait, setupCredentialReceipt, setupPanelProviderIsCrn, setupScreen, setupScreenView, setupSubmission, sha256Hex, skills, stageOutput, startTrainingRequest, subtask, tableDescribe, tableQuery, trainingProvider, trainingProviderMetadata, trainingRecipe, uiAssetContentType, uiBundle, uiBundleManifest, uiLimit, uiName, validateBatchSpec, validateFoldFn, validateJsonSchema, validateJsonSchemaDefinition, validatePartitionFn, validatePartitionSpec, validateStageOutputSpec, validateTool, validateView, webFetch, webSearch };
4627
+ export type { Action, ActionPattern, Actor, AdmissionLimitConstraint, AdmissionLimitInput, AdmissionLimitScope, AdmissionLimitWindow, Agent, AgentCredentialSetupRequirement, AgentDef, AgentDeliveryReceipt, AgentDeployPolicy, AgentResultDelivery, AgentSendOpts, AgentSetupMetadata, AgentSetupRequirement, AgentSetupWorkflow, AgentUiDeclaration, AnalyticsClient, AnalyticsDimensionValue, AnalyticsEventDefinition, AnalyticsIntent, AnalyticsValues, AuthProvider, AuthProviderCRN, AuthProviderContext, AuthProviderRequest, AuthProviderResult, AwaitOpts, AwaitPresentation, BatchSpec, BindingCRN, BindingOwnerContext, BindingOwnerScope, BoundOperation, BoundResourceCapabilities, BranchRef, CRN, CRNKind, CanonicalEvent, CanonicalEventDraft, CapabilityContractRef, CapabilityGrant, CapabilityRef, CaptureCaseRequest, CaseRow, CatalogTool, Channel, ChannelContext, ChannelFailure, ChannelIngressEvent, ChannelIngressSource, ChannelMessage, ChannelProtocol, ChannelReceiveResult, ChannelRequest, ChannelResponse, ChannelSourceEvidence, ChannelSubscriptionRequest, ChannelTarget, CheckpointDeploymentRequest, CheckpointImportMetadata, CheckpointImportRequest, ChoiceAnswer, ChoiceQuestion, CodeScoreResult, CodeScorerIR, CodeScorerRule, CommitOpts, CompareSuitesRequest, Compensation, ConnectionCancelRequest, ConnectionIdentity, ConnectionOperation, ConnectionRecoveryRequest, ConnectionRecoveryResult, ConnectionRequest, ConnectionUsageReport, ConstalApiApplyRequest, ConstalApiChangePlan, ConstalApiChangePlanRef, ConstalApiChangePlanRequest, ConstalApiChangeReceipt, ConstalApiOperationReceipt, ContainerImageReference, ContainerImageSelection, ContainerImageSource, ContainerRegistryRequest, ContainerRegistryResponse, ControlEvent, Cost, CreateSandboxImageOptions, CreateSandboxOptions, CredentialCRN, CredentialDestroyResult, CredentialEvidence, CredentialInteractionAction, CredentialInteractionAdvanceRequest, CredentialInteractionEvent, CredentialInteractionPrimaryAction, CredentialInteractionProof, CredentialInteractionResult, CredentialInteractionStartRequest, CredentialMaterialRequest, CredentialMintRequest, CredentialMintResult, CredentialProviderCRN, CredentialProviderContext, CredentialProviderCredentialSlotSetup, CredentialProviderDefinition, CredentialProviderPackage, CredentialProviderPackageMetadata, CredentialProviderSecretInput, CredentialProviderSetupMetadata, CredentialSetupState, CredentialVerifyResult, Ctx, CustomerTenantCRN, DataManifest, DatasetCRN, DatasetDraft, DatasetRef, DelegatedGrant, DelegationCeiling, DeliveryMode, DeliveryReceipt, DispatchResult, EffectClass, EvalComparison, EvalDivergence, EvalMode, EvalSubject, EvalSubjectSource, EvaluationAnswer, EvaluationAnswerFor, EvaluationAnswers, EvaluationEntry, EvaluationInvocationArgs, EvaluationInvocationResult, EvaluationProtocol, EvaluationQuestion, EvaluationQuestions, EvaluationRecord, EvaluationSpec, EventBase, Fact, FactRef, FileEntry, FixedMemoryStoreRef, FixedModelGatewayRef, FoldFn, GateEvidence, GateResult, GateVerdict, GatewayCancelRequest, GatewayConfigEgressBinding, GatewayContext, GatewayCredentialSlotSetup, GatewayDefinition, GatewayDiscoverySetup, GatewayModelOffer, GatewayOperation, GatewayPackage, GatewayPackageMetadata, GatewayRecoveryRequest, GatewayRecoveryResult, GatewayRequest, GovernanceContractRef, Handle, HandleOutcome, Hash, HistoryView, HmacVerification, IgnoredChannelEvent, IngressRequest, IngressTarget, IntegrationArtifactEgressRequest, IntegrationArtifactEgressResponse, IntegrationAttachment, IntegrationContext, IntegrationEgressPolicy, IntegrationEgressRequest, IntegrationEgressResponse, IntegrationEgressRule, IntegrationLifecycle, IntegrationReleaseContext, IntegrationSecret, IntegrationState, InvocationCredentialUse, InvocationHandle, InvokableKind, InvokeOpts, JoinOutcome, JsonScalar, JsonValue, LabelRequest, LabelSelector, LabelSelectorOperator, LabelSelectorRequirement, LedgerAddress, LedgerEvent, ListSchedulesOptions, LoadedSkill, LocalResourceRef, ManifestIndexPage, MapFact, MapOpts, McpClientOptions, McpClientState, McpMessageTransport, MemoryDeleteArgs, MemoryGetArgs, MemoryRecord, MemoryRememberArgs, MemorySearchArgs, MemorySearchHit, MemoryStoreBinding, Mode, ModelAdvertisedPricing, ModelCompletion, ModelCredentialHeader, ModelGatewayBinding, ModelGatewayConfig, ModelGatewayProtocol, ModelGenerationOptions, ModelGovernanceControls, ModelGovernanceMeter, ModelHistoryMessage, ModelInvocationArgs, ModelInvocationResult, ModelTechnicalCapabilities, ModelTool, NormalizedModelGatewayConfig, NoulAnswer, NoulQuestion, Out, Over, PartitionFn, PartitionSpec, Partitioning, PolicyCRN, PolicyConstraint, PolicyContextValue, PolicyDefinition, PolicyInput, PolicyInvocationOrigin, PolicyOutcome, Principal, PrincipalKind, Provenance, RawModelProtocol, Recovery, ReduceFact, ReduceOpts, Ref, RequestLabelRequest, ResourceContractRef, ResourceControlsConstraint, ResourceCredentialBinding, ResourceDependencyRef, ResourceKind, ResourceName, ResourceNameParts, ResourceNeed, ResourcePattern, ResourceSelector, RollbackReport, RunIdentityView, RunInfo, RunStatusDetail, RunSuiteRequest, Sandbox, SandboxCommandCollectionError, SandboxCommandExecution, SandboxCommandResult, SandboxExecInput, SandboxFileResult, SandboxGovernanceControls, SandboxGovernanceMeter, SandboxImage, SandboxMutationResult, SandboxNetworkMode, SandboxNetworkPolicy, SandboxPool, SandboxProcess, SandboxProcessCredentials, SandboxProcessIoOperation, SandboxProcessOperation, SandboxProcessReadInput, SandboxProcessReadResult, SandboxProcessStatus, SandboxProcessWriteResult, SandboxReadFileOptions, SandboxReadFileResult, SandboxWorkspace, SandboxWriteFileResult, Schedule, ScheduleCancellation, ScheduleDuration, ScheduleMissed, ScheduleOccurrence, ScheduleOccurrencePage, ScheduleOptions, SchedulePage, ScheduleState, ScheduleTarget, ScheduleTiming, ScheduleTrigger, ScheduleWhen, ScopedBindingKey, ScopedCredentialRef, ScopedMemoryStoreRef, ScopedModelGatewayRef, ScopedResourceRef, ScoreAnswer, ScoreQuestion, ScoreRequest, ScorerApplies, ScorerCRN, ScorerDef, ScorerEvaluation, ScorerKind, ScorerRef, ScorerVerdictIntent, SetEvalBaselineRequest, SetupAction, SetupCredentialCandidate, SetupCredentialInteractionPanel, SetupCredentialReceipt, SetupFormPanel, SetupPanel, SetupProgressPanel, SetupReviewPanel, SetupScreen, SetupStepStatus, SetupStepSummary, SetupSubmission, SetupTerminalPanel, SetupWorkflowStatus, Skill, SkillDescription, SkillLibrary, SkillSource, SortField, SpawnAttenuation, SpawnBudget, SpawnOpts, SqlFold, StageInfo, StageOutputSpec, StartTrainingRequest, SteerEvent, SuiteFact, TableAggregate, TableDescribeArgs, TableFilter, TableFilterOperation, TableOrder, TableQueryArgs, TableQueryPlan, TableQueryResult, TableScalar, TableSnapshotDescription, Task, Tier, Tool, ToolCallRecord, TrainingJobFact, TrainingJobReference, TrainingJobState, TrainingJobStatus, TrainingMethod, TrainingModelOffer, TrainingProviderDefinition, TrainingProviderMetadata, TrainingProviderPin, TrainingRecipe, TrainingResumePoint, TrainingUsageUnits, TurnDraft, TurnGate, TurnRecord, TurnSpec, UiAccess, UiBundle, UiBundleManifest, UiCRN, UiCapability, UiExecution, UiGovernanceMeter, UiHandler, UiResource, UiRuntimeContext, UiSource, UiSqlResult, UiState, UpstreamPayer, Verdict, VerdictSamplingMode, ViewDef, WaitResolvedEvent };
package/publish/index.js CHANGED
@@ -1,3 +1,72 @@
1
+ // packages/sdk/src/joins.ts
2
+ var EmptyJoin = class extends Error {
3
+ constructor(message2) {
4
+ super(message2);
5
+ this.name = "EmptyJoin";
6
+ }
7
+ };
8
+ var settled = (handle) => Promise.resolve(handle.then(
9
+ () => void 0,
10
+ (error) => {
11
+ if (error && typeof error === "object" && ("durableSuspension" in error && error.durableSuspension === true || "durableInterruption" in error && error.durableInterruption === true)) throw error;
12
+ return void 0;
13
+ }
14
+ ));
15
+ var bySeq = (handles) => handles.map((handle, index) => ({ handle, index })).filter((item) => item.handle.resolved).sort((left, right) => left.handle.seq - right.handle.seq);
16
+ async function admit(handles) {
17
+ await Promise.all(handles.map(async (handle) => {
18
+ const start = handle.start;
19
+ if (!start) return;
20
+ try {
21
+ await start.call(handle);
22
+ } catch (error) {
23
+ if (!handle.resolved) throw error;
24
+ }
25
+ }));
26
+ }
27
+ async function outcome(handle) {
28
+ try {
29
+ return { ok: true, value: await handle };
30
+ } catch (error) {
31
+ if (error && typeof error === "object" && ("durableSuspension" in error && error.durableSuspension === true || "durableInterruption" in error && error.durableInterruption === true)) throw error;
32
+ return { ok: false, error };
33
+ }
34
+ }
35
+ async function select(handles) {
36
+ if (handles.length === 0) throw new EmptyJoin("select: no handles");
37
+ await admit(handles);
38
+ const first = bySeq(handles)[0];
39
+ if (first) {
40
+ return { index: first.index, ...await outcome(first.handle) };
41
+ }
42
+ await Promise.race(handles.map(settled));
43
+ return select(handles);
44
+ }
45
+ async function all(handles) {
46
+ await admit(handles);
47
+ if (handles.every((handle) => handle.resolved)) return Promise.all(handles);
48
+ await Promise.all(handles.filter((handle) => !handle.resolved).map(settled));
49
+ return all(handles);
50
+ }
51
+ async function race(handles, opts = { win: "first" }) {
52
+ if (handles.length === 0) throw new EmptyJoin("race: no handles");
53
+ await admit(handles);
54
+ const failures = [];
55
+ for (const { handle: winner } of bySeq(handles)) {
56
+ const result = await outcome(winner);
57
+ if (!result.ok && opts.win === "first-success") {
58
+ failures.push(result.error);
59
+ continue;
60
+ }
61
+ for (const handle of handles) if (handle !== winner && !handle.resolved) await handle.cancel();
62
+ if (!result.ok) throw result.error;
63
+ return result.value;
64
+ }
65
+ if (handles.every((handle) => handle.resolved)) throw new AggregateError(failures, "race: every candidate failed");
66
+ await Promise.race(handles.filter((handle) => !handle.resolved).map(settled));
67
+ return race(handles, opts);
68
+ }
69
+
1
70
  // packages/sdk/src/hash.ts
2
71
  var encoder = new TextEncoder();
3
72
  function canonicalNumber(value) {
@@ -1049,9 +1118,9 @@ function normalizeDomains(values) {
1049
1118
  }
1050
1119
  return `${wildcard2 ? "*." : ""}${hostname}`;
1051
1120
  }).sort();
1052
- return [...new Set(domains)].filter((domain, index, all) => {
1121
+ return [...new Set(domains)].filter((domain, index, all2) => {
1053
1122
  const bare = domain.startsWith("*.") ? domain.slice(2) : domain;
1054
- return !all.some((candidate, candidateIndex) => candidateIndex !== index && candidate.startsWith("*.") && (bare === candidate.slice(2) || bare.endsWith(`.${candidate.slice(2)}`)));
1123
+ return !all2.some((candidate, candidateIndex) => candidateIndex !== index && candidate.startsWith("*.") && (bare === candidate.slice(2) || bare.endsWith(`.${candidate.slice(2)}`)));
1055
1124
  });
1056
1125
  }
1057
1126
  function normalizeSandboxNetworkPolicy(value, options = {}) {
@@ -4342,6 +4411,7 @@ export {
4342
4411
  DirectNetworkDenied,
4343
4412
  EVALUATION_LIMITS,
4344
4413
  EffectCeilingExceeded,
4414
+ EmptyJoin,
4345
4415
  GateExhausted,
4346
4416
  IntegrationRequestNotSent,
4347
4417
  LeaseLost,
@@ -4381,6 +4451,7 @@ export {
4381
4451
  agentSetupRequirements,
4382
4452
  agentUiBundleManifest,
4383
4453
  agentUiDeclaration,
4454
+ all,
4384
4455
  analyticsEvent,
4385
4456
  approximateTokens,
4386
4457
  authProvider,
@@ -4459,6 +4530,7 @@ export {
4459
4530
  parseResourceName,
4460
4531
  policy,
4461
4532
  policyName,
4533
+ race,
4462
4534
  renderTrainingCompletion,
4463
4535
  resolveBindingOwner,
4464
4536
  resolveContainerImageSource,
@@ -4480,6 +4552,7 @@ export {
4480
4552
  scopedResourceRef,
4481
4553
  scoreLevel,
4482
4554
  scorerName,
4555
+ select,
4483
4556
  selectableResourceLabels,
4484
4557
  setupAwait,
4485
4558
  setupCredentialReceipt,