@thready-web/dsh-bot-plugin 0.1.0-beta.1 → 0.1.0-beta.10

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 (144) hide show
  1. package/README.md +109 -1
  2. package/client.js +646 -621
  3. package/dist/approvals.js +160 -0
  4. package/dist/authorization.js +225 -0
  5. package/dist/cli.js +32 -12
  6. package/dist/context.js +59 -17
  7. package/dist/cron.js +1 -1
  8. package/dist/cua-access.js +79 -0
  9. package/dist/desk.js +314 -37
  10. package/dist/engine.js +178 -84
  11. package/dist/fs-safe.js +1 -1
  12. package/dist/host.js +1 -0
  13. package/dist/http-plugin.js +14 -4
  14. package/dist/http.js +383 -85
  15. package/dist/inbox.js +51 -40
  16. package/dist/index.js +190 -47
  17. package/dist/live-diff.js +3 -1
  18. package/dist/live-snapshot.js +2 -13
  19. package/dist/log/canonical.js +37 -0
  20. package/dist/log/plan.js +62 -0
  21. package/dist/log/routes.js +144 -0
  22. package/dist/log/snapshot-service.js +76 -0
  23. package/dist/log/source.js +173 -0
  24. package/dist/memory-catalog.js +798 -0
  25. package/dist/permissions.js +86 -0
  26. package/dist/provision.js +2 -0
  27. package/dist/questions.js +407 -0
  28. package/dist/runtime-registry.js +4 -4
  29. package/dist/session-files.js +2 -2
  30. package/dist/session-previews.js +5 -1
  31. package/dist/store.js +20 -5
  32. package/dist/tools.js +150 -32
  33. package/dist/triggers.js +83 -39
  34. package/dist/work-admit.js +222 -25
  35. package/dist/work-child.js +17 -9
  36. package/dist/work-http.js +33 -2
  37. package/dist/work-ledger.js +256 -16
  38. package/dist/work-mock-host.js +9 -6
  39. package/dist/work-mock.js +29 -19
  40. package/dist/work-tickets.js +423 -96
  41. package/dist/work-tools.js +43 -6
  42. package/dist/work-worker.js +1028 -207
  43. package/dist/workspace-files.js +319 -0
  44. package/dist/workspace-image.js +91 -0
  45. package/fixtures/mock-llm.mjs +17 -2
  46. package/package.json +15 -5
  47. package/public/assets/SourceEditor-BEQaScgR.js +669 -0
  48. package/public/assets/SourceEditor-CJwK846Z.css +1 -0
  49. package/public/assets/abap-CRCWOmpq.js +1 -0
  50. package/public/assets/apex-DnsZk_dE.js +1 -0
  51. package/public/assets/azcli-1IWB1ccx.js +1 -0
  52. package/public/assets/bat-DPkNLes8.js +1 -0
  53. package/public/assets/bicep-Corcdgou.js +2 -0
  54. package/public/assets/cameligo-CGrWLZr3.js +1 -0
  55. package/public/assets/clojure-D9WOWImG.js +1 -0
  56. package/public/assets/codicon-DCmgc-ay.ttf +0 -0
  57. package/public/assets/coffee-B7EJu28W.js +1 -0
  58. package/public/assets/cpp-SEyurbux.js +1 -0
  59. package/public/assets/csharp-BoL64M5l.js +1 -0
  60. package/public/assets/csp-C46ZqvIl.js +1 -0
  61. package/public/assets/css-DQU6DXDx.js +3 -0
  62. package/public/assets/css.worker-DYpkewsP.js +79 -0
  63. package/public/assets/cssMode-gpcjCFFS.js +4 -0
  64. package/public/assets/cypher-D84EuPTj.js +1 -0
  65. package/public/assets/dart-D8lhlL1r.js +1 -0
  66. package/public/assets/dockerfile-DLk6rpji.js +1 -0
  67. package/public/assets/ecl-BO6FnfXk.js +1 -0
  68. package/public/assets/editor.worker-B4pQIWZD.js +12 -0
  69. package/public/assets/elixir-BRjLKONM.js +1 -0
  70. package/public/assets/flow9-Cac8vKd7.js +1 -0
  71. package/public/assets/freemarker2-C1qemGIt.js +3 -0
  72. package/public/assets/fsharp-fd1GTHhf.js +1 -0
  73. package/public/assets/go-O9LJTZXk.js +1 -0
  74. package/public/assets/graphql-LQdxqEYJ.js +1 -0
  75. package/public/assets/handlebars-sZqIfAlP.js +1 -0
  76. package/public/assets/hcl-DxDQ3s82.js +1 -0
  77. package/public/assets/html-Bn1WXB8L.js +1 -0
  78. package/public/assets/html.worker-tnXziJOq.js +456 -0
  79. package/public/assets/htmlMode-CvQyXnaW.js +4 -0
  80. package/public/assets/index-DRNkUrer.css +1 -0
  81. package/public/assets/index-DhL5Kdlz.js +63 -0
  82. package/public/assets/ini-BvajGCUy.js +1 -0
  83. package/public/assets/java-SYsfObOQ.js +1 -0
  84. package/public/assets/javascript-Ox4Jg12j.js +1 -0
  85. package/public/assets/json.worker-aFakAbRR.js +44 -0
  86. package/public/assets/jsonMode-DMR7R2dQ.js +10 -0
  87. package/public/assets/julia-DQXNmw_w.js +1 -0
  88. package/public/assets/kotlin-qQ0MG-9I.js +1 -0
  89. package/public/assets/less-GGFNNJHn.js +2 -0
  90. package/public/assets/lexon-Canl7DCW.js +1 -0
  91. package/public/assets/liquid-B6HxtpBd.js +1 -0
  92. package/public/assets/lua-D28Ae8-K.js +1 -0
  93. package/public/assets/m3-DPitgjJI.js +1 -0
  94. package/public/assets/markdown-B811l8j2.js +1 -0
  95. package/public/assets/mdx--jDhmrXq.js +1 -0
  96. package/public/assets/mips-CdjsipkG.js +1 -0
  97. package/public/assets/msdax-CYqgjx_P.js +1 -0
  98. package/public/assets/mysql-BHd6q0vd.js +1 -0
  99. package/public/assets/objective-c-B1aVtJYH.js +1 -0
  100. package/public/assets/pascal-BhNW15KB.js +1 -0
  101. package/public/assets/pascaligo-5jv8CcQD.js +1 -0
  102. package/public/assets/perl-DlYyT36c.js +1 -0
  103. package/public/assets/pgsql-Dy0bjov7.js +1 -0
  104. package/public/assets/php-120yhfDK.js +1 -0
  105. package/public/assets/pla-CjnFlu4u.js +1 -0
  106. package/public/assets/postiats-CQpG440k.js +1 -0
  107. package/public/assets/powerquery-DdJtto1Z.js +1 -0
  108. package/public/assets/powershell-Bu_VLpJB.js +1 -0
  109. package/public/assets/protobuf-IBS6jZEB.js +2 -0
  110. package/public/assets/pug-kFxLfcjb.js +1 -0
  111. package/public/assets/python-YjG50skX.js +1 -0
  112. package/public/assets/qsharp-q7JyzKFN.js +1 -0
  113. package/public/assets/r-BIFz-_sK.js +1 -0
  114. package/public/assets/razor-CEcFE3UK.js +1 -0
  115. package/public/assets/redis-CHOsPHWR.js +1 -0
  116. package/public/assets/redshift-CBifECDb.js +1 -0
  117. package/public/assets/restructuredtext-CghPJEOS.js +1 -0
  118. package/public/assets/ruby-CYWGW-b1.js +1 -0
  119. package/public/assets/rust-DMDD0SHb.js +1 -0
  120. package/public/assets/sb-BYAiYHFx.js +1 -0
  121. package/public/assets/scala-Bqvq8jcR.js +1 -0
  122. package/public/assets/scheme-Dhb-2j9p.js +1 -0
  123. package/public/assets/scss-CTwUZ5N7.js +3 -0
  124. package/public/assets/shell-CsDZo4DB.js +1 -0
  125. package/public/assets/solidity-CME5AdoB.js +1 -0
  126. package/public/assets/sophia-RYC1BQQz.js +1 -0
  127. package/public/assets/sparql-KEyrF7De.js +1 -0
  128. package/public/assets/sql-BdTr02Mf.js +1 -0
  129. package/public/assets/st-C7iG7M4S.js +1 -0
  130. package/public/assets/swift-D7IUmUK8.js +1 -0
  131. package/public/assets/systemverilog-DgMryOEJ.js +1 -0
  132. package/public/assets/tcl-PloMZuKG.js +1 -0
  133. package/public/assets/ts.worker-Bij5J2kb.js +51316 -0
  134. package/public/assets/tsMode-g4kTQl09.js +11 -0
  135. package/public/assets/twig-BfRIq3la.js +1 -0
  136. package/public/assets/typescript-CnHeFmPW.js +1 -0
  137. package/public/assets/typespec-CzxlYoT_.js +1 -0
  138. package/public/assets/vb-BwAE3J76.js +1 -0
  139. package/public/assets/wgsl-B_1kOXbF.js +298 -0
  140. package/public/assets/xml-BFXMY9nb.js +1 -0
  141. package/public/assets/yaml-DNm87nSf.js +1 -0
  142. package/public/index.html +2 -2
  143. package/public/assets/index-Be82iGwe.css +0 -1
  144. package/public/assets/index-ByU9a3Lh.js +0 -61
