@intentic/sandbox-contract 1.299.0 → 1.300.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 (151) hide show
  1. package/dist/contracts/agent.contract.d.ts +771 -8
  2. package/dist/contracts/agent.contract.d.ts.map +1 -1
  3. package/dist/contracts/agent.contract.js +3 -2
  4. package/dist/contracts/agent.contract.js.map +1 -1
  5. package/dist/contracts/agents.contract.d.ts +0 -81
  6. package/dist/contracts/agents.contract.d.ts.map +1 -1
  7. package/dist/contracts/capabilities.contract.d.ts +6 -1
  8. package/dist/contracts/capabilities.contract.d.ts.map +1 -1
  9. package/dist/contracts/capabilities.contract.js +3 -2
  10. package/dist/contracts/capabilities.contract.js.map +1 -1
  11. package/dist/contracts/exit.contract.d.ts +15 -3
  12. package/dist/contracts/exit.contract.d.ts.map +1 -1
  13. package/dist/contracts/exit.contract.js +5 -4
  14. package/dist/contracts/exit.contract.js.map +1 -1
  15. package/dist/contracts/host.contract.d.ts +24 -2
  16. package/dist/contracts/host.contract.d.ts.map +1 -1
  17. package/dist/contracts/host.contract.js +4 -3
  18. package/dist/contracts/host.contract.js.map +1 -1
  19. package/dist/contracts/intentic.contract.d.ts +10 -2
  20. package/dist/contracts/intentic.contract.d.ts.map +1 -1
  21. package/dist/contracts/intentic.contract.js +4 -3
  22. package/dist/contracts/intentic.contract.js.map +1 -1
  23. package/dist/contracts/netdisk.contract.d.ts +5 -1
  24. package/dist/contracts/netdisk.contract.d.ts.map +1 -1
  25. package/dist/contracts/netdisk.contract.js +3 -2
  26. package/dist/contracts/netdisk.contract.js.map +1 -1
  27. package/dist/contracts/runner.contract.d.ts +505 -18
  28. package/dist/contracts/runner.contract.d.ts.map +1 -1
  29. package/dist/contracts/runner.contract.js +4 -3
  30. package/dist/contracts/runner.contract.js.map +1 -1
  31. package/dist/contracts/sessions.contract.d.ts +0 -1
  32. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  33. package/dist/contracts/settings.contract.d.ts +0 -33
  34. package/dist/contracts/settings.contract.d.ts.map +1 -1
  35. package/dist/contracts/system.contract.d.ts +333 -8
  36. package/dist/contracts/system.contract.d.ts.map +1 -1
  37. package/dist/contracts/system.contract.js +5 -4
  38. package/dist/contracts/system.contract.js.map +1 -1
  39. package/dist/contracts/vpn.contract.d.ts +5 -1
  40. package/dist/contracts/vpn.contract.d.ts.map +1 -1
  41. package/dist/contracts/vpn.contract.js +3 -2
  42. package/dist/contracts/vpn.contract.js.map +1 -1
  43. package/dist/contracts/workspace.contract.d.ts +1 -0
  44. package/dist/contracts/workspace.contract.d.ts.map +1 -1
  45. package/dist/events/agent-events.d.ts +1 -15
  46. package/dist/events/agent-events.d.ts.map +1 -1
  47. package/dist/events/agent-events.js +0 -10
  48. package/dist/events/agent-events.js.map +1 -1
  49. package/dist/events/system-events.d.ts +0 -10
  50. package/dist/events/system-events.d.ts.map +1 -1
  51. package/dist/events/transcript.d.ts +0 -6
  52. package/dist/events/transcript.d.ts.map +1 -1
  53. package/dist/events/transcript.js +1 -1
  54. package/dist/events/transcript.js.map +1 -1
  55. package/dist/index.d.ts +1176 -171
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +0 -2
  58. package/dist/index.js.map +1 -1
  59. package/dist/models/model-order.d.ts +0 -2
  60. package/dist/models/model-order.d.ts.map +1 -1
  61. package/dist/models/model-order.js +0 -13
  62. package/dist/models/model-order.js.map +1 -1
  63. package/dist/protocol/routes.d.ts +6 -0
  64. package/dist/protocol/routes.d.ts.map +1 -1
  65. package/dist/protocol/routes.js +12 -4
  66. package/dist/protocol/routes.js.map +1 -1
  67. package/dist/schemas/agent.d.ts +0 -1
  68. package/dist/schemas/agent.d.ts.map +1 -1
  69. package/dist/schemas/agent.js +0 -4
  70. package/dist/schemas/agent.js.map +1 -1
  71. package/dist/schemas/agents.d.ts +0 -15
  72. package/dist/schemas/agents.d.ts.map +1 -1
  73. package/dist/schemas/agents.js +0 -8
  74. package/dist/schemas/agents.js.map +1 -1
  75. package/dist/schemas/automations.d.ts +0 -5
  76. package/dist/schemas/automations.d.ts.map +1 -1
  77. package/dist/schemas/capabilities.d.ts +1 -0
  78. package/dist/schemas/capabilities.d.ts.map +1 -1
  79. package/dist/schemas/capabilities.js +1 -0
  80. package/dist/schemas/capabilities.js.map +1 -1
  81. package/dist/schemas/devices.d.ts +1 -0
  82. package/dist/schemas/devices.d.ts.map +1 -1
  83. package/dist/schemas/devices.js +43 -24
  84. package/dist/schemas/devices.js.map +1 -1
  85. package/dist/schemas/providers/usage.d.ts +0 -6
  86. package/dist/schemas/providers/usage.d.ts.map +1 -1
  87. package/dist/schemas/providers/usage.js +0 -6
  88. package/dist/schemas/providers/usage.js.map +1 -1
  89. package/dist/schemas/settings.d.ts +0 -31
  90. package/dist/schemas/settings.d.ts.map +1 -1
  91. package/dist/schemas/settings.js +0 -23
  92. package/dist/schemas/settings.js.map +1 -1
  93. package/dist/schemas/workspace/workspace-search.d.ts +1 -0
  94. package/dist/schemas/workspace/workspace-search.d.ts.map +1 -1
  95. package/dist/schemas/workspace/workspace-search.js +5 -0
  96. package/dist/schemas/workspace/workspace-search.js.map +1 -1
  97. package/dist/state/definition.d.ts +0 -12
  98. package/dist/state/definition.d.ts.map +1 -1
  99. package/dist/state/history-state.d.ts.map +1 -1
  100. package/dist/state/history-state.js +1 -0
  101. package/dist/state/history-state.js.map +1 -1
  102. package/dist/state/workspace-state.d.ts +6 -0
  103. package/dist/state/workspace-state.d.ts.map +1 -1
  104. package/dist/state/workspace-state.js +7 -0
  105. package/dist/state/workspace-state.js.map +1 -1
  106. package/dist/text/transcript-fold.d.ts.map +1 -1
  107. package/dist/text/transcript-fold.js +0 -4
  108. package/dist/text/transcript-fold.js.map +1 -1
  109. package/package.json +5 -5
  110. package/src/contracts/agent.contract.ts +3 -2
  111. package/src/contracts/capabilities.contract.ts +3 -2
  112. package/src/contracts/exit.contract.ts +5 -4
  113. package/src/contracts/host.contract.ts +4 -3
  114. package/src/contracts/intentic.contract.ts +4 -3
  115. package/src/contracts/netdisk.contract.ts +3 -2
  116. package/src/contracts/runner.contract.ts +4 -3
  117. package/src/contracts/system.contract.ts +5 -4
  118. package/src/contracts/vpn.contract.ts +3 -2
  119. package/src/events/agent-events.ts +0 -14
  120. package/src/events/transcript.ts +1 -1
  121. package/src/index.ts +0 -2
  122. package/src/models/model-order.test.ts +1 -51
  123. package/src/models/model-order.ts +1 -23
  124. package/src/models/model-pins.ts +2 -2
  125. package/src/protocol/routes.test.ts +51 -18
  126. package/src/protocol/routes.ts +26 -6
  127. package/src/schemas/agent.ts +0 -8
  128. package/src/schemas/agents.ts +0 -11
  129. package/src/schemas/capabilities.ts +3 -0
  130. package/src/schemas/devices.ts +75 -29
  131. package/src/schemas/model-route.ts +1 -1
  132. package/src/schemas/providers/usage.ts +0 -11
  133. package/src/schemas/settings.ts +0 -52
  134. package/src/schemas/workspace/workspace-search.ts +7 -0
  135. package/src/state/history-state.ts +3 -0
  136. package/src/state/workspace-state.test.ts +13 -5
  137. package/src/state/workspace-state.ts +11 -0
  138. package/src/text/transcript-fold.test.ts +0 -17
  139. package/src/text/transcript-fold.ts +0 -5
  140. package/dist/models/fast-tier.d.ts +0 -9
  141. package/dist/models/fast-tier.d.ts.map +0 -1
  142. package/dist/models/fast-tier.js +0 -19
  143. package/dist/models/fast-tier.js.map +0 -1
  144. package/dist/models/prompt-complexity.d.ts +0 -27
  145. package/dist/models/prompt-complexity.d.ts.map +0 -1
  146. package/dist/models/prompt-complexity.js +0 -91
  147. package/dist/models/prompt-complexity.js.map +0 -1
  148. package/src/models/fast-tier.test.ts +0 -77
  149. package/src/models/fast-tier.ts +0 -36
  150. package/src/models/prompt-complexity.test.ts +0 -177
  151. package/src/models/prompt-complexity.ts +0 -215
