@drisp/protocol 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/v2.d.ts +7 -4
- package/dist/v2.js +8 -2
- package/package.json +1 -1
package/dist/v2.d.ts
CHANGED
|
@@ -13,11 +13,14 @@ type SizeClass = 'S' | 'M' | 'L';
|
|
|
13
13
|
declare const SIZE_CLASS_CAPS: Readonly<Record<SizeClass, number>>;
|
|
14
14
|
/** What a Run of each class is expected to use: default, not measured. */
|
|
15
15
|
declare const SIZE_CLASS_FORECASTS: Readonly<Record<SizeClass, number>>;
|
|
16
|
-
/** The smallest class whose cap is at least the declared one; above the largest cap is `L`. */
|
|
16
|
+
/** The smallest class whose cap is at least the declared one; above the largest cap is `L`. A cap that is no number reads as `S`. */
|
|
17
17
|
declare function classOfCap(declaredCap: number): SizeClass;
|
|
18
|
+
/** What a Run declaring `declaredCap` is expected to use: its class's forecast. */
|
|
19
|
+
declare function forecastOfCap(declaredCap: number): number;
|
|
18
20
|
/**
|
|
19
|
-
* What one attempt holds against the budget: a closed attempt (finished, failed, cancelled) its forecast
|
|
20
|
-
* or queued one still its
|
|
21
|
+
* What one attempt holds against the budget: a closed attempt (finished, failed, cancelled) its forecast, never more
|
|
22
|
+
* than its own declared cap (so the rule stays looser than the cap sum it replaces); a running or queued one still its
|
|
23
|
+
* declared cap. A closed attempt whose cap is no positive number counts its forecast.
|
|
21
24
|
*/
|
|
22
25
|
declare function attemptCost(attempt: {
|
|
23
26
|
tokenCap: number;
|
|
@@ -1424,4 +1427,4 @@ type ConnectPendingResponse = z.infer<typeof connectPendingResponseSchema>;
|
|
|
1424
1427
|
type TeamDefault = z.infer<typeof teamDefaultSchema>;
|
|
1425
1428
|
type RunsGoTo = z.infer<typeof runsGoToSchema>;
|
|
1426
1429
|
|
|
1427
|
-
export { type Audience, type BuildCloseReason, type Checkpoint, type Command, type ConnectAlreadyConnected, type ConnectPendingResponse, type ConnectRedeemRequest, type ConnectRedeemResponse, type ConnectStartRequest, type ConnectStartResponse, type ControlRecord, type Delegation, type ExecutionFact, type Grant, type Harness, type HarnessReadiness, type HistoryRecord, type InstalledWorkflow, type RepositoryBinding, type RepositorySource, type RunCloseReason, type RunParent, type RunView, type RunnerAdoptRequest, type RunnerDisconnectPreview, type RunnerDisconnectResponse, type RunnerFrame, type RunnerList, type RunnerListEntry, type RunnerReadiness, type RunsGoTo, SIZE_CLASS_CAPS, SIZE_CLASS_FORECASTS, type Scope, type SizeClass, type TeamDefault, type WorkflowIdentity, type WorkflowInstallReference, type WorkflowReference, abandonedConversationContinuationCapability, attemptCost, audienceSchema, buildCloseReasonSchema, canonicalJson, checkpointPathSchema, checkpointSchema, classOfCap, clientFrameSchema, commandSchema, connectAlreadyConnectedSchema, connectApproveRequestSchema, connectCodeAlphabet, connectCodeRequestSchema, connectCodeResponseSchema, connectCodeSchema, connectDenyRequestSchema, connectPendingResponseSchema, connectPollRequestSchema, connectRedeemRequestSchema, connectRedeemResponseSchema, connectStartRequestSchema, connectStartResponseSchema, controlRecordSchema, conversationContinuationCapability, delegationSchema, delegationTokenPrefix, grantSchema, harnessReadinessSchema, harnessSchema, historyRecordSchema, hubEpochRequestSchema, installReference, installedWorkflowsSchema, interruptionSchema, permissionAnswerSchema, protocolVersion, readableHistory, readinessFixCommand, repositoryAccessCapability, repositoryBindingSchema, repositoryRefSchema, repositorySourceSchema, repositoryWorkingDirectorySchema, runArtifactMaxBytes, runArtifactNameSchema, runCloseReasonSchema, runDelegationCapability, runKeySchema, runParentIntentSchema, runParentSchema, runSpecSchema, runViewSchema, runnerAdoptRequestSchema, runnerDisconnectPreviewSchema, runnerDisconnectRequestSchema, runnerDisconnectResponseSchema, runnerFrameSchema, runnerListEntrySchema, runnerListSchema, runnerReadinessSchema, runnerUpdateCommand, runnerUpdateRequestSchema, runsGoToSchema, sameWorkflow, scopeSchema, secretEnvironmentSchema, sequence, teamDefaultRequestSchema, teamDefaultSchema, workflowIdentitySchema, workflowInstallCapability, workflowName, workflowReferenceSchema, workflowSourceSchema };
|
|
1430
|
+
export { type Audience, type BuildCloseReason, type Checkpoint, type Command, type ConnectAlreadyConnected, type ConnectPendingResponse, type ConnectRedeemRequest, type ConnectRedeemResponse, type ConnectStartRequest, type ConnectStartResponse, type ControlRecord, type Delegation, type ExecutionFact, type Grant, type Harness, type HarnessReadiness, type HistoryRecord, type InstalledWorkflow, type RepositoryBinding, type RepositorySource, type RunCloseReason, type RunParent, type RunView, type RunnerAdoptRequest, type RunnerDisconnectPreview, type RunnerDisconnectResponse, type RunnerFrame, type RunnerList, type RunnerListEntry, type RunnerReadiness, type RunsGoTo, SIZE_CLASS_CAPS, SIZE_CLASS_FORECASTS, type Scope, type SizeClass, type TeamDefault, type WorkflowIdentity, type WorkflowInstallReference, type WorkflowReference, abandonedConversationContinuationCapability, attemptCost, audienceSchema, buildCloseReasonSchema, canonicalJson, checkpointPathSchema, checkpointSchema, classOfCap, clientFrameSchema, commandSchema, connectAlreadyConnectedSchema, connectApproveRequestSchema, connectCodeAlphabet, connectCodeRequestSchema, connectCodeResponseSchema, connectCodeSchema, connectDenyRequestSchema, connectPendingResponseSchema, connectPollRequestSchema, connectRedeemRequestSchema, connectRedeemResponseSchema, connectStartRequestSchema, connectStartResponseSchema, controlRecordSchema, conversationContinuationCapability, delegationSchema, delegationTokenPrefix, forecastOfCap, grantSchema, harnessReadinessSchema, harnessSchema, historyRecordSchema, hubEpochRequestSchema, installReference, installedWorkflowsSchema, interruptionSchema, permissionAnswerSchema, protocolVersion, readableHistory, readinessFixCommand, repositoryAccessCapability, repositoryBindingSchema, repositoryRefSchema, repositorySourceSchema, repositoryWorkingDirectorySchema, runArtifactMaxBytes, runArtifactNameSchema, runCloseReasonSchema, runDelegationCapability, runKeySchema, runParentIntentSchema, runParentSchema, runSpecSchema, runViewSchema, runnerAdoptRequestSchema, runnerDisconnectPreviewSchema, runnerDisconnectRequestSchema, runnerDisconnectResponseSchema, runnerFrameSchema, runnerListEntrySchema, runnerListSchema, runnerReadinessSchema, runnerUpdateCommand, runnerUpdateRequestSchema, runsGoToSchema, sameWorkflow, scopeSchema, secretEnvironmentSchema, sequence, teamDefaultRequestSchema, teamDefaultSchema, workflowIdentitySchema, workflowInstallCapability, workflowName, workflowReferenceSchema, workflowSourceSchema };
|
package/dist/v2.js
CHANGED
|
@@ -59,12 +59,17 @@ var SIZE_CLASS_FORECASTS = {
|
|
|
59
59
|
L: 12e5
|
|
60
60
|
};
|
|
61
61
|
function classOfCap(declaredCap) {
|
|
62
|
-
if (declaredCap <= SIZE_CLASS_CAPS.S) return "S";
|
|
62
|
+
if (Number.isNaN(declaredCap) || declaredCap <= SIZE_CLASS_CAPS.S) return "S";
|
|
63
63
|
if (declaredCap <= SIZE_CLASS_CAPS.M) return "M";
|
|
64
64
|
return "L";
|
|
65
65
|
}
|
|
66
|
+
function forecastOfCap(declaredCap) {
|
|
67
|
+
return SIZE_CLASS_FORECASTS[classOfCap(declaredCap)];
|
|
68
|
+
}
|
|
66
69
|
function attemptCost(attempt) {
|
|
67
|
-
|
|
70
|
+
if (!attempt.closed) return attempt.tokenCap;
|
|
71
|
+
const forecast = forecastOfCap(attempt.tokenCap);
|
|
72
|
+
return attempt.tokenCap > 0 ? Math.min(attempt.tokenCap, forecast) : forecast;
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
// src/v2.ts
|
|
@@ -648,6 +653,7 @@ export {
|
|
|
648
653
|
conversationContinuationCapability,
|
|
649
654
|
delegationSchema,
|
|
650
655
|
delegationTokenPrefix,
|
|
656
|
+
forecastOfCap,
|
|
651
657
|
grantSchema,
|
|
652
658
|
harnessReadinessSchema,
|
|
653
659
|
harnessSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drisp/protocol",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Wire contract between a drisp runner and the hub: zod schemas, inferred types, and JSON Schema for the instance-socket frames, Run, Turn, Interruption, and the event stream",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|