@@ -1,4 +1,6 @@
1
1
  import { toolError } from "./errors.js";
2
+ import { DEFAULT_WORK_BUDGET } from "./work-admit.js";
3
+ const SLICE = `${DEFAULT_WORK_BUDGET.workerWallMs} ms and ${DEFAULT_WORK_BUDGET.workerMaxTokens} tokens`;
2
4
  const OUTPUT = {
3
5
  schema: {
4
6
  type: 'object',
@@ -12,19 +14,19 @@ const OUTPUT = {
12
14
  /**
13
15
  * Bot tools plus the worker report. Execute checks the host session.
14
16
  * Model arguments never supply owner, attempt, or fence.
15
- * @param {ReturnType<import('./work-worker.js').createWorkRuntime>} work
17
+ * @param {ReturnType<typeof import('./work-worker.js').createWorkRuntime>} work
16
18
  * @param {import('./engine.js').Engine} engine
17
19
  */
18
20
  export function workToolDefinitions(work, engine) {
19
21
  return [
20
- tool('foundations_dispatch', 'Hand a long job to a worker session. Available only on a bot. status=accepted means received, not yet dispatched. status=enqueued means it entered the execution queue, not that it has started. The return value is never started. ownerSessionId is ignored.', {
22
+ tool('foundations_dispatch', 'Hand a non-trivial job to a worker session. Prefer this over doing the work with bash, write, edit, or an official subagent in the main session. Available only on a bot. status=accepted means received, and may wait for an execution slot. status=enqueued means it entered the execution queue, not that it has started. queued=true means it is waiting for a slot and will start automatically when one is free. The return value is never started. A BUDGET error means both the slot cap and the queue cap are full; do not start the job in the main session. ownerSessionId is ignored.', {
21
23
  type: 'object',
22
24
  properties: {
23
25
  briefing: { type: 'string' },
24
26
  idempotencyKey: { type: 'string' },
25
27
  budget: {
26
28
  type: 'object',
27
- description: 'Time and token estimate for this ticket. When omitted, the host estimates from the task text. It cannot exceed the host ceiling.',
29
+ description: `Time and token budget for this ticket. When omitted, the host uses one standard slice (${SLICE}). Pass that slice. Do not estimate a smaller budget. Later grants add more slices with no cumulative ceiling.`,
28
30
  properties: {
29
31
  wallMs: { type: 'integer', description: 'Expected maximum runtime in milliseconds.' },
30
32
  maxTokens: { type: 'integer', description: 'Expected maximum tokens.' },
@@ -65,13 +67,16 @@ export function workToolDefinitions(work, engine) {
65
67
  ownerSessionId: { type: 'string', description: 'Ignored.' },
66
68
  },
67
69
  }, (args, hostId) => work.cancelTicket(hostId, args), 'bot'),
68
- tool('foundations_grant', 'Grant more time or tokens to an unfinished ticket. wallMs and maxTokens are amounts to add, not a new total. A budget-exhausted notice is not a failure. deny=true refuses the grant and stops this round.', {
70
+ tool('foundations_grant', `Grant more active runtime or tokens to an unfinished ticket. wallMs and maxTokens are amounts to ADD, not totals. Add at least one standard slice (${SLICE}), and more if current usage is already past granted plus that slice. There is no limit on how many times you grant and no cumulative ceiling. Do not refuse because earlier grants were many or large. Exhausted workers wait at the next safe loop boundary without expiry. An insufficient grant leaves the worker paused. The main session cannot refuse. deny=true does not stop the worker; another full slice is granted. Tell the user and end the turn. Do not take over the task and do not redispatch a replacement.`, {
69
71
  type: 'object',
70
72
  properties: {
71
73
  ticketId: { type: 'string' },
72
74
  wallMs: { type: 'integer', description: 'Milliseconds to add.' },
73
75
  maxTokens: { type: 'integer', description: 'Tokens to add.' },
74
- deny: { type: 'boolean', description: 'Refuse the grant and stop.' },
76
+ deny: {
77
+ type: 'boolean',
78
+ description: 'Ignored as a refusal. Does not stop the worker.',
79
+ },
75
80
  ownerSessionId: { type: 'string', description: 'Ignored.' },
76
81
  },
77
82
  required: ['ticketId'],
@@ -101,6 +106,38 @@ export function workToolDefinitions(work, engine) {
101
106
  },
102
107
  required: ['resultEventId'],
103
108
  }, (args, hostId) => work.reject(hostId, args), 'bot'),
109
+ tool('foundations_worker_history', "Read the worker session log for a ticket this main session owns. The host queries that log directly. The worker is not notified and no authorization prompt is raised. Call it once when the user asks how an unfinished ticket is progressing. The excerpt is not a result: do not call foundations_publish from it, and do not read, edit, or build the worker's files. Omit ticketId only when this session has one unfinished ticket. When several are unfinished, the result lists their ids and does not include a log.", {
110
+ type: 'object',
111
+ properties: {
112
+ ticketId: {
113
+ type: 'string',
114
+ description: 'Ticket to read. Omit only when one unfinished ticket is open.',
115
+ },
116
+ maxChars: {
117
+ type: 'integer',
118
+ description: 'Optional cap for the returned excerpt, from 500 to 24000. Omit it for the default excerpt.',
119
+ },
120
+ },
121
+ }, async (args, hostId) => {
122
+ const maxChars = Number(args.maxChars);
123
+ return work.workerHistory(hostId, {
124
+ ...(typeof args.ticketId === 'string' ? { ticketId: args.ticketId } : {}),
125
+ ...(Number.isFinite(maxChars) ? { maxChars } : {}),
126
+ });
127
+ }, 'bot'),
128
+ tool('foundations_main_history', 'Read the main session that owns this ticket. The host queries the session log directly and does not raise an authorization prompt. Use it when the attached excerpt is missing a line you need. Do not write the main session.', {
129
+ type: 'object',
130
+ properties: {
131
+ maxChars: {
132
+ type: 'integer',
133
+ description: 'Optional cap for the returned excerpt, from 500 to 24000. Omit it for the default excerpt.',
134
+ },
135
+ },
136
+ }, async (args, hostId) => {
137
+ const maxChars = Number(args.maxChars);
138
+ const limits = Number.isFinite(maxChars) ? { maxChars } : undefined;
139
+ return work.mainHistory(hostId, limits);
140
+ }, 'worker'),
104
141
  tool('foundations_report', 'The worker reports progress, a question, an artifact, a result, or a failure. This only writes the ledger. ticket, attempt, fence, and owner are discarded.', {
105
142
  type: 'object',
106
143
  properties: {
@@ -113,7 +150,7 @@ export function workToolDefinitions(work, engine) {
113
150
  ownerSessionId: { type: 'string', description: 'Ignored.' },
114
151
  },
115
152
  required: ['kind', 'text'],
116
- }, (args, hostId) => {
153
+ }, async (args, hostId) => {
117
154
  if (engine.isBot(hostId))
118
155
  return toolError('FORBIDDEN', 'The main session cannot report in place of the worker.');
119
156
  return work.report(hostId, args);