@@ -1,215 +0,0 @@
1
- // Judges whether a turn could run on the cheap rung of the provider the user is already on: a pure function over the
2
- // turn's shape, no model or catalog access. Never fails up: every ambiguous case resolves to standard, since
3
- // substituting a pricier model would just be honoring the original request.
4
-
5
- // A verdict lists these, the shadow ledger stores them, a screen renders them: renaming one is a breaking change.
6
- export type ComplexityRule =
7
- // Gates: any one ends the question, standard with no score computed.
8
- | "images"
9
- | "plan-mode"
10
- | "unattended"
11
- // Escalating rules: any one forces standard; order between them cannot matter.
12
- | "code-block"
13
- | "stack-trace"
14
- | "hard-words"
15
- | "multi-step"
16
- | "cross-cutting"
17
- | "long-prompt"
18
- | "many-attachments"
19
- // Graded features: these only move the score.
20
- | "medium-prompt"
21
- | "attachment"
22
- | "editor-context"
23
- | "paths"
24
- | "many-verbs"
25
- | "after-hard-turn"
26
- | "short-prompt"
27
- | "easy-words"
28
- | "bare-question"
29
- | "no-workspace-reference";
30
-
31
- export type ComplexityTier = "fast" | "standard";
32
-
33
- // Everything the judge may know: primitive counts, flags and the prompt itself, no shared objects, so the daemon's turn
34
- // and the composer's draft can each build one independently.
35
- export interface ComplexityInput {
36
- readonly prompt: string;
37
- // Uploaded files plus @-mentioned workspace paths, resolved by the daemon into one count.
38
- readonly attachments: number;
39
- // Any attachment the model will read as an image; a cheap rung misreading one is the worst cell in the matrix.
40
- readonly hasImages: boolean;
41
- // The opt-in editor chip: the user pointed at a file and a selection, so the turn is about real code.
42
- readonly editorContext: boolean;
43
- // A surface started this, not a person at a composer (AgentTurn.unattended).
44
- readonly unattended: boolean;
45
- // The turn opens in plan mode: it is being asked to think before it acts.
46
- readonly planMode: boolean;
47
- // Whether the prior turn's judgement (not what it ran) was standard; a weight that raises the bar, not a lock.
48
- readonly afterHardTurn: boolean;
49
- // settings.autoTierEagerness; absent means balanced, what every pre-knob verdict was judged against.
50
- readonly eagerness?: TierEagerness;
51
- }
52
-
53
- export interface ComplexityVerdict {
54
- readonly tier: ComplexityTier;
55
- // 0..1, rounded to three places so ledger rows compare exactly; 1 whenever a gate or escalating rule fired.
56
- readonly score: number;
57
- // Every rule that fired, in declaration order; empty means the base score, above the fast ceiling.
58
- readonly rules: readonly ComplexityRule[];
59
- // The ceiling this score was judged against, carried out since the ceiling is itself a setting that can change.
60
- readonly ceiling: number;
61
- }
62
-
63
- // Above the fast ceiling on purpose: a prompt matching no rule at all is medium, not simple.
64
- const BASE_SCORE = 0.5;
65
-
66
- // How eager the judge is (settings.autoTierEagerness), the one knob this feature exposes:
67
- // - cautious: floor of 0, downgrades only the clearest easy asks
68
- // - balanced: the shipped default; every verdict before this knob existed was judged against it
69
- // - eager: also lets an easy-worded question about real code through
70
- export const FAST_CEILINGS = { cautious: 0, balanced: 0.25, eager: 0.4 } as const;
71
- export type TierEagerness = keyof typeof FAST_CEILINGS;
72
-
73
- // The stop used when nobody chose one: balanced, what every pre-knob verdict was judged against.
74
- export const FAST_CEILING = FAST_CEILINGS.balanced;
75
-
76
- // Characters, not tokens: thresholds mark a sentence turning into a brief, or carrying unfenced paste.
77
- const MEDIUM_PROMPT_CHARS = 600;
78
- const LONG_PROMPT_CHARS = 2400;
79
- const SHORT_PROMPT_CHARS = 140;
80
- // Three files in is a job about a shape rather than about a file, whatever the words say.
81
- const MANY_ATTACHMENTS = 3;
82
- // Three or more distinct imperatives is a list of jobs wearing the grammar of one.
83
- const MANY_VERBS = 3;
84
-
85
- // Short, boring word lists, case-insensitive on word boundaries; easy only lowers score, hard forces standard.
86
- const EASY_WORDS =
87
- /\b(?:what(?:'s| is| are)|explain|describe|summari[sz]e|list|show me|where(?:'s| is| are)|rename|typo|reword|reformat|format this|tidy|define|translate|spell|abbreviat)/i;
88
-
89
- const HARD_WORDS =
90
- /\b(?:refactor|redesign|architect|architecture|migrat|root cause|debug|investigat|diagnos|optimi[sz]|race condition|deadlock|memory leak|regression|security|threat model|benchmark|profil|audit|design a|plan (?:a|the|out)|why (?:does|is|are|did|would|can't|cannot))/i;
91
-
92
- // "Do this, and also that": the strongest cheap signal of a job that is several jobs.
93
- const MULTI_STEP = /\b(?:and then|after that|once (?:that|you)|followed by|as well as|then also)\b/i;
94
-
95
- // A job whose subject is the shape of the codebase, not a place in it; the cheap rung is worst at exactly this.
96
- const CROSS_CUTTING =
97
- /\b(?:across (?:the|all|every)|every(?: single)? (?:file|module|package|component|usage|call ?site)|all (?:the|of the) (?:files|usages|call ?sites|places)|everywhere|throughout the|codebase-wide|repo-wide)\b/i;
98
-
99
- // Fenced code, a diff, or an inline patch: proof the turn is real code, where the cheap rung fails silently.
100
- const CODE_BLOCK = /```|^diff --git |^@@ .* @@|^[+-]{3} [ab]\//m;
101
-
102
- // A thrown error the user pasted in: the canonical case where the expensive tier earns its price.
103
- const STACK_TRACE =
104
- /(?:^|\n)\s*(?:at [\w$.<>]+ \(|Traceback \(most recent call last\)|Caused by:|panic:|thread '.*' panicked|Unhandled|[A-Z]\w*(?:Error|Exception): )/;
105
-
106
- // A workspace path or @-mention, distinguishing "explain closures" from "explain what this file does".
107
- const PATH_LIKE =
108
- /(?:^|\s)(?:@[\w./-]+|[\w-]+\/[\w./-]+\.[a-z]{1,5}\b|\b[\w-]+\.(?:ts|tsx|js|jsx|vue|py|go|rs|java|rb|css|scss|json|ya?ml|md|sql|sh)\b)/i;
109
-
110
- // One sentence, ending in a question mark, with no second clause: knowledge, not work.
111
- const BARE_QUESTION = /^[^.!?]{0,200}\?\s*$/;
112
-
113
- // Imperatives that start a request, counted rather than matched: one is a task, three is a list.
114
- const VERBS =
115
- /\b(?:add|remove|delete|fix|write|create|make|update|change|move|rename|split|merge|extract|inline|wire|hook|test|check|run|build|deploy|document|implement|replace|convert|handle|support|expose|log|render|validate|parse|sort|filter|cache)\b/gi;
116
-
117
- // Bullets and numbered steps, a checklist however casually it is written.
118
- const LIST_LINES = /^\s*(?:[-*+]\s|\d+[.)]\s)/gm;
119
-
120
- // Every rule that ends the question on its own; split from the graded features below because these are answers, not
121
- // evidence.
122
- const forcing = (input: ComplexityInput, text: string): ComplexityRule[] => {
123
- const rules: ComplexityRule[] = [];
124
- // Gates first, cheapest and least arguable: about the turn's situation rather than its words.
125
- if (input.hasImages) {
126
- rules.push("images");
127
- }
128
- if (input.planMode) {
129
- rules.push("plan-mode");
130
- }
131
- // Unattended turns are billed whole with nobody watching a bad guess.
132
- if (input.unattended) {
133
- rules.push("unattended");
134
- }
135
- // Then the words: each of these claims the turn is about real code doing something real.
136
- if (CODE_BLOCK.test(text)) {
137
- rules.push("code-block");
138
- }
139
- if (STACK_TRACE.test(text)) {
140
- rules.push("stack-trace");
141
- }
142
- if (HARD_WORDS.test(text)) {
143
- rules.push("hard-words");
144
- }
145
- if (MULTI_STEP.test(text) || (text.match(LIST_LINES)?.length ?? 0) >= 2) {
146
- rules.push("multi-step");
147
- }
148
- if (CROSS_CUTTING.test(text)) {
149
- rules.push("cross-cutting");
150
- }
151
- if (text.length > LONG_PROMPT_CHARS) {
152
- rules.push("long-prompt");
153
- }
154
- if (input.attachments >= MANY_ATTACHMENTS) {
155
- rules.push("many-attachments");
156
- }
157
- return rules;
158
- };
159
-
160
- // Weights are a fitted hypothesis with a ledger under them, not a claim (ships in shadow first). A fast verdict always
161
- // requires a positive `easing` feature to have fired: absence of complexity is not evidence of simplicity.
162
- interface GradedFeature {
163
- readonly rule: ComplexityRule;
164
- readonly weight: number;
165
- readonly of: (input: ComplexityInput, text: string) => boolean;
166
- // A positive reason to think this is easy, not merely an absence of reasons to think it is hard.
167
- readonly easing?: true;
168
- }
169
-
170
- const GRADED: readonly GradedFeature[] = [
171
- { rule: "medium-prompt", weight: +0.2, of: (_input, text) => text.length > MEDIUM_PROMPT_CHARS },
172
- { rule: "attachment", weight: +0.15, of: (input) => input.attachments > 0 },
173
- { rule: "editor-context", weight: +0.1, of: (input) => input.editorContext },
174
- // Naming a file holds an easy-worded question at standard on balanced; eager is the choice to let it through.
175
- { rule: "paths", weight: +0.15, of: (_input, text) => PATH_LIKE.test(text) },
176
- {
177
- rule: "many-verbs",
178
- weight: +0.15,
179
- of: (_input, text) => new Set((text.match(VERBS) ?? []).map((verb) => verb.toLowerCase())).size >= MANY_VERBS,
180
- },
181
- // The heaviest weight: the only feature seeing past the words, heavy enough eager cannot downgrade past it.
182
- { rule: "after-hard-turn", weight: +0.25, of: (input) => input.afterHardTurn },
183
- // Declared in ledger order. `easing` marks the two positive signals; the rest are light absence features.
184
- { rule: "short-prompt", weight: -0.1, of: (_input, text) => text.length <= SHORT_PROMPT_CHARS },
185
- { rule: "easy-words", weight: -0.25, easing: true, of: (_input, text) => EASY_WORDS.test(text) },
186
- { rule: "bare-question", weight: -0.15, easing: true, of: (_input, text) => BARE_QUESTION.test(text) },
187
- {
188
- rule: "no-workspace-reference",
189
- weight: -0.1,
190
- of: (input, text) => input.attachments === 0 && !input.editorContext && !PATH_LIKE.test(text),
191
- },
192
- ];
193
-
194
- // Three places, so a stored score is a value not a float artefact, and same-rule rows compare equal.
195
- const round3 = (value: number): number => Math.round(value * 1000) / 1000;
196
-
197
- // Gates and escalators force standard at score 1 (monotone: a new rule only moves turns up a tier). Fast otherwise
198
- // needs both a sub-ceiling score and a positive `easing` signal; silence alone never downgrades.
199
- export const judgeComplexity = (input: ComplexityInput): ComplexityVerdict => {
200
- const ceiling = FAST_CEILINGS[input.eagerness ?? "balanced"];
201
- const text = input.prompt.trim();
202
- const forced = forcing(input, text);
203
- if (forced.length > 0) {
204
- return { tier: "standard", score: 1, rules: forced, ceiling };
205
- }
206
- const hits = GRADED.filter((feature) => feature.of(input, text));
207
- const score = Math.min(1, Math.max(0, BASE_SCORE + hits.reduce((total, feature) => total + feature.weight, 0)));
208
- const eased = hits.some((feature) => feature.easing === true);
209
- return {
210
- tier: eased && score <= ceiling ? "fast" : "standard",
211
- score: round3(score),
212
- rules: hits.map((feature) => feature.rule),
213
- ceiling,
214
- };
215
- };