@drisp/protocol 0.8.0 → 0.8.1

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.
Files changed (3) hide show
  1. package/dist/v2.d.ts +21 -1
  2. package/dist/v2.js +24 -0
  3. package/package.json +1 -1
package/dist/v2.d.ts CHANGED
@@ -4,6 +4,26 @@ import { f as InstalledWorkflowSchema } from './domain-B-kg2pa_.js';
4
4
  /** Presentation of canonical fragment records; archive/cursor accounting always uses the original records. */
5
5
  declare function readableHistory(records: HistoryRecord[]): HistoryRecord[];
6
6
 
7
+ /**
8
+ * What a Build's children cost against its token budget (root ADR-0011). Tokens exclude cache reads. The forecasts
9
+ * are defaults, not measured; the caps are the per-Run ceilings the size classes declare.
10
+ */
11
+ type SizeClass = 'S' | 'M' | 'L';
12
+ /** Per-Run token cap of each size class. The largest class also bounds anything above it. */
13
+ declare const SIZE_CLASS_CAPS: Readonly<Record<SizeClass, number>>;
14
+ /** What a Run of each class is expected to use: default, not measured. */
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`. */
17
+ declare function classOfCap(declaredCap: number): SizeClass;
18
+ /**
19
+ * What one attempt holds against the budget: a closed attempt (finished, failed, cancelled) its forecast; a running
20
+ * or queued one still its declared cap.
21
+ */
22
+ declare function attemptCost(attempt: {
23
+ tokenCap: number;
24
+ closed: boolean;
25
+ }): number;
26
+
7
27
  declare const protocolVersion: {
8
28
  readonly major: 2;
9
29
  readonly minor: 2;
@@ -1404,4 +1424,4 @@ type ConnectPendingResponse = z.infer<typeof connectPendingResponseSchema>;
1404
1424
  type TeamDefault = z.infer<typeof teamDefaultSchema>;
1405
1425
  type RunsGoTo = z.infer<typeof runsGoToSchema>;
1406
1426
 
1407
- 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, type Scope, type TeamDefault, type WorkflowIdentity, type WorkflowInstallReference, type WorkflowReference, abandonedConversationContinuationCapability, audienceSchema, buildCloseReasonSchema, canonicalJson, checkpointPathSchema, checkpointSchema, 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 };
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 };
package/dist/v2.js CHANGED
@@ -47,6 +47,26 @@ function readableHistory(records) {
47
47
  return result;
48
48
  }
49
49
 
50
+ // src/budget.ts
51
+ var SIZE_CLASS_CAPS = {
52
+ S: 3e6,
53
+ M: 6e6,
54
+ L: 12e6
55
+ };
56
+ var SIZE_CLASS_FORECASTS = {
57
+ S: 15e4,
58
+ M: 4e5,
59
+ L: 12e5
60
+ };
61
+ function classOfCap(declaredCap) {
62
+ if (declaredCap <= SIZE_CLASS_CAPS.S) return "S";
63
+ if (declaredCap <= SIZE_CLASS_CAPS.M) return "M";
64
+ return "L";
65
+ }
66
+ function attemptCost(attempt) {
67
+ return attempt.closed ? SIZE_CLASS_FORECASTS[classOfCap(attempt.tokenCap)] : attempt.tokenCap;
68
+ }
69
+
50
70
  // src/v2.ts
51
71
  var protocolVersion = { major: 2, minor: 2 };
52
72
  var conversationContinuationCapability = "conversation_continuation";
@@ -599,12 +619,16 @@ var connectApproveRequestSchema = z.strictObject({
599
619
  });
600
620
  var connectDenyRequestSchema = z.strictObject({ code: z.string().min(8).max(16) });
601
621
  export {
622
+ SIZE_CLASS_CAPS,
623
+ SIZE_CLASS_FORECASTS,
602
624
  abandonedConversationContinuationCapability,
625
+ attemptCost,
603
626
  audienceSchema,
604
627
  buildCloseReasonSchema,
605
628
  canonicalJson,
606
629
  checkpointPathSchema,
607
630
  checkpointSchema,
631
+ classOfCap,
608
632
  clientFrameSchema,
609
633
  commandSchema,
610
634
  connectAlreadyConnectedSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drisp/protocol",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
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",