@constal/sdk 6.15.0 → 6.16.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/package.json +5 -1
- package/publish/api.json +18 -1
- package/publish/index.d.ts +96 -2
- package/publish/index.js +176 -42
- package/publish/sandbox-terminal.d.ts +96 -0
- package/publish/sandbox-terminal.js +135 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constal/sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.16.0",
|
|
4
4
|
"description": "Public TypeScript SDK for authoring Constal agents, integrations, policies, channels, and credential providers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"constal",
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
"./chat-format": {
|
|
24
24
|
"types": "./publish/chat-format.d.ts",
|
|
25
25
|
"import": "./publish/chat-format.js"
|
|
26
|
+
},
|
|
27
|
+
"./sandbox-terminal": {
|
|
28
|
+
"types": "./publish/sandbox-terminal.d.ts",
|
|
29
|
+
"import": "./publish/sandbox-terminal.js"
|
|
26
30
|
}
|
|
27
31
|
},
|
|
28
32
|
"files": [
|
package/publish/api.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"package": "@constal/sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.16.0",
|
|
4
4
|
"exports": [
|
|
5
5
|
"AGENT_UI_DEFAULTS",
|
|
6
6
|
"Action",
|
|
@@ -355,6 +355,11 @@
|
|
|
355
355
|
"SANDBOX_POOL_OPERATIONS",
|
|
356
356
|
"SANDBOX_PROVIDER_FAILURE_CLASSES",
|
|
357
357
|
"SANDBOX_PROVIDER_UNAVAILABLE",
|
|
358
|
+
"SANDBOX_TERMINAL_CHANNELS",
|
|
359
|
+
"SANDBOX_TERMINAL_EXIT_CODE_CAUSE",
|
|
360
|
+
"SANDBOX_TERMINAL_NONZERO_EXIT",
|
|
361
|
+
"SANDBOX_TERMINAL_PROTOCOL",
|
|
362
|
+
"SANDBOX_TERMINAL_TERM",
|
|
358
363
|
"Sandbox",
|
|
359
364
|
"SandboxCapabilities",
|
|
360
365
|
"SandboxCreateRequest",
|
|
@@ -396,6 +401,13 @@
|
|
|
396
401
|
"SandboxSnapshot",
|
|
397
402
|
"SandboxSnapshotCapabilities",
|
|
398
403
|
"SandboxState",
|
|
404
|
+
"SandboxTerminalChannel",
|
|
405
|
+
"SandboxTerminalClosable",
|
|
406
|
+
"SandboxTerminalMessage",
|
|
407
|
+
"SandboxTerminalSize",
|
|
408
|
+
"SandboxTerminalStatus",
|
|
409
|
+
"SandboxTerminalStatusCause",
|
|
410
|
+
"SandboxTerminalStream",
|
|
399
411
|
"SandboxUpdateRequest",
|
|
400
412
|
"SandboxUsageEvent",
|
|
401
413
|
"SandboxUsageItem",
|
|
@@ -595,6 +607,8 @@
|
|
|
595
607
|
"cutPartitions",
|
|
596
608
|
"dataShareEarningMicroUsd",
|
|
597
609
|
"datasetName",
|
|
610
|
+
"decodeSandboxTerminalMessage",
|
|
611
|
+
"encodeSandboxTerminalMessage",
|
|
598
612
|
"evaluateCodeScorer",
|
|
599
613
|
"evaluatePolicyDefinition",
|
|
600
614
|
"evaluationArguments",
|
|
@@ -661,6 +675,9 @@
|
|
|
661
675
|
"sandboxEgressHostMatches",
|
|
662
676
|
"sandboxLimit",
|
|
663
677
|
"sandboxProviderUnavailable",
|
|
678
|
+
"sandboxTerminalExitCode",
|
|
679
|
+
"sandboxTerminalExited",
|
|
680
|
+
"sandboxTerminalFailed",
|
|
664
681
|
"scopedBindingKey",
|
|
665
682
|
"scopedCredentialRef",
|
|
666
683
|
"scopedResourceRef",
|
package/publish/index.d.ts
CHANGED
|
@@ -5668,6 +5668,100 @@ declare function credentialProviderSetupMetadata(value: unknown, slots: string[]
|
|
|
5668
5668
|
/** Defines and validates a Credential Provider package. */
|
|
5669
5669
|
declare function credentialProvider<C>(definition: CredentialProviderDefinition<C>): CredentialProviderPackage<C>;
|
|
5670
5670
|
|
|
5671
|
+
/**
|
|
5672
|
+
* `@constal/sdk/sandbox-terminal`: a sandbox's terminal on the wire, the one definition every hop and client uses
|
|
5673
|
+
* (docs/sandbox-terminal.md). A terminal is a WebSocket that speaks Kubernetes' `v5.channel.k8s.io`, the protocol
|
|
5674
|
+
* client-go's WebSocket executor speaks: each binary message is one channel byte and its payload.
|
|
5675
|
+
*
|
|
5676
|
+
* - 0, stdin: the client's input to the terminal, raw bytes.
|
|
5677
|
+
* - 1, stdout: the terminal's output, raw bytes, escapes and all.
|
|
5678
|
+
* - 2, stderr: unused under a TTY, which merges it into stdout.
|
|
5679
|
+
* - 3, error: the session's last message, a Kubernetes Status (SandboxTerminalStatus): Success, Failure with reason
|
|
5680
|
+
* `NonZeroExitCode` and an `ExitCode` cause, or Failure with the door's reason and the provider's words.
|
|
5681
|
+
* - 4, resize: the client's terminal size, `{"Width":<cols>,"Height":<rows>}`, each a uint16 (Kubernetes' TerminalSize).
|
|
5682
|
+
* - 255, close: `[255, <channel>]`, a half-close of one stream. It is what v5 adds to v4: on a PTY, a close of stdin ends the
|
|
5683
|
+
* client's input and sends nothing on, as a PTY has no end of input of its own (Ctrl-D is the byte 0x04).
|
|
5684
|
+
*
|
|
5685
|
+
* The server never half-closes: its last message is the channel-3 Status, and then it closes the socket with 1000.
|
|
5686
|
+
*/
|
|
5687
|
+
/** The subprotocol a terminal's WebSocket offers and is answered with (Sec-WebSocket-Protocol). */
|
|
5688
|
+
declare const SANDBOX_TERMINAL_PROTOCOL = "v5.channel.k8s.io";
|
|
5689
|
+
/** The terminal a session's PTY emulates, its `TERM`: xterm's 256-colour terminal, as xterm.js emulates it. */
|
|
5690
|
+
declare const SANDBOX_TERMINAL_TERM = "xterm-256color";
|
|
5691
|
+
/** Each channel of `v5.channel.k8s.io` and its byte. */
|
|
5692
|
+
declare const SANDBOX_TERMINAL_CHANNELS: {
|
|
5693
|
+
readonly stdin: 0;
|
|
5694
|
+
readonly stdout: 1;
|
|
5695
|
+
readonly stderr: 2;
|
|
5696
|
+
readonly error: 3;
|
|
5697
|
+
readonly resize: 4;
|
|
5698
|
+
readonly close: 255;
|
|
5699
|
+
};
|
|
5700
|
+
type SandboxTerminalChannel = keyof typeof SANDBOX_TERMINAL_CHANNELS;
|
|
5701
|
+
/** The channels that carry bytes. */
|
|
5702
|
+
type SandboxTerminalStream = "stdin" | "stdout" | "stderr";
|
|
5703
|
+
/** The channels a close (`[255, <channel>]`) names: every one but close itself. */
|
|
5704
|
+
type SandboxTerminalClosable = Exclude<SandboxTerminalChannel, "close">;
|
|
5705
|
+
/** A terminal's size, as Kubernetes' TerminalSize writes it: its columns (`Width`) and rows (`Height`), each a uint16. */
|
|
5706
|
+
interface SandboxTerminalSize {
|
|
5707
|
+
Width: number;
|
|
5708
|
+
Height: number;
|
|
5709
|
+
}
|
|
5710
|
+
/** One cause of a Status, as Kubernetes' StatusCause writes it: its type (`reason`) and its message. */
|
|
5711
|
+
interface SandboxTerminalStatusCause {
|
|
5712
|
+
reason: string;
|
|
5713
|
+
message: string;
|
|
5714
|
+
}
|
|
5715
|
+
/**
|
|
5716
|
+
* The session's last message, on channel 3: Kubernetes' metav1.Status as its remotecommand v4 and later write it.
|
|
5717
|
+
*
|
|
5718
|
+
* - `Success`: the program exited 0.
|
|
5719
|
+
* - `Failure`, `reason` `NonZeroExitCode`: the program exited with the code its one `ExitCode` cause names, as decimal;
|
|
5720
|
+
* a program a signal ended has the shell's code for it, 128 and the signal's number.
|
|
5721
|
+
* - `Failure`, any other `reason`: the session ended otherwise; `reason` is the door's error code, `message` its words
|
|
5722
|
+
* (the provider's, where the provider ended it) and `code` its HTTP status.
|
|
5723
|
+
*/
|
|
5724
|
+
interface SandboxTerminalStatus {
|
|
5725
|
+
metadata: Record<string, never>;
|
|
5726
|
+
status: "Success" | "Failure";
|
|
5727
|
+
reason?: string;
|
|
5728
|
+
message?: string;
|
|
5729
|
+
code?: number;
|
|
5730
|
+
details?: {
|
|
5731
|
+
causes: SandboxTerminalStatusCause[];
|
|
5732
|
+
};
|
|
5733
|
+
}
|
|
5734
|
+
/** The reason of a Status for a program's own nonzero exit, and the type of its cause (Kubernetes' NonZeroExitCodeReason, ExitCodeCauseType). */
|
|
5735
|
+
declare const SANDBOX_TERMINAL_NONZERO_EXIT = "NonZeroExitCode";
|
|
5736
|
+
declare const SANDBOX_TERMINAL_EXIT_CODE_CAUSE = "ExitCode";
|
|
5737
|
+
/** One message of `v5.channel.k8s.io`, by its channel. */
|
|
5738
|
+
type SandboxTerminalMessage = {
|
|
5739
|
+
channel: SandboxTerminalStream;
|
|
5740
|
+
data: Uint8Array;
|
|
5741
|
+
} | {
|
|
5742
|
+
channel: "error";
|
|
5743
|
+
status: SandboxTerminalStatus;
|
|
5744
|
+
} | {
|
|
5745
|
+
channel: "resize";
|
|
5746
|
+
size: SandboxTerminalSize;
|
|
5747
|
+
} | {
|
|
5748
|
+
channel: "close";
|
|
5749
|
+
stream: SandboxTerminalClosable;
|
|
5750
|
+
};
|
|
5751
|
+
/** The Status of a program's exit with `code`: Success for 0, else Failure `NonZeroExitCode` with its `ExitCode` cause. */
|
|
5752
|
+
declare function sandboxTerminalExited(code: number): SandboxTerminalStatus;
|
|
5753
|
+
/** The Status of a session that ended otherwise than by its program's exit: the door's error code, its words and its HTTP status. */
|
|
5754
|
+
declare function sandboxTerminalFailed(reason: string, message: string, code: number): SandboxTerminalStatus;
|
|
5755
|
+
/**
|
|
5756
|
+
* The exit code a Status reports, as client-go reads it: 0 for Success, the `ExitCode` cause's for `NonZeroExitCode`, and
|
|
5757
|
+
* null for a session that ended otherwise.
|
|
5758
|
+
*/
|
|
5759
|
+
declare function sandboxTerminalExitCode(status: SandboxTerminalStatus): number | null;
|
|
5760
|
+
/** One message as its bytes on the wire: its channel's byte, then its payload. */
|
|
5761
|
+
declare function encodeSandboxTerminalMessage(message: SandboxTerminalMessage): Uint8Array<ArrayBuffer>;
|
|
5762
|
+
/** One message from its bytes on the wire; a TypeError says why bytes are no message of `v5.channel.k8s.io`. */
|
|
5763
|
+
declare function decodeSandboxTerminalMessage(bytes: Uint8Array | ArrayBuffer): SandboxTerminalMessage;
|
|
5764
|
+
|
|
5671
5765
|
interface ContainerImageReference {
|
|
5672
5766
|
registry: string;
|
|
5673
5767
|
repository: string;
|
|
@@ -5998,5 +6092,5 @@ declare function parseLedgerAddress(value: unknown): LedgerAddressParts | null;
|
|
|
5998
6092
|
/** Formats ledger address parts; throws when a part breaks its id rule. */
|
|
5999
6093
|
declare function formatLedgerAddress(parts: LedgerAddressParts): LedgerAddress;
|
|
6000
6094
|
|
|
6001
|
-
export { AGENT_UI_DEFAULTS, AfterYield, ApiError, CHAT_FORMAT_CAPABILITY, 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, DATA_SHARE_FEE_BPS, DirectNetworkDenied, EVALUATION_LIMITS, EffectCeilingExceeded, EmptyJoin, GENERAL_QUALITY_JUDGE, GateExhausted, IntegrationRequestNotSent, LeaseLost, MCP_CLIENT_CAPABILITY, MCP_PROTOCOL_VERSION, MEMORY_OPERATION_DECLARATIONS, MODEL_CHECKPOINT_IMPORT_CAPABILITY, MODEL_COMPLETION_CAPABILITY, MODEL_EVALUATION_CAPABILITY, McpClient, NondeterministicReplay, NotAppendOnly, OutcomeUnknown, PolicyConstraintFailed, PolicyDecisionFailed, RESOURCE_CREDENTIAL_BINDING_SCHEMA, RESOURCE_KINDS, ResourceDisabled, ResourceInvalid, ResourceUnbound, RollbackTargetInvalid, SANDBOX_EGRESS_LIMITS, SANDBOX_POOL_OPERATIONS, SANDBOX_PROVIDER_FAILURE_CLASSES, SANDBOX_PROVIDER_UNAVAILABLE, SessionDeleted, SpawnCardinality, SwallowedYield, TRAINING_PROVIDER_CAPABILITY, TRAINING_RECIPE_DEFAULTS, TerminalIntegrationFailure, ToolUnavailable, UI_ASSET_CONTENT_TYPES, UI_BUNDLE_BOUNDS, UnknownTool, WEB_FETCH_ARGUMENT_SCHEMA, WEB_SEARCH_ARGUMENT_SCHEMA, action, actionPattern, agent, agentLimit, agentResourceBinding, agentSetupMetadata, agentSetupRequirements, agentUiBundleManifest, agentUiDeclaration, all, analyticsEvent, approximateTokens, authProvider, authProviderName, bindingName, bucketFor, canonicalJson, capabilityContractRef, casTool, channel, channelIngressRequest, channelIngressSource, channelSourceEvidence, channelSubscriptionRequest, channelTarget, chatFormat, chatFormatMetadata, chatFormatPin, chatParseInput, chatParsed, chatRenderInput, chatRenderRequest, chatRendering, checkpointArtifactRef, checkpointDeploymentRequest, checkpointImportMetadata, checkpointImportRequest, codeScorerIR, containerImageReference, containerImageSelection, containerImageSource, credentialEvidence, credentialInteractionAction, credentialInteractionEvent, credentialInteractionResult, credentialName, credentialProvider, credentialProviderConfigSchema, credentialProviderName, credentialProviderSetupMetadata, credentialRotationDefaults, credentialSetupState, customerTenantName, cutBatches, cutPartitions, dataShareEarningMicroUsd, datasetName, evaluateCodeScorer, evaluatePolicyDefinition, evaluationArguments, evaluationProtocolRequest, evaluationProtocolResult, formatLedgerAddress, gateway, gatewayModelOffer, gatewayPackageMetadata, hash, hashValue, immutableContainerImageReference, integrationEgressPolicy, invocationCredentialUses, judgeAgent, labelSelector, matchesAction, matchesLabelSelector, matchesResource, mcpToolDescription, mcpToolResult, memoryStoreBinding, modelAdvertisedPricing, modelControls, modelGatewayBinding, modelGatewayEndpoint, modelGenerationOptions, modelLimit, modelMessages, modelPrompt, modelProtocolRequest, modelProtocolResult, murmur3_32, normalizeCredentialDestinations, normalizeModelGatewayConfig, normalizeSandboxConnectionKeys, normalizeSandboxEgressPolicy, normalizeSandboxLabels, normalizeSandboxNetworkPolicy, noulDecision, opTool, opTools, parseLedgerAddress, parseResourceName, policy, policyName, race, resolveBindingOwner, resolveContainerImageSource, resolveGatewayEgress, resolveResourceDependencyRef, resourceContractRef, resourceCredentialBinding, resourceDependencyRef, resourceLabelMap, resourceName, resourceNeed, resourcePattern, resourceSelector, resourceTools, runLabels, sandboxControls, sandboxEgressDecision, sandboxEgressHostMatches, sandboxLimit, sandboxProviderUnavailable, scopedBindingKey, scopedCredentialRef, scopedResourceRef, scoreLevel, scorerDraftHash, scorerName, select, selectableResourceLabels, setupAwait, setupCredentialReceipt, setupPanelProviderIsCrn, setupScreen, setupScreenView, setupSubmission, sha256Hex, shareContributionRequest, shareContributionReview, shareEvaluation, sharePrices, shareRequest, skills, stageOutput, startTrainingRequest, subtask, tableDescribe, tableQuery, trainingCorrection, trainingProvider, trainingProviderMetadata, trainingRecipe, uiAssetContentType, uiBundle, uiBundleManifest, uiLimit, uiName, validateBatchSpec, validateFoldFn, validateJsonSchema, validateJsonSchemaDefinition, validatePartitionFn, validatePartitionSpec, validateStageOutputSpec, validateTool, validateView, webFetch, webSearch };
|
|
6002
|
-
export type { Action, ActionPattern, Actor, AdmissionLimitConstraint, AdmissionLimitInput, AdmissionLimitScope, AdmissionLimitWindow, Agent, AgentCredentialSetupRequirement, AgentDef, AgentDeployPolicy, AgentGovernanceMeter, 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, ChannelDeliveryError, ChannelDeliveryEvent, ChannelDeliveryOutcome, ChannelDeliveryReport, ChannelFailure, ChannelFetchRequest, ChannelFetchResult, ChannelIngressEvent, ChannelIngressSource, ChannelMessage, ChannelObject, ChannelPresence, ChannelPresenceReceipt, ChannelProtocol, ChannelReceiveResult, ChannelRequest, ChannelResponse, ChannelSourceEvidence, ChannelSubscriptionRequest, ChannelTarget, ChatFormatDefinition, ChatFormatMetadata, ChatFormatPin, ChatMessage, ChatParseRequest, ChatParsed, ChatRenderRequest, ChatRendering, ChatSpan, ChatTool, 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, CreatedSandbox, CredentialCRN, CredentialDestination, CredentialDestroyResult, CredentialEvidence, CredentialInteractionAction, CredentialInteractionAdvanceRequest, CredentialInteractionEvent, CredentialInteractionPrimaryAction, CredentialInteractionProof, CredentialInteractionResult, CredentialInteractionStartRequest, CredentialMaterialRequest, CredentialMintRequest, CredentialMintResult, CredentialPresentation, CredentialProviderCRN, CredentialProviderConfigEgressBinding, CredentialProviderContext, CredentialProviderCredentialSlotSetup, CredentialProviderDefinition, CredentialProviderPackage, CredentialProviderPackageMetadata, CredentialProviderSecretInput, CredentialProviderSetupMetadata, CredentialSetupState, CredentialUninstallRequest, CredentialUninstallResult, CredentialVerifyResult, Ctx, CustomerTenantCRN, DataManifest, DataSharingScope, DatasetCRN, DatasetDraft, DatasetRef, DelegatedGrant, DelegationCeiling, DeliveryMode, DeliveryReceipt, DispatchResult, EffectClass, EvalComparison, EvalDivergence, EvalMode, EvalSubject, EvalSubjectSource, EvalSuiteCase, EvalSuiteCasePage, EvalSuiteCaseScore, EvalSuiteCaseState, EvalSuiteScoreState, 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, HistoryPage, HistoryView, HmacVerification, IgnoredChannelEvent, IngressRequest, IngressTarget, IntegrationArtifactEgressRequest, IntegrationArtifactEgressResponse, IntegrationAttachment, IntegrationContext, IntegrationEgressPolicy, IntegrationEgressRequest, IntegrationEgressResponse, IntegrationEgressRule, IntegrationLifecycle, IntegrationReleaseContext, IntegrationSecret, IntegrationState, InvocationCredentialUse, InvocationHandle, InvokableKind, InvokeOpts, JoinOutcome, JsonScalar, JsonValue, JudgeRubric, LabelRequest, LabelSelector, LabelSelectorOperator, LabelSelectorRequirement, LedgerAddress, LedgerAddressParts, LedgerEvent, ListSchedulesOptions, LocalResourceRef, ManifestIndexPage, MapFact, MapOpts, McpClientOptions, McpClientState, McpMessageTransport, MemoryDeleteArgs, MemoryGetArgs, MemoryRecord, MemoryRememberArgs, MemorySearchArgs, MemorySearchHit, MemoryStoreBinding, Mode, ModelAdvertisedPricing, ModelCacheHint, ModelCompletion, ModelContentPart, ModelCredentialHeader, ModelFilePart, ModelGatewayBinding, ModelGatewayConfig, ModelGatewayProtocol, ModelGenerationOptions, ModelGovernanceControls, ModelGovernanceMeter, ModelHistoryMessage, ModelHistoryToolCall, ModelInvocationArgs, ModelInvocationResult, ModelProtocolRequestOptions, ModelTechnicalCapabilities, ModelTextPart, 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, RunReport, RunStatusDetail, RunSuiteRequest, Sandbox, SandboxCapabilities, SandboxCreateRequest, SandboxEgress, SandboxEgressCapabilities, SandboxEgressDestination, SandboxEgressPolicy, SandboxEgressRule, SandboxExecCapabilities, SandboxExecRequest, SandboxExecution, SandboxExecutionState, SandboxFile, SandboxFileBody, SandboxFileCapabilities, SandboxFileContent, SandboxFileScope, SandboxGovernanceControls, SandboxGovernanceMeter, SandboxHistoryEvent, SandboxIndexedEvent, SandboxLabelCapabilities, SandboxLabels, SandboxLifecycleEvent, SandboxNetworkMode, SandboxNetworkPolicy, SandboxOrphanEvent, SandboxOrphanWithdrawnEvent, SandboxPersistence, SandboxPlacement, SandboxPool, SandboxPoolCreateRequest, SandboxPoolOperation, SandboxPortCapabilities, SandboxProviderAllocation, SandboxProviderFailureClass, SandboxProviderUnavailable, SandboxSecretsRoute, SandboxSnapshot, SandboxSnapshotCapabilities, SandboxState, SandboxUpdateRequest, SandboxUsageEvent, SandboxUsageItem, SandboxView, SandboxWaitOptions, Schedule, ScheduleCancellation, ScheduleDuration, ScheduleMissed, ScheduleOccurrence, ScheduleOccurrencePage, ScheduleOptions, SchedulePage, ScheduleState, ScheduleTarget, ScheduleTiming, ScheduleTrigger, ScheduleWhen, ScopedBindingKey, ScopedCredentialRef, ScopedMemoryStoreRef, ScopedModelGatewayRef, ScopedResourceRef, ScoreAnswer, ScoreQuestion, ScoreRequest, ScorerApplies, ScorerCRN, ScorerDef, ScorerDraft, ScorerEvaluation, ScorerKind, ScorerRef, ScorerVerdictIntent, SetEvalBaselineRequest, SetupAction, SetupCredentialCandidate, SetupCredentialInteractionPanel, SetupCredentialReceipt, SetupFormPanel, SetupPanel, SetupProgressPanel, SetupReviewPanel, SetupScreen, SetupStepStatus, SetupStepSummary, SetupSubmission, SetupTerminalPanel, SetupWorkflowStatus, Share, ShareAction, ShareContribution, ShareContributionImport, ShareContributionRequest, ShareContributionReview, ShareContributionReviewRequest, ShareContributionStatus, ShareEvaluation, ShareEvaluationPin, ShareEvaluationRequest, ShareEvaluationVerdict, ShareEvaluationView, ShareHistory, SharePrice, ShareRequest, ShareReviewDecision, SortField, SpawnAttenuation, SpawnBudget, SpawnHandle, SpawnOpts, SqlFold, StageInfo, StageOutputSpec, StartTrainingRequest, SteerEvent, StepJournal, SuiteFact, TableAggregate, TableDescribeArgs, TableFilter, TableFilterOperation, TableOrder, TableQueryArgs, TableQueryPlan, TableQueryResult, TableScalar, TableSnapshotDescription, Task, Tier, Tool, ToolCallRecord, TrainingCorrection, TrainingJobFact, TrainingJobReference, TrainingJobState, TrainingJobStatus, TrainingMethod, TrainingModelOffer, TrainingPreparation, TrainingProviderDefinition, TrainingProviderMetadata, TrainingProviderPin, TrainingRecipe, TrainingResumePoint, TrainingStep, TrainingUsageUnits, TurnDraft, TurnGate, TurnHistoryMessage, TurnRecord, TurnSpec, UiAccess, UiBundle, UiBundleManifest, UiCRN, UiCapability, UiExecution, UiGovernanceMeter, UiHandler, UiResource, UiRuntimeContext, UiSource, UiSqlResult, UiState, UpstreamPayer, Verdict, VerdictSamplingMode, ViewDef, WaitResolvedEvent };
|
|
6095
|
+
export { AGENT_UI_DEFAULTS, AfterYield, ApiError, CHAT_FORMAT_CAPABILITY, 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, DATA_SHARE_FEE_BPS, DirectNetworkDenied, EVALUATION_LIMITS, EffectCeilingExceeded, EmptyJoin, GENERAL_QUALITY_JUDGE, GateExhausted, IntegrationRequestNotSent, LeaseLost, MCP_CLIENT_CAPABILITY, MCP_PROTOCOL_VERSION, MEMORY_OPERATION_DECLARATIONS, MODEL_CHECKPOINT_IMPORT_CAPABILITY, MODEL_COMPLETION_CAPABILITY, MODEL_EVALUATION_CAPABILITY, McpClient, NondeterministicReplay, NotAppendOnly, OutcomeUnknown, PolicyConstraintFailed, PolicyDecisionFailed, RESOURCE_CREDENTIAL_BINDING_SCHEMA, RESOURCE_KINDS, ResourceDisabled, ResourceInvalid, ResourceUnbound, RollbackTargetInvalid, SANDBOX_EGRESS_LIMITS, SANDBOX_POOL_OPERATIONS, SANDBOX_PROVIDER_FAILURE_CLASSES, SANDBOX_PROVIDER_UNAVAILABLE, SANDBOX_TERMINAL_CHANNELS, SANDBOX_TERMINAL_EXIT_CODE_CAUSE, SANDBOX_TERMINAL_NONZERO_EXIT, SANDBOX_TERMINAL_PROTOCOL, SANDBOX_TERMINAL_TERM, SessionDeleted, SpawnCardinality, SwallowedYield, TRAINING_PROVIDER_CAPABILITY, TRAINING_RECIPE_DEFAULTS, TerminalIntegrationFailure, ToolUnavailable, UI_ASSET_CONTENT_TYPES, UI_BUNDLE_BOUNDS, UnknownTool, WEB_FETCH_ARGUMENT_SCHEMA, WEB_SEARCH_ARGUMENT_SCHEMA, action, actionPattern, agent, agentLimit, agentResourceBinding, agentSetupMetadata, agentSetupRequirements, agentUiBundleManifest, agentUiDeclaration, all, analyticsEvent, approximateTokens, authProvider, authProviderName, bindingName, bucketFor, canonicalJson, capabilityContractRef, casTool, channel, channelIngressRequest, channelIngressSource, channelSourceEvidence, channelSubscriptionRequest, channelTarget, chatFormat, chatFormatMetadata, chatFormatPin, chatParseInput, chatParsed, chatRenderInput, chatRenderRequest, chatRendering, checkpointArtifactRef, checkpointDeploymentRequest, checkpointImportMetadata, checkpointImportRequest, codeScorerIR, containerImageReference, containerImageSelection, containerImageSource, credentialEvidence, credentialInteractionAction, credentialInteractionEvent, credentialInteractionResult, credentialName, credentialProvider, credentialProviderConfigSchema, credentialProviderName, credentialProviderSetupMetadata, credentialRotationDefaults, credentialSetupState, customerTenantName, cutBatches, cutPartitions, dataShareEarningMicroUsd, datasetName, decodeSandboxTerminalMessage, encodeSandboxTerminalMessage, evaluateCodeScorer, evaluatePolicyDefinition, evaluationArguments, evaluationProtocolRequest, evaluationProtocolResult, formatLedgerAddress, gateway, gatewayModelOffer, gatewayPackageMetadata, hash, hashValue, immutableContainerImageReference, integrationEgressPolicy, invocationCredentialUses, judgeAgent, labelSelector, matchesAction, matchesLabelSelector, matchesResource, mcpToolDescription, mcpToolResult, memoryStoreBinding, modelAdvertisedPricing, modelControls, modelGatewayBinding, modelGatewayEndpoint, modelGenerationOptions, modelLimit, modelMessages, modelPrompt, modelProtocolRequest, modelProtocolResult, murmur3_32, normalizeCredentialDestinations, normalizeModelGatewayConfig, normalizeSandboxConnectionKeys, normalizeSandboxEgressPolicy, normalizeSandboxLabels, normalizeSandboxNetworkPolicy, noulDecision, opTool, opTools, parseLedgerAddress, parseResourceName, policy, policyName, race, resolveBindingOwner, resolveContainerImageSource, resolveGatewayEgress, resolveResourceDependencyRef, resourceContractRef, resourceCredentialBinding, resourceDependencyRef, resourceLabelMap, resourceName, resourceNeed, resourcePattern, resourceSelector, resourceTools, runLabels, sandboxControls, sandboxEgressDecision, sandboxEgressHostMatches, sandboxLimit, sandboxProviderUnavailable, sandboxTerminalExitCode, sandboxTerminalExited, sandboxTerminalFailed, scopedBindingKey, scopedCredentialRef, scopedResourceRef, scoreLevel, scorerDraftHash, scorerName, select, selectableResourceLabels, setupAwait, setupCredentialReceipt, setupPanelProviderIsCrn, setupScreen, setupScreenView, setupSubmission, sha256Hex, shareContributionRequest, shareContributionReview, shareEvaluation, sharePrices, shareRequest, skills, stageOutput, startTrainingRequest, subtask, tableDescribe, tableQuery, trainingCorrection, trainingProvider, trainingProviderMetadata, trainingRecipe, uiAssetContentType, uiBundle, uiBundleManifest, uiLimit, uiName, validateBatchSpec, validateFoldFn, validateJsonSchema, validateJsonSchemaDefinition, validatePartitionFn, validatePartitionSpec, validateStageOutputSpec, validateTool, validateView, webFetch, webSearch };
|
|
6096
|
+
export type { Action, ActionPattern, Actor, AdmissionLimitConstraint, AdmissionLimitInput, AdmissionLimitScope, AdmissionLimitWindow, Agent, AgentCredentialSetupRequirement, AgentDef, AgentDeployPolicy, AgentGovernanceMeter, 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, ChannelDeliveryError, ChannelDeliveryEvent, ChannelDeliveryOutcome, ChannelDeliveryReport, ChannelFailure, ChannelFetchRequest, ChannelFetchResult, ChannelIngressEvent, ChannelIngressSource, ChannelMessage, ChannelObject, ChannelPresence, ChannelPresenceReceipt, ChannelProtocol, ChannelReceiveResult, ChannelRequest, ChannelResponse, ChannelSourceEvidence, ChannelSubscriptionRequest, ChannelTarget, ChatFormatDefinition, ChatFormatMetadata, ChatFormatPin, ChatMessage, ChatParseRequest, ChatParsed, ChatRenderRequest, ChatRendering, ChatSpan, ChatTool, 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, CreatedSandbox, CredentialCRN, CredentialDestination, CredentialDestroyResult, CredentialEvidence, CredentialInteractionAction, CredentialInteractionAdvanceRequest, CredentialInteractionEvent, CredentialInteractionPrimaryAction, CredentialInteractionProof, CredentialInteractionResult, CredentialInteractionStartRequest, CredentialMaterialRequest, CredentialMintRequest, CredentialMintResult, CredentialPresentation, CredentialProviderCRN, CredentialProviderConfigEgressBinding, CredentialProviderContext, CredentialProviderCredentialSlotSetup, CredentialProviderDefinition, CredentialProviderPackage, CredentialProviderPackageMetadata, CredentialProviderSecretInput, CredentialProviderSetupMetadata, CredentialSetupState, CredentialUninstallRequest, CredentialUninstallResult, CredentialVerifyResult, Ctx, CustomerTenantCRN, DataManifest, DataSharingScope, DatasetCRN, DatasetDraft, DatasetRef, DelegatedGrant, DelegationCeiling, DeliveryMode, DeliveryReceipt, DispatchResult, EffectClass, EvalComparison, EvalDivergence, EvalMode, EvalSubject, EvalSubjectSource, EvalSuiteCase, EvalSuiteCasePage, EvalSuiteCaseScore, EvalSuiteCaseState, EvalSuiteScoreState, 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, HistoryPage, HistoryView, HmacVerification, IgnoredChannelEvent, IngressRequest, IngressTarget, IntegrationArtifactEgressRequest, IntegrationArtifactEgressResponse, IntegrationAttachment, IntegrationContext, IntegrationEgressPolicy, IntegrationEgressRequest, IntegrationEgressResponse, IntegrationEgressRule, IntegrationLifecycle, IntegrationReleaseContext, IntegrationSecret, IntegrationState, InvocationCredentialUse, InvocationHandle, InvokableKind, InvokeOpts, JoinOutcome, JsonScalar, JsonValue, JudgeRubric, LabelRequest, LabelSelector, LabelSelectorOperator, LabelSelectorRequirement, LedgerAddress, LedgerAddressParts, LedgerEvent, ListSchedulesOptions, LocalResourceRef, ManifestIndexPage, MapFact, MapOpts, McpClientOptions, McpClientState, McpMessageTransport, MemoryDeleteArgs, MemoryGetArgs, MemoryRecord, MemoryRememberArgs, MemorySearchArgs, MemorySearchHit, MemoryStoreBinding, Mode, ModelAdvertisedPricing, ModelCacheHint, ModelCompletion, ModelContentPart, ModelCredentialHeader, ModelFilePart, ModelGatewayBinding, ModelGatewayConfig, ModelGatewayProtocol, ModelGenerationOptions, ModelGovernanceControls, ModelGovernanceMeter, ModelHistoryMessage, ModelHistoryToolCall, ModelInvocationArgs, ModelInvocationResult, ModelProtocolRequestOptions, ModelTechnicalCapabilities, ModelTextPart, 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, RunReport, RunStatusDetail, RunSuiteRequest, Sandbox, SandboxCapabilities, SandboxCreateRequest, SandboxEgress, SandboxEgressCapabilities, SandboxEgressDestination, SandboxEgressPolicy, SandboxEgressRule, SandboxExecCapabilities, SandboxExecRequest, SandboxExecution, SandboxExecutionState, SandboxFile, SandboxFileBody, SandboxFileCapabilities, SandboxFileContent, SandboxFileScope, SandboxGovernanceControls, SandboxGovernanceMeter, SandboxHistoryEvent, SandboxIndexedEvent, SandboxLabelCapabilities, SandboxLabels, SandboxLifecycleEvent, SandboxNetworkMode, SandboxNetworkPolicy, SandboxOrphanEvent, SandboxOrphanWithdrawnEvent, SandboxPersistence, SandboxPlacement, SandboxPool, SandboxPoolCreateRequest, SandboxPoolOperation, SandboxPortCapabilities, SandboxProviderAllocation, SandboxProviderFailureClass, SandboxProviderUnavailable, SandboxSecretsRoute, SandboxSnapshot, SandboxSnapshotCapabilities, SandboxState, SandboxTerminalChannel, SandboxTerminalClosable, SandboxTerminalMessage, SandboxTerminalSize, SandboxTerminalStatus, SandboxTerminalStatusCause, SandboxTerminalStream, SandboxUpdateRequest, SandboxUsageEvent, SandboxUsageItem, SandboxView, SandboxWaitOptions, Schedule, ScheduleCancellation, ScheduleDuration, ScheduleMissed, ScheduleOccurrence, ScheduleOccurrencePage, ScheduleOptions, SchedulePage, ScheduleState, ScheduleTarget, ScheduleTiming, ScheduleTrigger, ScheduleWhen, ScopedBindingKey, ScopedCredentialRef, ScopedMemoryStoreRef, ScopedModelGatewayRef, ScopedResourceRef, ScoreAnswer, ScoreQuestion, ScoreRequest, ScorerApplies, ScorerCRN, ScorerDef, ScorerDraft, ScorerEvaluation, ScorerKind, ScorerRef, ScorerVerdictIntent, SetEvalBaselineRequest, SetupAction, SetupCredentialCandidate, SetupCredentialInteractionPanel, SetupCredentialReceipt, SetupFormPanel, SetupPanel, SetupProgressPanel, SetupReviewPanel, SetupScreen, SetupStepStatus, SetupStepSummary, SetupSubmission, SetupTerminalPanel, SetupWorkflowStatus, Share, ShareAction, ShareContribution, ShareContributionImport, ShareContributionRequest, ShareContributionReview, ShareContributionReviewRequest, ShareContributionStatus, ShareEvaluation, ShareEvaluationPin, ShareEvaluationRequest, ShareEvaluationVerdict, ShareEvaluationView, ShareHistory, SharePrice, ShareRequest, ShareReviewDecision, SortField, SpawnAttenuation, SpawnBudget, SpawnHandle, SpawnOpts, SqlFold, StageInfo, StageOutputSpec, StartTrainingRequest, SteerEvent, StepJournal, SuiteFact, TableAggregate, TableDescribeArgs, TableFilter, TableFilterOperation, TableOrder, TableQueryArgs, TableQueryPlan, TableQueryResult, TableScalar, TableSnapshotDescription, Task, Tier, Tool, ToolCallRecord, TrainingCorrection, TrainingJobFact, TrainingJobReference, TrainingJobState, TrainingJobStatus, TrainingMethod, TrainingModelOffer, TrainingPreparation, TrainingProviderDefinition, TrainingProviderMetadata, TrainingProviderPin, TrainingRecipe, TrainingResumePoint, TrainingStep, TrainingUsageUnits, TurnDraft, TurnGate, TurnHistoryMessage, 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
|
@@ -81,8 +81,8 @@ function canonicalJson(value) {
|
|
|
81
81
|
if (typeof value === "string") return JSON.stringify(value);
|
|
82
82
|
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
83
83
|
if (typeof value === "object") {
|
|
84
|
-
const
|
|
85
|
-
return `{${Object.keys(
|
|
84
|
+
const record15 = value;
|
|
85
|
+
return `{${Object.keys(record15).sort().filter((key) => record15[key] !== void 0).map((key) => `${JSON.stringify(key)}:${canonicalJson(record15[key])}`).join(",")}}`;
|
|
86
86
|
}
|
|
87
87
|
throw new TypeError(`canonical JSON does not support ${typeof value}`);
|
|
88
88
|
}
|
|
@@ -244,21 +244,21 @@ function validateJsonSchema(value, schema, path2 = "$") {
|
|
|
244
244
|
if (typeof rule.multipleOf === "number" && Math.abs(value / rule.multipleOf - Math.round(value / rule.multipleOf)) > Number.EPSILON * 8) return `${path2} is not a multiple`;
|
|
245
245
|
}
|
|
246
246
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
247
|
-
const
|
|
248
|
-
for (const key of Array.isArray(rule.required) ? rule.required : []) if (typeof key === "string" && !(key in
|
|
247
|
+
const record15 = value;
|
|
248
|
+
for (const key of Array.isArray(rule.required) ? rule.required : []) if (typeof key === "string" && !(key in record15)) return `${path2}.${key} is required`;
|
|
249
249
|
const properties = rule.properties && typeof rule.properties === "object" && !Array.isArray(rule.properties) ? rule.properties : {};
|
|
250
|
-
if (typeof rule.minProperties === "number" && Object.keys(
|
|
251
|
-
if (typeof rule.maxProperties === "number" && Object.keys(
|
|
250
|
+
if (typeof rule.minProperties === "number" && Object.keys(record15).length < rule.minProperties) return `${path2} has too few properties`;
|
|
251
|
+
if (typeof rule.maxProperties === "number" && Object.keys(record15).length > rule.maxProperties) return `${path2} has too many properties`;
|
|
252
252
|
if (rule.additionalProperties === false) {
|
|
253
|
-
const extra = Object.keys(
|
|
253
|
+
const extra = Object.keys(record15).find((key) => !(key in properties));
|
|
254
254
|
if (extra) return `${path2}.${extra} is not allowed`;
|
|
255
255
|
}
|
|
256
|
-
for (const [key, child] of Object.entries(properties)) if (key in
|
|
257
|
-
const error = validateJsonSchema(
|
|
256
|
+
for (const [key, child] of Object.entries(properties)) if (key in record15) {
|
|
257
|
+
const error = validateJsonSchema(record15[key], child, `${path2}.${key}`);
|
|
258
258
|
if (error) return error;
|
|
259
259
|
}
|
|
260
|
-
if (rule.additionalProperties && typeof rule.additionalProperties === "object") for (const key of Object.keys(
|
|
261
|
-
const error = validateJsonSchema(
|
|
260
|
+
if (rule.additionalProperties && typeof rule.additionalProperties === "object") for (const key of Object.keys(record15).filter((candidate) => !(candidate in properties))) {
|
|
261
|
+
const error = validateJsonSchema(record15[key], rule.additionalProperties, `${path2}.${key}`);
|
|
262
262
|
if (error) return error;
|
|
263
263
|
}
|
|
264
264
|
}
|
|
@@ -1909,7 +1909,7 @@ function setupScreen(value) {
|
|
|
1909
1909
|
if (!step || !id2 || !ID.test(id2) || !label || !["pending", "current", "complete", "blocked"].includes(String(step.status)) || step.optional !== void 0 && typeof step.optional !== "boolean" || !exact(step, ["id", "label", "status", "optional"])) throw new TypeError("Setup screen step is invalid");
|
|
1910
1910
|
parsedSteps.push({ id: id2, label, status: step.status, ...step.optional === void 0 ? {} : { optional: step.optional } });
|
|
1911
1911
|
}
|
|
1912
|
-
if (new Set(parsedSteps.map(({ id: id2 }) => id2)).size !== parsedSteps.length || parsedSteps.filter(({ status }) =>
|
|
1912
|
+
if (new Set(parsedSteps.map(({ id: id2 }) => id2)).size !== parsedSteps.length || parsedSteps.filter(({ status: status2 }) => status2 === "current").length > 1 || source.status === "active" && parsedSteps.filter(({ status: status2 }) => status2 === "current").length !== 1 || source.status === "active" && !source.waitLabel || source.status !== "active" && source.waitLabel !== null || source.status === "complete" && current.kind !== "complete" || source.status === "blocked" && current.kind !== "blocked") throw new TypeError("Setup screen state is inconsistent");
|
|
1913
1913
|
const normalized = {
|
|
1914
1914
|
object: "constal.setup.screen",
|
|
1915
1915
|
version: 1,
|
|
@@ -2814,9 +2814,9 @@ var MEMORY_OPERATION_DECLARATIONS = [
|
|
|
2814
2814
|
// packages/sdk/src/integration.ts
|
|
2815
2815
|
var ApiError = class extends Error {
|
|
2816
2816
|
/** `retryAfterMs`: the interval the remote API stated, such as its `retry-after`; absent when it stated none. */
|
|
2817
|
-
constructor(
|
|
2818
|
-
super(`${
|
|
2819
|
-
this.status =
|
|
2817
|
+
constructor(status2, body, disposition = "uncertain", retryAfterMs) {
|
|
2818
|
+
super(`${status2}: ${body}`);
|
|
2819
|
+
this.status = status2;
|
|
2820
2820
|
this.body = body;
|
|
2821
2821
|
this.disposition = disposition;
|
|
2822
2822
|
this.retryAfterMs = retryAfterMs;
|
|
@@ -4604,6 +4604,130 @@ function scoreLevel(answer2) {
|
|
|
4604
4604
|
return Math.min(Object.keys(answer2.legend).length - 1, Math.max(0, Math.round(answer2.score)));
|
|
4605
4605
|
}
|
|
4606
4606
|
|
|
4607
|
+
// packages/sdk/src/sandbox-terminal.ts
|
|
4608
|
+
var SANDBOX_TERMINAL_PROTOCOL = "v5.channel.k8s.io";
|
|
4609
|
+
var SANDBOX_TERMINAL_TERM = "xterm-256color";
|
|
4610
|
+
var SANDBOX_TERMINAL_CHANNELS = { stdin: 0, stdout: 1, stderr: 2, error: 3, resize: 4, close: 255 };
|
|
4611
|
+
var SANDBOX_TERMINAL_NONZERO_EXIT = "NonZeroExitCode";
|
|
4612
|
+
var SANDBOX_TERMINAL_EXIT_CODE_CAUSE = "ExitCode";
|
|
4613
|
+
function sandboxTerminalExited(code) {
|
|
4614
|
+
if (!Number.isSafeInteger(code) || code < 0) throw new TypeError("an exit code is a whole number");
|
|
4615
|
+
if (code === 0) return { metadata: {}, status: "Success" };
|
|
4616
|
+
return {
|
|
4617
|
+
metadata: {},
|
|
4618
|
+
status: "Failure",
|
|
4619
|
+
reason: SANDBOX_TERMINAL_NONZERO_EXIT,
|
|
4620
|
+
message: `command terminated with non-zero exit code ${code}`,
|
|
4621
|
+
details: { causes: [{ reason: SANDBOX_TERMINAL_EXIT_CODE_CAUSE, message: String(code) }] }
|
|
4622
|
+
};
|
|
4623
|
+
}
|
|
4624
|
+
function sandboxTerminalFailed(reason, message2, code) {
|
|
4625
|
+
return { metadata: {}, status: "Failure", reason, message: message2, code };
|
|
4626
|
+
}
|
|
4627
|
+
function sandboxTerminalExitCode(status2) {
|
|
4628
|
+
if (status2.status === "Success") return 0;
|
|
4629
|
+
if (status2.reason !== SANDBOX_TERMINAL_NONZERO_EXIT) return null;
|
|
4630
|
+
const cause = status2.details?.causes.find((entry2) => entry2.reason === SANDBOX_TERMINAL_EXIT_CODE_CAUSE);
|
|
4631
|
+
return cause && /^\d+$/u.test(cause.message) ? Number(cause.message) : null;
|
|
4632
|
+
}
|
|
4633
|
+
function channelName(name) {
|
|
4634
|
+
return Object.hasOwn(SANDBOX_TERMINAL_CHANNELS, name);
|
|
4635
|
+
}
|
|
4636
|
+
var CHANNEL_NAMES = new Map(
|
|
4637
|
+
Object.keys(SANDBOX_TERMINAL_CHANNELS).filter(channelName).map((name) => [SANDBOX_TERMINAL_CHANNELS[name], name])
|
|
4638
|
+
);
|
|
4639
|
+
var UINT16_MAX = 65535;
|
|
4640
|
+
function uint16(value) {
|
|
4641
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= UINT16_MAX;
|
|
4642
|
+
}
|
|
4643
|
+
function framed(channel2, payload) {
|
|
4644
|
+
const message2 = new Uint8Array(1 + payload.byteLength);
|
|
4645
|
+
message2[0] = channel2;
|
|
4646
|
+
message2.set(payload, 1);
|
|
4647
|
+
return message2;
|
|
4648
|
+
}
|
|
4649
|
+
function encodeSandboxTerminalMessage(message2) {
|
|
4650
|
+
const byte = SANDBOX_TERMINAL_CHANNELS[message2.channel];
|
|
4651
|
+
switch (message2.channel) {
|
|
4652
|
+
case "stdin":
|
|
4653
|
+
case "stdout":
|
|
4654
|
+
case "stderr":
|
|
4655
|
+
return framed(byte, message2.data);
|
|
4656
|
+
case "error":
|
|
4657
|
+
return framed(byte, new TextEncoder().encode(JSON.stringify(message2.status)));
|
|
4658
|
+
case "resize": {
|
|
4659
|
+
if (!uint16(message2.size.Width) || !uint16(message2.size.Height)) throw new TypeError("a terminal's Width and Height are each a uint16");
|
|
4660
|
+
return framed(byte, new TextEncoder().encode(JSON.stringify({ Width: message2.size.Width, Height: message2.size.Height })));
|
|
4661
|
+
}
|
|
4662
|
+
case "close":
|
|
4663
|
+
return framed(byte, Uint8Array.of(SANDBOX_TERMINAL_CHANNELS[message2.stream]));
|
|
4664
|
+
}
|
|
4665
|
+
}
|
|
4666
|
+
function record11(value) {
|
|
4667
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
4668
|
+
}
|
|
4669
|
+
function json(payload, channel2) {
|
|
4670
|
+
let value;
|
|
4671
|
+
try {
|
|
4672
|
+
value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(payload));
|
|
4673
|
+
} catch {
|
|
4674
|
+
throw new TypeError(`a ${channel2} message is a JSON object`);
|
|
4675
|
+
}
|
|
4676
|
+
const object5 = record11(value);
|
|
4677
|
+
if (!object5) throw new TypeError(`a ${channel2} message is a JSON object`);
|
|
4678
|
+
return object5;
|
|
4679
|
+
}
|
|
4680
|
+
function status(object5) {
|
|
4681
|
+
if (object5.status !== "Success" && object5.status !== "Failure") throw new TypeError("a Status is Success or Failure");
|
|
4682
|
+
const read = { metadata: {}, status: object5.status };
|
|
4683
|
+
for (const field2 of ["reason", "message"]) {
|
|
4684
|
+
const value = object5[field2];
|
|
4685
|
+
if (value === void 0) continue;
|
|
4686
|
+
if (typeof value !== "string") throw new TypeError(`a Status's ${field2} is a string`);
|
|
4687
|
+
read[field2] = value;
|
|
4688
|
+
}
|
|
4689
|
+
if (object5.code !== void 0) {
|
|
4690
|
+
if (typeof object5.code !== "number" || !Number.isInteger(object5.code)) throw new TypeError("a Status's code is a whole number");
|
|
4691
|
+
read.code = object5.code;
|
|
4692
|
+
}
|
|
4693
|
+
const details = object5.details === void 0 ? void 0 : record11(object5.details);
|
|
4694
|
+
if (details === null) throw new TypeError("a Status's details are an object");
|
|
4695
|
+
if (details?.causes !== void 0) {
|
|
4696
|
+
if (!Array.isArray(details.causes)) throw new TypeError("a Status's causes are a list");
|
|
4697
|
+
read.details = { causes: details.causes.map((entry2) => {
|
|
4698
|
+
const cause = record11(entry2);
|
|
4699
|
+
return { reason: typeof cause?.reason === "string" ? cause.reason : "", message: typeof cause?.message === "string" ? cause.message : "" };
|
|
4700
|
+
}) };
|
|
4701
|
+
}
|
|
4702
|
+
return read;
|
|
4703
|
+
}
|
|
4704
|
+
function decodeSandboxTerminalMessage(bytes) {
|
|
4705
|
+
const message2 = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
4706
|
+
if (message2.byteLength === 0) throw new TypeError("a terminal message starts with its channel's byte");
|
|
4707
|
+
const channel2 = CHANNEL_NAMES.get(message2[0]);
|
|
4708
|
+
const payload = message2.subarray(1);
|
|
4709
|
+
switch (channel2) {
|
|
4710
|
+
case "stdin":
|
|
4711
|
+
case "stdout":
|
|
4712
|
+
case "stderr":
|
|
4713
|
+
return { channel: channel2, data: payload };
|
|
4714
|
+
case "error":
|
|
4715
|
+
return { channel: channel2, status: status(json(payload, channel2)) };
|
|
4716
|
+
case "resize": {
|
|
4717
|
+
const size = json(payload, channel2);
|
|
4718
|
+
if (!uint16(size.Width) || !uint16(size.Height)) throw new TypeError("a terminal's Width and Height are each a uint16");
|
|
4719
|
+
return { channel: channel2, size: { Width: size.Width, Height: size.Height } };
|
|
4720
|
+
}
|
|
4721
|
+
case "close": {
|
|
4722
|
+
const stream = payload.byteLength === 1 ? CHANNEL_NAMES.get(payload[0]) : void 0;
|
|
4723
|
+
if (stream === void 0 || stream === "close") throw new TypeError("a close names the one channel it closes");
|
|
4724
|
+
return { channel: channel2, stream };
|
|
4725
|
+
}
|
|
4726
|
+
default:
|
|
4727
|
+
throw new TypeError(`a terminal message has no channel ${message2[0]}`);
|
|
4728
|
+
}
|
|
4729
|
+
}
|
|
4730
|
+
|
|
4607
4731
|
// packages/sdk/src/container-image.ts
|
|
4608
4732
|
var REPOSITORY = /^[a-z0-9]+(?:(?:\.|_|__|-+)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:\.|_|__|-+)[a-z0-9]+)*)*$/u;
|
|
4609
4733
|
var TAG = /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$/u;
|
|
@@ -4736,30 +4860,30 @@ async function resolveContainerImageSource(reference, platform, request, authori
|
|
|
4736
4860
|
|
|
4737
4861
|
// packages/sdk/src/mcp.ts
|
|
4738
4862
|
var MCP_PROTOCOL_VERSION = "2025-06-18";
|
|
4739
|
-
function
|
|
4863
|
+
function record12(value) {
|
|
4740
4864
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
4741
4865
|
}
|
|
4742
4866
|
function mcpToolDescription(value) {
|
|
4743
|
-
const tool =
|
|
4744
|
-
const outputSchema = tool?.outputSchema === void 0 ? {} :
|
|
4867
|
+
const tool = record12(value), inputSchema = record12(tool?.inputSchema);
|
|
4868
|
+
const outputSchema = tool?.outputSchema === void 0 ? {} : record12(tool.outputSchema);
|
|
4745
4869
|
if (!tool || typeof tool.name !== "string" || !tool.name || tool.description !== void 0 && typeof tool.description !== "string" || !inputSchema || outputSchema === null) throw new TerminalIntegrationFailure("MCP server advertised an invalid tool");
|
|
4746
4870
|
return {
|
|
4747
4871
|
name: tool.name,
|
|
4748
4872
|
description: typeof tool.description === "string" ? tool.description : "",
|
|
4749
4873
|
inputSchema,
|
|
4750
4874
|
outputSchema,
|
|
4751
|
-
annotations:
|
|
4875
|
+
annotations: record12(tool.annotations) ?? {}
|
|
4752
4876
|
};
|
|
4753
4877
|
}
|
|
4754
4878
|
function mcpToolResult(value) {
|
|
4755
|
-
const result =
|
|
4756
|
-
if (!result || result.isError !== void 0 && typeof result.isError !== "boolean" || result?.content !== void 0 && !Array.isArray(result.content) || result?.structuredContent !== void 0 && !
|
|
4879
|
+
const result = record12(value);
|
|
4880
|
+
if (!result || result.isError !== void 0 && typeof result.isError !== "boolean" || result?.content !== void 0 && !Array.isArray(result.content) || result?.structuredContent !== void 0 && !record12(result.structuredContent) || result && result.content === void 0 && result.structuredContent === void 0) {
|
|
4757
4881
|
throw new TerminalIntegrationFailure("MCP tools/call result is invalid");
|
|
4758
4882
|
}
|
|
4759
4883
|
return result;
|
|
4760
4884
|
}
|
|
4761
4885
|
function message(value) {
|
|
4762
|
-
const item =
|
|
4886
|
+
const item = record12(value);
|
|
4763
4887
|
if (!item || item.jsonrpc !== "2.0") throw new TerminalIntegrationFailure("MCP transport returned an invalid JSON-RPC message");
|
|
4764
4888
|
return item;
|
|
4765
4889
|
}
|
|
@@ -4799,7 +4923,7 @@ var McpClient = class {
|
|
|
4799
4923
|
for (; ; ) {
|
|
4800
4924
|
const received = message(await this.transport.receive());
|
|
4801
4925
|
if (received.id === id2) {
|
|
4802
|
-
if (
|
|
4926
|
+
if (record12(received.error)) {
|
|
4803
4927
|
const error = received.error;
|
|
4804
4928
|
throw new TerminalIntegrationFailure(`MCP ${typeof error.code === "number" || typeof error.code === "string" ? error.code : "unknown"}: ${typeof error.message === "string" ? error.message : "request failed"}`);
|
|
4805
4929
|
}
|
|
@@ -4824,7 +4948,7 @@ var McpClient = class {
|
|
|
4824
4948
|
}
|
|
4825
4949
|
async initialize() {
|
|
4826
4950
|
if (this.#protocol) return { protocolVersion: this.#protocol, server: {} };
|
|
4827
|
-
const result =
|
|
4951
|
+
const result = record12(await this.#request("initialize", {
|
|
4828
4952
|
protocolVersion: MCP_PROTOCOL_VERSION,
|
|
4829
4953
|
capabilities: {},
|
|
4830
4954
|
clientInfo: this.options.client ?? { name: "Constal", version: "1.0.0" }
|
|
@@ -4835,7 +4959,7 @@ var McpClient = class {
|
|
|
4835
4959
|
this.#protocol = result.protocolVersion;
|
|
4836
4960
|
await this.transport.negotiated?.(this.#protocol);
|
|
4837
4961
|
await this.#serialized(() => this.transport.send({ jsonrpc: "2.0", method: "notifications/initialized" }));
|
|
4838
|
-
return { protocolVersion: this.#protocol, server:
|
|
4962
|
+
return { protocolVersion: this.#protocol, server: record12(result.serverInfo) ?? {} };
|
|
4839
4963
|
}
|
|
4840
4964
|
async request(method, params) {
|
|
4841
4965
|
if (!this.#protocol) throw new TerminalIntegrationFailure("MCP session is not initialized");
|
|
@@ -4845,8 +4969,8 @@ var McpClient = class {
|
|
|
4845
4969
|
const tools = [], cursors = /* @__PURE__ */ new Set();
|
|
4846
4970
|
let cursor;
|
|
4847
4971
|
do {
|
|
4848
|
-
const result =
|
|
4849
|
-
if (!result || !Array.isArray(result.tools) || result.tools.some((item) => !
|
|
4972
|
+
const result = record12(await this.request("tools/list", cursor ? { cursor } : {}));
|
|
4973
|
+
if (!result || !Array.isArray(result.tools) || result.tools.some((item) => !record12(item))) {
|
|
4850
4974
|
throw new TerminalIntegrationFailure("MCP tools/list result is invalid");
|
|
4851
4975
|
}
|
|
4852
4976
|
tools.push(...result.tools);
|
|
@@ -4876,14 +5000,14 @@ var McpClient = class {
|
|
|
4876
5000
|
function validPointer(value) {
|
|
4877
5001
|
return typeof value === "string" && value.length <= 4096 && (value === "" || value.startsWith("/") && !/~(?:[^01]|$)/u.test(value));
|
|
4878
5002
|
}
|
|
4879
|
-
function
|
|
5003
|
+
function record13(value) {
|
|
4880
5004
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
4881
5005
|
}
|
|
4882
5006
|
function exactKeys5(value, allowed) {
|
|
4883
5007
|
return Object.keys(value).every((key) => allowed.includes(key));
|
|
4884
5008
|
}
|
|
4885
5009
|
function scorerRule(value, depth, state) {
|
|
4886
|
-
const rule =
|
|
5010
|
+
const rule = record13(value);
|
|
4887
5011
|
if (!rule || typeof rule.op !== "string") throw new TypeError("Code Scorer IR is invalid");
|
|
4888
5012
|
if (rule.op === "all" || rule.op === "any") {
|
|
4889
5013
|
if (!exactKeys5(rule, ["op", "rules"]) || !Array.isArray(rule.rules) || rule.rules.length < 1) {
|
|
@@ -4896,7 +5020,7 @@ function scorerRule(value, depth, state) {
|
|
|
4896
5020
|
return { op: "not", rule: scorerRule(rule.rule, depth + 1, state) };
|
|
4897
5021
|
}
|
|
4898
5022
|
if (rule.op === "schema") {
|
|
4899
|
-
if (!exactKeys5(rule, ["op", "path", "schema"]) || !validPointer(rule.path) || !
|
|
5023
|
+
if (!exactKeys5(rule, ["op", "path", "schema"]) || !validPointer(rule.path) || !record13(rule.schema) || validateJsonSchemaDefinition(rule.schema)) throw new TypeError("Code Scorer schema rule is invalid");
|
|
4900
5024
|
return rule;
|
|
4901
5025
|
}
|
|
4902
5026
|
if (rule.op === "regex") {
|
|
@@ -4931,7 +5055,7 @@ function scorerRule(value, depth, state) {
|
|
|
4931
5055
|
throw new TypeError("Code Scorer operation is invalid");
|
|
4932
5056
|
}
|
|
4933
5057
|
function codeScorerIR(value) {
|
|
4934
|
-
const ir =
|
|
5058
|
+
const ir = record13(value);
|
|
4935
5059
|
if (!ir || ir.v !== 1 || !exactKeys5(ir, ["v", "rule"])) throw new TypeError("Code Scorer IR is invalid");
|
|
4936
5060
|
return { v: 1, rule: scorerRule(ir.rule, 0, { rules: 0 }) };
|
|
4937
5061
|
}
|
|
@@ -4944,7 +5068,7 @@ function pointer(value, path2) {
|
|
|
4944
5068
|
if (!/^(?:0|[1-9][0-9]*)$/u.test(key) || Number(key) >= current.length) return { found: false, value: void 0 };
|
|
4945
5069
|
current = current[Number(key)];
|
|
4946
5070
|
} else {
|
|
4947
|
-
const source =
|
|
5071
|
+
const source = record13(current);
|
|
4948
5072
|
if (!source || !Object.hasOwn(source, key)) return { found: false, value: void 0 };
|
|
4949
5073
|
current = source[key];
|
|
4950
5074
|
}
|
|
@@ -4978,7 +5102,7 @@ function evaluate(rule, subject) {
|
|
|
4978
5102
|
if (!sources.found || !Array.isArray(sources.value)) return fail(rule.sourcesPath, "citation sources are missing");
|
|
4979
5103
|
const available = new Set(sources.value.flatMap((source, index) => {
|
|
4980
5104
|
if (typeof source === "string") return [source, String(index + 1)];
|
|
4981
|
-
const item =
|
|
5105
|
+
const item = record13(source);
|
|
4982
5106
|
return item ? [String(item.id ?? ""), String(index + 1)].filter(Boolean) : [String(index + 1)];
|
|
4983
5107
|
}));
|
|
4984
5108
|
const citations = [...text2.value.matchAll(/\[([^\]\n]{1,128})\]/gu)].map((match) => match[1].trim());
|
|
@@ -4997,7 +5121,7 @@ function evaluate(rule, subject) {
|
|
|
4997
5121
|
const contains = typeof selected.value === "string" && typeof rule.value === "string" ? selected.value.includes(rule.value) : Array.isArray(selected.value) && selected.value.some((value) => canonicalJson(value) === canonicalJson(rule.value));
|
|
4998
5122
|
return contains ? pass() : fail(rule.path, "value is not contained");
|
|
4999
5123
|
}
|
|
5000
|
-
const names = Array.isArray(selected.value) ? selected.value.map((item) => typeof item === "string" ? item : String(
|
|
5124
|
+
const names = Array.isArray(selected.value) ? selected.value.map((item) => typeof item === "string" ? item : String(record13(item)?.name ?? "")) : [];
|
|
5001
5125
|
const sequence = rule.mode === "exact" ? names.length === rule.expected.length && names.every((name, index) => name === rule.expected[index]) : rule.expected.reduce((cursor, expected) => {
|
|
5002
5126
|
const index = names.indexOf(expected, cursor);
|
|
5003
5127
|
return index < 0 ? Number.POSITIVE_INFINITY : index + 1;
|
|
@@ -5035,11 +5159,11 @@ var GENERAL_QUALITY_JUDGE = {
|
|
|
5035
5159
|
}
|
|
5036
5160
|
}
|
|
5037
5161
|
};
|
|
5038
|
-
function
|
|
5162
|
+
function record14(value) {
|
|
5039
5163
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
5040
5164
|
}
|
|
5041
5165
|
function question2(criterion, field2) {
|
|
5042
|
-
const source =
|
|
5166
|
+
const source = record14(criterion);
|
|
5043
5167
|
if (!source || source.instructions === void 0 || Object.keys(source).some((key) => key !== "instructions" && key !== "levels") || source.levels !== void 0 && (!Array.isArray(source.levels) || source.levels.length < 2)) {
|
|
5044
5168
|
throw new TypeError(`${field2} is { instructions, levels? } with at least two levels`);
|
|
5045
5169
|
}
|
|
@@ -5052,9 +5176,9 @@ function position(answer2, asked) {
|
|
|
5052
5176
|
throw new TypeError("evaluation answer does not match its rubric question");
|
|
5053
5177
|
}
|
|
5054
5178
|
function judged(message2) {
|
|
5055
|
-
const body =
|
|
5179
|
+
const body = record14(message2);
|
|
5056
5180
|
const state = body?.kind === "eval-judge" ? body.value : body?.task === "evaluate" ? { case: body.case, output: body.output } : void 0;
|
|
5057
|
-
const scale =
|
|
5181
|
+
const scale = record14(body?.scale);
|
|
5058
5182
|
if (!body || state === void 0 || typeof scale?.min !== "number" || typeof scale.max !== "number" || !Number.isFinite(scale.min) || !Number.isFinite(scale.max) || scale.min >= scale.max) {
|
|
5059
5183
|
throw new TypeError('a Judge is given { kind: "eval-judge", rubric, scale, value } or { task: "evaluate", rubric, scale, case, output }');
|
|
5060
5184
|
}
|
|
@@ -5066,8 +5190,8 @@ function judgeAgent(input) {
|
|
|
5066
5190
|
version: input.version,
|
|
5067
5191
|
async onMessage(message2, ctx) {
|
|
5068
5192
|
const { rubric, scale, state } = judged(message2);
|
|
5069
|
-
const source =
|
|
5070
|
-
const dimensions = source?.dimensions === void 0 ? {} :
|
|
5193
|
+
const source = record14(rubric);
|
|
5194
|
+
const dimensions = source?.dimensions === void 0 ? {} : record14(source.dimensions);
|
|
5071
5195
|
if (!source || !dimensions || Object.keys(source).some((key) => !["instructions", "levels", "dimensions"].includes(key))) {
|
|
5072
5196
|
throw new TypeError("a Judge rubric is { instructions, levels?, dimensions? }");
|
|
5073
5197
|
}
|
|
@@ -5093,9 +5217,9 @@ function judgeAgent(input) {
|
|
|
5093
5217
|
|
|
5094
5218
|
// packages/sdk/src/errors.ts
|
|
5095
5219
|
var GateExhausted = class extends Error {
|
|
5096
|
-
constructor(
|
|
5220
|
+
constructor(record15) {
|
|
5097
5221
|
super("turn gate exhausted");
|
|
5098
|
-
this.record =
|
|
5222
|
+
this.record = record15;
|
|
5099
5223
|
this.name = "GateExhausted";
|
|
5100
5224
|
}
|
|
5101
5225
|
record;
|
|
@@ -5349,6 +5473,11 @@ export {
|
|
|
5349
5473
|
SANDBOX_POOL_OPERATIONS,
|
|
5350
5474
|
SANDBOX_PROVIDER_FAILURE_CLASSES,
|
|
5351
5475
|
SANDBOX_PROVIDER_UNAVAILABLE,
|
|
5476
|
+
SANDBOX_TERMINAL_CHANNELS,
|
|
5477
|
+
SANDBOX_TERMINAL_EXIT_CODE_CAUSE,
|
|
5478
|
+
SANDBOX_TERMINAL_NONZERO_EXIT,
|
|
5479
|
+
SANDBOX_TERMINAL_PROTOCOL,
|
|
5480
|
+
SANDBOX_TERMINAL_TERM,
|
|
5352
5481
|
SessionDeleted,
|
|
5353
5482
|
SpawnCardinality,
|
|
5354
5483
|
SwallowedYield,
|
|
@@ -5418,6 +5547,8 @@ export {
|
|
|
5418
5547
|
cutPartitions,
|
|
5419
5548
|
dataShareEarningMicroUsd,
|
|
5420
5549
|
datasetName,
|
|
5550
|
+
decodeSandboxTerminalMessage,
|
|
5551
|
+
encodeSandboxTerminalMessage,
|
|
5421
5552
|
evaluateCodeScorer,
|
|
5422
5553
|
evaluatePolicyDefinition,
|
|
5423
5554
|
evaluationArguments,
|
|
@@ -5484,6 +5615,9 @@ export {
|
|
|
5484
5615
|
sandboxEgressHostMatches,
|
|
5485
5616
|
sandboxLimit,
|
|
5486
5617
|
sandboxProviderUnavailable,
|
|
5618
|
+
sandboxTerminalExitCode,
|
|
5619
|
+
sandboxTerminalExited,
|
|
5620
|
+
sandboxTerminalFailed,
|
|
5487
5621
|
scopedBindingKey,
|
|
5488
5622
|
scopedCredentialRef,
|
|
5489
5623
|
scopedResourceRef,
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@constal/sdk/sandbox-terminal`: a sandbox's terminal on the wire, the one definition every hop and client uses
|
|
3
|
+
* (docs/sandbox-terminal.md). A terminal is a WebSocket that speaks Kubernetes' `v5.channel.k8s.io`, the protocol
|
|
4
|
+
* client-go's WebSocket executor speaks: each binary message is one channel byte and its payload.
|
|
5
|
+
*
|
|
6
|
+
* - 0, stdin: the client's input to the terminal, raw bytes.
|
|
7
|
+
* - 1, stdout: the terminal's output, raw bytes, escapes and all.
|
|
8
|
+
* - 2, stderr: unused under a TTY, which merges it into stdout.
|
|
9
|
+
* - 3, error: the session's last message, a Kubernetes Status (SandboxTerminalStatus): Success, Failure with reason
|
|
10
|
+
* `NonZeroExitCode` and an `ExitCode` cause, or Failure with the door's reason and the provider's words.
|
|
11
|
+
* - 4, resize: the client's terminal size, `{"Width":<cols>,"Height":<rows>}`, each a uint16 (Kubernetes' TerminalSize).
|
|
12
|
+
* - 255, close: `[255, <channel>]`, a half-close of one stream. It is what v5 adds to v4: on a PTY, a close of stdin ends the
|
|
13
|
+
* client's input and sends nothing on, as a PTY has no end of input of its own (Ctrl-D is the byte 0x04).
|
|
14
|
+
*
|
|
15
|
+
* The server never half-closes: its last message is the channel-3 Status, and then it closes the socket with 1000.
|
|
16
|
+
*/
|
|
17
|
+
/** The subprotocol a terminal's WebSocket offers and is answered with (Sec-WebSocket-Protocol). */
|
|
18
|
+
declare const SANDBOX_TERMINAL_PROTOCOL = "v5.channel.k8s.io";
|
|
19
|
+
/** The terminal a session's PTY emulates, its `TERM`: xterm's 256-colour terminal, as xterm.js emulates it. */
|
|
20
|
+
declare const SANDBOX_TERMINAL_TERM = "xterm-256color";
|
|
21
|
+
/** Each channel of `v5.channel.k8s.io` and its byte. */
|
|
22
|
+
declare const SANDBOX_TERMINAL_CHANNELS: {
|
|
23
|
+
readonly stdin: 0;
|
|
24
|
+
readonly stdout: 1;
|
|
25
|
+
readonly stderr: 2;
|
|
26
|
+
readonly error: 3;
|
|
27
|
+
readonly resize: 4;
|
|
28
|
+
readonly close: 255;
|
|
29
|
+
};
|
|
30
|
+
type SandboxTerminalChannel = keyof typeof SANDBOX_TERMINAL_CHANNELS;
|
|
31
|
+
/** The channels that carry bytes. */
|
|
32
|
+
type SandboxTerminalStream = "stdin" | "stdout" | "stderr";
|
|
33
|
+
/** The channels a close (`[255, <channel>]`) names: every one but close itself. */
|
|
34
|
+
type SandboxTerminalClosable = Exclude<SandboxTerminalChannel, "close">;
|
|
35
|
+
/** A terminal's size, as Kubernetes' TerminalSize writes it: its columns (`Width`) and rows (`Height`), each a uint16. */
|
|
36
|
+
interface SandboxTerminalSize {
|
|
37
|
+
Width: number;
|
|
38
|
+
Height: number;
|
|
39
|
+
}
|
|
40
|
+
/** One cause of a Status, as Kubernetes' StatusCause writes it: its type (`reason`) and its message. */
|
|
41
|
+
interface SandboxTerminalStatusCause {
|
|
42
|
+
reason: string;
|
|
43
|
+
message: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The session's last message, on channel 3: Kubernetes' metav1.Status as its remotecommand v4 and later write it.
|
|
47
|
+
*
|
|
48
|
+
* - `Success`: the program exited 0.
|
|
49
|
+
* - `Failure`, `reason` `NonZeroExitCode`: the program exited with the code its one `ExitCode` cause names, as decimal;
|
|
50
|
+
* a program a signal ended has the shell's code for it, 128 and the signal's number.
|
|
51
|
+
* - `Failure`, any other `reason`: the session ended otherwise; `reason` is the door's error code, `message` its words
|
|
52
|
+
* (the provider's, where the provider ended it) and `code` its HTTP status.
|
|
53
|
+
*/
|
|
54
|
+
interface SandboxTerminalStatus {
|
|
55
|
+
metadata: Record<string, never>;
|
|
56
|
+
status: "Success" | "Failure";
|
|
57
|
+
reason?: string;
|
|
58
|
+
message?: string;
|
|
59
|
+
code?: number;
|
|
60
|
+
details?: {
|
|
61
|
+
causes: SandboxTerminalStatusCause[];
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** The reason of a Status for a program's own nonzero exit, and the type of its cause (Kubernetes' NonZeroExitCodeReason, ExitCodeCauseType). */
|
|
65
|
+
declare const SANDBOX_TERMINAL_NONZERO_EXIT = "NonZeroExitCode";
|
|
66
|
+
declare const SANDBOX_TERMINAL_EXIT_CODE_CAUSE = "ExitCode";
|
|
67
|
+
/** One message of `v5.channel.k8s.io`, by its channel. */
|
|
68
|
+
type SandboxTerminalMessage = {
|
|
69
|
+
channel: SandboxTerminalStream;
|
|
70
|
+
data: Uint8Array;
|
|
71
|
+
} | {
|
|
72
|
+
channel: "error";
|
|
73
|
+
status: SandboxTerminalStatus;
|
|
74
|
+
} | {
|
|
75
|
+
channel: "resize";
|
|
76
|
+
size: SandboxTerminalSize;
|
|
77
|
+
} | {
|
|
78
|
+
channel: "close";
|
|
79
|
+
stream: SandboxTerminalClosable;
|
|
80
|
+
};
|
|
81
|
+
/** The Status of a program's exit with `code`: Success for 0, else Failure `NonZeroExitCode` with its `ExitCode` cause. */
|
|
82
|
+
declare function sandboxTerminalExited(code: number): SandboxTerminalStatus;
|
|
83
|
+
/** The Status of a session that ended otherwise than by its program's exit: the door's error code, its words and its HTTP status. */
|
|
84
|
+
declare function sandboxTerminalFailed(reason: string, message: string, code: number): SandboxTerminalStatus;
|
|
85
|
+
/**
|
|
86
|
+
* The exit code a Status reports, as client-go reads it: 0 for Success, the `ExitCode` cause's for `NonZeroExitCode`, and
|
|
87
|
+
* null for a session that ended otherwise.
|
|
88
|
+
*/
|
|
89
|
+
declare function sandboxTerminalExitCode(status: SandboxTerminalStatus): number | null;
|
|
90
|
+
/** One message as its bytes on the wire: its channel's byte, then its payload. */
|
|
91
|
+
declare function encodeSandboxTerminalMessage(message: SandboxTerminalMessage): Uint8Array<ArrayBuffer>;
|
|
92
|
+
/** One message from its bytes on the wire; a TypeError says why bytes are no message of `v5.channel.k8s.io`. */
|
|
93
|
+
declare function decodeSandboxTerminalMessage(bytes: Uint8Array | ArrayBuffer): SandboxTerminalMessage;
|
|
94
|
+
|
|
95
|
+
export { SANDBOX_TERMINAL_CHANNELS, SANDBOX_TERMINAL_EXIT_CODE_CAUSE, SANDBOX_TERMINAL_NONZERO_EXIT, SANDBOX_TERMINAL_PROTOCOL, SANDBOX_TERMINAL_TERM, decodeSandboxTerminalMessage, encodeSandboxTerminalMessage, sandboxTerminalExitCode, sandboxTerminalExited, sandboxTerminalFailed };
|
|
96
|
+
export type { SandboxTerminalChannel, SandboxTerminalClosable, SandboxTerminalMessage, SandboxTerminalSize, SandboxTerminalStatus, SandboxTerminalStatusCause, SandboxTerminalStream };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// packages/sdk/src/sandbox-terminal.ts
|
|
2
|
+
var SANDBOX_TERMINAL_PROTOCOL = "v5.channel.k8s.io";
|
|
3
|
+
var SANDBOX_TERMINAL_TERM = "xterm-256color";
|
|
4
|
+
var SANDBOX_TERMINAL_CHANNELS = { stdin: 0, stdout: 1, stderr: 2, error: 3, resize: 4, close: 255 };
|
|
5
|
+
var SANDBOX_TERMINAL_NONZERO_EXIT = "NonZeroExitCode";
|
|
6
|
+
var SANDBOX_TERMINAL_EXIT_CODE_CAUSE = "ExitCode";
|
|
7
|
+
function sandboxTerminalExited(code) {
|
|
8
|
+
if (!Number.isSafeInteger(code) || code < 0) throw new TypeError("an exit code is a whole number");
|
|
9
|
+
if (code === 0) return { metadata: {}, status: "Success" };
|
|
10
|
+
return {
|
|
11
|
+
metadata: {},
|
|
12
|
+
status: "Failure",
|
|
13
|
+
reason: SANDBOX_TERMINAL_NONZERO_EXIT,
|
|
14
|
+
message: `command terminated with non-zero exit code ${code}`,
|
|
15
|
+
details: { causes: [{ reason: SANDBOX_TERMINAL_EXIT_CODE_CAUSE, message: String(code) }] }
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function sandboxTerminalFailed(reason, message, code) {
|
|
19
|
+
return { metadata: {}, status: "Failure", reason, message, code };
|
|
20
|
+
}
|
|
21
|
+
function sandboxTerminalExitCode(status2) {
|
|
22
|
+
if (status2.status === "Success") return 0;
|
|
23
|
+
if (status2.reason !== SANDBOX_TERMINAL_NONZERO_EXIT) return null;
|
|
24
|
+
const cause = status2.details?.causes.find((entry) => entry.reason === SANDBOX_TERMINAL_EXIT_CODE_CAUSE);
|
|
25
|
+
return cause && /^\d+$/u.test(cause.message) ? Number(cause.message) : null;
|
|
26
|
+
}
|
|
27
|
+
function channelName(name) {
|
|
28
|
+
return Object.hasOwn(SANDBOX_TERMINAL_CHANNELS, name);
|
|
29
|
+
}
|
|
30
|
+
var CHANNEL_NAMES = new Map(
|
|
31
|
+
Object.keys(SANDBOX_TERMINAL_CHANNELS).filter(channelName).map((name) => [SANDBOX_TERMINAL_CHANNELS[name], name])
|
|
32
|
+
);
|
|
33
|
+
var UINT16_MAX = 65535;
|
|
34
|
+
function uint16(value) {
|
|
35
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= UINT16_MAX;
|
|
36
|
+
}
|
|
37
|
+
function framed(channel, payload) {
|
|
38
|
+
const message = new Uint8Array(1 + payload.byteLength);
|
|
39
|
+
message[0] = channel;
|
|
40
|
+
message.set(payload, 1);
|
|
41
|
+
return message;
|
|
42
|
+
}
|
|
43
|
+
function encodeSandboxTerminalMessage(message) {
|
|
44
|
+
const byte = SANDBOX_TERMINAL_CHANNELS[message.channel];
|
|
45
|
+
switch (message.channel) {
|
|
46
|
+
case "stdin":
|
|
47
|
+
case "stdout":
|
|
48
|
+
case "stderr":
|
|
49
|
+
return framed(byte, message.data);
|
|
50
|
+
case "error":
|
|
51
|
+
return framed(byte, new TextEncoder().encode(JSON.stringify(message.status)));
|
|
52
|
+
case "resize": {
|
|
53
|
+
if (!uint16(message.size.Width) || !uint16(message.size.Height)) throw new TypeError("a terminal's Width and Height are each a uint16");
|
|
54
|
+
return framed(byte, new TextEncoder().encode(JSON.stringify({ Width: message.size.Width, Height: message.size.Height })));
|
|
55
|
+
}
|
|
56
|
+
case "close":
|
|
57
|
+
return framed(byte, Uint8Array.of(SANDBOX_TERMINAL_CHANNELS[message.stream]));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function record(value) {
|
|
61
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
62
|
+
}
|
|
63
|
+
function json(payload, channel) {
|
|
64
|
+
let value;
|
|
65
|
+
try {
|
|
66
|
+
value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(payload));
|
|
67
|
+
} catch {
|
|
68
|
+
throw new TypeError(`a ${channel} message is a JSON object`);
|
|
69
|
+
}
|
|
70
|
+
const object = record(value);
|
|
71
|
+
if (!object) throw new TypeError(`a ${channel} message is a JSON object`);
|
|
72
|
+
return object;
|
|
73
|
+
}
|
|
74
|
+
function status(object) {
|
|
75
|
+
if (object.status !== "Success" && object.status !== "Failure") throw new TypeError("a Status is Success or Failure");
|
|
76
|
+
const read = { metadata: {}, status: object.status };
|
|
77
|
+
for (const field of ["reason", "message"]) {
|
|
78
|
+
const value = object[field];
|
|
79
|
+
if (value === void 0) continue;
|
|
80
|
+
if (typeof value !== "string") throw new TypeError(`a Status's ${field} is a string`);
|
|
81
|
+
read[field] = value;
|
|
82
|
+
}
|
|
83
|
+
if (object.code !== void 0) {
|
|
84
|
+
if (typeof object.code !== "number" || !Number.isInteger(object.code)) throw new TypeError("a Status's code is a whole number");
|
|
85
|
+
read.code = object.code;
|
|
86
|
+
}
|
|
87
|
+
const details = object.details === void 0 ? void 0 : record(object.details);
|
|
88
|
+
if (details === null) throw new TypeError("a Status's details are an object");
|
|
89
|
+
if (details?.causes !== void 0) {
|
|
90
|
+
if (!Array.isArray(details.causes)) throw new TypeError("a Status's causes are a list");
|
|
91
|
+
read.details = { causes: details.causes.map((entry) => {
|
|
92
|
+
const cause = record(entry);
|
|
93
|
+
return { reason: typeof cause?.reason === "string" ? cause.reason : "", message: typeof cause?.message === "string" ? cause.message : "" };
|
|
94
|
+
}) };
|
|
95
|
+
}
|
|
96
|
+
return read;
|
|
97
|
+
}
|
|
98
|
+
function decodeSandboxTerminalMessage(bytes) {
|
|
99
|
+
const message = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
100
|
+
if (message.byteLength === 0) throw new TypeError("a terminal message starts with its channel's byte");
|
|
101
|
+
const channel = CHANNEL_NAMES.get(message[0]);
|
|
102
|
+
const payload = message.subarray(1);
|
|
103
|
+
switch (channel) {
|
|
104
|
+
case "stdin":
|
|
105
|
+
case "stdout":
|
|
106
|
+
case "stderr":
|
|
107
|
+
return { channel, data: payload };
|
|
108
|
+
case "error":
|
|
109
|
+
return { channel, status: status(json(payload, channel)) };
|
|
110
|
+
case "resize": {
|
|
111
|
+
const size = json(payload, channel);
|
|
112
|
+
if (!uint16(size.Width) || !uint16(size.Height)) throw new TypeError("a terminal's Width and Height are each a uint16");
|
|
113
|
+
return { channel, size: { Width: size.Width, Height: size.Height } };
|
|
114
|
+
}
|
|
115
|
+
case "close": {
|
|
116
|
+
const stream = payload.byteLength === 1 ? CHANNEL_NAMES.get(payload[0]) : void 0;
|
|
117
|
+
if (stream === void 0 || stream === "close") throw new TypeError("a close names the one channel it closes");
|
|
118
|
+
return { channel, stream };
|
|
119
|
+
}
|
|
120
|
+
default:
|
|
121
|
+
throw new TypeError(`a terminal message has no channel ${message[0]}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
SANDBOX_TERMINAL_CHANNELS,
|
|
126
|
+
SANDBOX_TERMINAL_EXIT_CODE_CAUSE,
|
|
127
|
+
SANDBOX_TERMINAL_NONZERO_EXIT,
|
|
128
|
+
SANDBOX_TERMINAL_PROTOCOL,
|
|
129
|
+
SANDBOX_TERMINAL_TERM,
|
|
130
|
+
decodeSandboxTerminalMessage,
|
|
131
|
+
encodeSandboxTerminalMessage,
|
|
132
|
+
sandboxTerminalExitCode,
|
|
133
|
+
sandboxTerminalExited,
|
|
134
|
+
sandboxTerminalFailed
|
|
135
|
+
};
|