@nebutra/agent-runtime 0.2.0 → 0.2.2

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 (137) hide show
  1. package/LICENSE +21 -676
  2. package/README.md +2 -0
  3. package/dist/adapters/dispatcher-sse.js +1 -0
  4. package/dist/adapters/index.d.ts +24 -5
  5. package/dist/adapters/index.js +28 -0
  6. package/dist/adapters/index.js.map +1 -1
  7. package/dist/adapters/mcp-catalog.js +1 -0
  8. package/dist/adapters/prisma-rollout.js +1 -0
  9. package/dist/chunk-424PT5DM.js +23 -0
  10. package/dist/chunk-424PT5DM.js.map +1 -0
  11. package/dist/{chunk-NN7DATXA.js → chunk-4Y25ZTKI.js} +3 -3
  12. package/dist/chunk-4Y25ZTKI.js.map +1 -0
  13. package/dist/{chunk-BJBBR3QA.js → chunk-D4YAPLOW.js} +4 -4
  14. package/dist/chunk-D4YAPLOW.js.map +1 -0
  15. package/dist/{chunk-ZMYX5VBU.js → chunk-GQZKYWFT.js} +23 -7
  16. package/dist/chunk-GQZKYWFT.js.map +1 -0
  17. package/dist/chunk-KCNN4QUQ.js +255 -0
  18. package/dist/chunk-KCNN4QUQ.js.map +1 -0
  19. package/dist/{chunk-PGGWSUTM.js → chunk-NI4EDT4T.js} +2 -2
  20. package/dist/chunk-NI4EDT4T.js.map +1 -0
  21. package/dist/chunk-Q62VKHIT.js +178 -0
  22. package/dist/chunk-Q62VKHIT.js.map +1 -0
  23. package/dist/{chunk-MUF7ZZTO.js → chunk-R5HOSQUW.js} +2 -1
  24. package/dist/{chunk-MUF7ZZTO.js.map → chunk-R5HOSQUW.js.map} +1 -1
  25. package/dist/{chunk-5N4644PB.js → chunk-SD2ZJ7XG.js} +4 -4
  26. package/dist/cli.d.ts +2 -0
  27. package/dist/cli.js +52 -0
  28. package/dist/cli.js.map +1 -0
  29. package/dist/commands.js +1 -0
  30. package/dist/definitions.js +1 -0
  31. package/dist/dispatcher.js +1 -0
  32. package/dist/durable-turn.js +3 -2
  33. package/dist/hook-pipeline.js +1 -0
  34. package/dist/index.d.ts +8 -85
  35. package/dist/index.js +249 -134
  36. package/dist/index.js.map +1 -1
  37. package/dist/loop.d.ts +2 -2
  38. package/dist/loop.js +3 -2
  39. package/dist/mcp-bridge.d.ts +3 -3
  40. package/dist/mcp-bridge.js +3 -2
  41. package/dist/model.js +1 -0
  42. package/dist/orchestration.d.ts +84 -0
  43. package/dist/orchestration.js +16 -0
  44. package/dist/orchestration.js.map +1 -0
  45. package/dist/policy.js +1 -0
  46. package/dist/protocol.js +1 -0
  47. package/dist/pulsar.d.ts +78 -0
  48. package/dist/pulsar.js +17 -0
  49. package/dist/pulsar.js.map +1 -0
  50. package/dist/rollout-store-persistent.js +1 -0
  51. package/dist/rollout.js +1 -0
  52. package/dist/sandbox.js +2 -1
  53. package/dist/skills.js +2 -1
  54. package/dist/subagents.js +1 -0
  55. package/dist/tools.d.ts +4 -3
  56. package/dist/tools.js +5 -3
  57. package/package.json +84 -27
  58. package/.turbo/turbo-build.log +0 -115
  59. package/.turbo/turbo-test.log +0 -44
  60. package/.turbo/turbo-typecheck.log +0 -4
  61. package/CHANGELOG.md +0 -253
  62. package/dist/chunk-BJBBR3QA.js.map +0 -1
  63. package/dist/chunk-NN7DATXA.js.map +0 -1
  64. package/dist/chunk-PGGWSUTM.js.map +0 -1
  65. package/dist/chunk-ZMYX5VBU.js.map +0 -1
  66. package/src/adapters/dispatcher-sse.test.ts +0 -218
  67. package/src/adapters/dispatcher-sse.ts +0 -222
  68. package/src/adapters/index.ts +0 -18
  69. package/src/adapters/mcp-catalog.test.ts +0 -213
  70. package/src/adapters/mcp-catalog.ts +0 -188
  71. package/src/adapters/prisma-rollout.test.ts +0 -153
  72. package/src/adapters/prisma-rollout.ts +0 -104
  73. package/src/agent-runtime.test.ts +0 -176
  74. package/src/artifact-stream.test.ts +0 -330
  75. package/src/artifact-stream.ts +0 -453
  76. package/src/channel-gateway.test.ts +0 -432
  77. package/src/channel-gateway.ts +0 -357
  78. package/src/code-review.test.ts +0 -501
  79. package/src/code-review.ts +0 -495
  80. package/src/command-suggestions.test.ts +0 -251
  81. package/src/command-suggestions.ts +0 -338
  82. package/src/commands.test.ts +0 -184
  83. package/src/commands.ts +0 -140
  84. package/src/commit-message.test.ts +0 -249
  85. package/src/commit-message.ts +0 -180
  86. package/src/context-compaction.test.ts +0 -522
  87. package/src/context-compaction.ts +0 -434
  88. package/src/definitions.test.ts +0 -78
  89. package/src/definitions.ts +0 -190
  90. package/src/deployment-status.test.ts +0 -215
  91. package/src/deployment-status.ts +0 -227
  92. package/src/design-context.test.ts +0 -195
  93. package/src/design-context.ts +0 -198
  94. package/src/dispatcher.test.ts +0 -234
  95. package/src/dispatcher.ts +0 -189
  96. package/src/durable-turn.test.ts +0 -209
  97. package/src/durable-turn.ts +0 -135
  98. package/src/edit-planner.test.ts +0 -204
  99. package/src/edit-planner.ts +0 -325
  100. package/src/fuzzy-match.test.ts +0 -311
  101. package/src/fuzzy-match.ts +0 -444
  102. package/src/hook-pipeline.test.ts +0 -279
  103. package/src/hook-pipeline.ts +0 -373
  104. package/src/inbound-admission.test.ts +0 -394
  105. package/src/inbound-admission.ts +0 -246
  106. package/src/index.ts +0 -47
  107. package/src/loop.test.ts +0 -161
  108. package/src/loop.ts +0 -211
  109. package/src/mcp-bridge.test.ts +0 -165
  110. package/src/mcp-bridge.ts +0 -76
  111. package/src/memory-provider.test.ts +0 -232
  112. package/src/memory-provider.ts +0 -257
  113. package/src/model.ts +0 -168
  114. package/src/permission-ruleset.test.ts +0 -301
  115. package/src/permission-ruleset.ts +0 -200
  116. package/src/policy.ts +0 -151
  117. package/src/project-repo.test.ts +0 -232
  118. package/src/project-repo.ts +0 -311
  119. package/src/protocol.ts +0 -159
  120. package/src/rollout-store-persistent.test.ts +0 -217
  121. package/src/rollout-store-persistent.ts +0 -166
  122. package/src/rollout.ts +0 -150
  123. package/src/sandbox.ts +0 -113
  124. package/src/session-share.test.ts +0 -360
  125. package/src/session-share.ts +0 -310
  126. package/src/skill-distillation.test.ts +0 -177
  127. package/src/skill-distillation.ts +0 -369
  128. package/src/skills.test.ts +0 -277
  129. package/src/skills.ts +0 -255
  130. package/src/subagents.test.ts +0 -290
  131. package/src/subagents.ts +0 -332
  132. package/src/tools.ts +0 -126
  133. package/src/workbench.test.ts +0 -0
  134. package/src/workbench.ts +0 -0
  135. package/tsconfig.json +0 -12
  136. package/tsup.config.ts +0 -33
  137. /package/dist/{chunk-5N4644PB.js.map → chunk-SD2ZJ7XG.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,3 +1,8 @@
1
+ import {
2
+ Pulsar,
3
+ PulsarBuilder,
4
+ PulsarThread
5
+ } from "./chunk-KCNN4QUQ.js";
1
6
  import {
2
7
  PersistentRolloutStore,
3
8
  RoundTripError
@@ -8,11 +13,11 @@ import {
8
13
  SandboxDelegationError,
9
14
  assertSafePosture,
10
15
  createHttpSandbox
11
- } from "./chunk-MUF7ZZTO.js";
16
+ } from "./chunk-R5HOSQUW.js";
12
17
  import {
13
18
  buildSkillListing,
14
19
  expandSkill
15
- } from "./chunk-ZMYX5VBU.js";
20
+ } from "./chunk-GQZKYWFT.js";
16
21
  import {
17
22
  TASK_KINDS,
18
23
  TASK_STATUSES,
@@ -23,9 +28,19 @@ import {
23
28
  resolveSubagentTools,
24
29
  settleDeferred
25
30
  } from "./chunk-5YS7WAPS.js";
31
+ import {
32
+ ProtocolDispatcher
33
+ } from "./chunk-RDKYDMXT.js";
34
+ import {
35
+ METHOD_REGISTRY,
36
+ NOTIFICATIONS,
37
+ requestEnvelopeSchema,
38
+ resolveScope,
39
+ scopeKey
40
+ } from "./chunk-FUG5DT2C.js";
26
41
  import {
27
42
  createDurableTurn
28
- } from "./chunk-5N4644PB.js";
43
+ } from "./chunk-SD2ZJ7XG.js";
29
44
  import {
30
45
  fromToolHooks,
31
46
  matchesMatcher,
@@ -34,18 +49,32 @@ import {
34
49
  } from "./chunk-LO24VOA3.js";
35
50
  import {
36
51
  runTurn
37
- } from "./chunk-BJBBR3QA.js";
52
+ } from "./chunk-D4YAPLOW.js";
53
+ import {
54
+ InMemoryRolloutStore,
55
+ PERSISTED_OUTPUT_MAX_BYTES,
56
+ isPersisted,
57
+ replay,
58
+ sanitizeForPersist
59
+ } from "./chunk-37BBB2P2.js";
38
60
  import {
39
61
  activateMcpTools
40
- } from "./chunk-PGGWSUTM.js";
62
+ } from "./chunk-NI4EDT4T.js";
41
63
  import {
42
- ToolRegistry,
64
+ RuntimeToolRegistry,
43
65
  adaptMcpTool
44
- } from "./chunk-NN7DATXA.js";
66
+ } from "./chunk-4Y25ZTKI.js";
45
67
  import {
46
68
  isTurnTerminal,
47
69
  mergeTurnConfig
48
70
  } from "./chunk-6EGG2OZC.js";
71
+ import {
72
+ costReport,
73
+ fanOutSubagents,
74
+ planSubagentDispatch,
75
+ planWaves,
76
+ runAgentWaves
77
+ } from "./chunk-Q62VKHIT.js";
49
78
  import {
50
79
  DEFAULT_APPROVAL_POLICY,
51
80
  DEFAULT_CAPABILITY_POLICY,
@@ -57,13 +86,6 @@ import {
57
86
  resolveRuleDecision,
58
87
  writableRootSchema
59
88
  } from "./chunk-CGRCUKGT.js";
60
- import {
61
- InMemoryRolloutStore,
62
- PERSISTED_OUTPUT_MAX_BYTES,
63
- isPersisted,
64
- replay,
65
- sanitizeForPersist
66
- } from "./chunk-37BBB2P2.js";
67
89
  import {
68
90
  CommandRegistry,
69
91
  expandCommand
@@ -76,15 +98,194 @@ import {
76
98
  substituteArguments
77
99
  } from "./chunk-7BUOF367.js";
78
100
  import {
79
- ProtocolDispatcher
80
- } from "./chunk-RDKYDMXT.js";
81
- import {
82
- METHOD_REGISTRY,
83
- NOTIFICATIONS,
84
- requestEnvelopeSchema,
85
- resolveScope,
86
- scopeKey
87
- } from "./chunk-FUG5DT2C.js";
101
+ __export,
102
+ __reExport
103
+ } from "./chunk-424PT5DM.js";
104
+
105
+ // src/index.ts
106
+ var src_exports = {};
107
+ __export(src_exports, {
108
+ ActionRunner: () => ActionRunner,
109
+ ArtifactStreamParser: () => ArtifactStreamParser,
110
+ BUDGET_RATIO: () => BUDGET_RATIO,
111
+ CLIP_TEXT_CHARS: () => CLIP_TEXT_CHARS,
112
+ CLIP_TOOL_CHARS: () => CLIP_TOOL_CHARS,
113
+ COMPACT_SENTINEL: () => COMPACT_SENTINEL,
114
+ CONCURRENCY: () => CONCURRENCY,
115
+ CONVERSATIONS_DIR: () => CONVERSATIONS_DIR,
116
+ ChannelGateway: () => ChannelGateway,
117
+ ChannelRegistry: () => ChannelRegistry,
118
+ CommandRegistry: () => CommandRegistry,
119
+ CommitMessageError: () => CommitMessageError,
120
+ DEFAULT_ABORT_MS: () => DEFAULT_ABORT_MS,
121
+ DEFAULT_APPROVAL_POLICY: () => DEFAULT_APPROVAL_POLICY,
122
+ DEFAULT_CAPABILITY_POLICY: () => DEFAULT_CAPABILITY_POLICY,
123
+ DEFAULT_TEMPERATURE: () => DEFAULT_TEMPERATURE,
124
+ DENIED: () => DENIED,
125
+ DefinitionResolver: () => DefinitionResolver,
126
+ DeploymentStateError: () => DeploymentStateError,
127
+ DuplicateChannelError: () => DuplicateChannelError,
128
+ EditType: () => EditType,
129
+ InMemoryProjectStore: () => InMemoryProjectStore,
130
+ InMemoryRolloutStore: () => InMemoryRolloutStore,
131
+ InMemoryShareStore: () => InMemoryShareStore,
132
+ InMemorySuggestionHistoryStore: () => InMemorySuggestionHistoryStore,
133
+ InboundDebouncer: () => InboundDebouncer,
134
+ LARGE_SET: () => LARGE_SET,
135
+ MAX_RETRIES: () => MAX_RETRIES,
136
+ MEMORY_CONTEXT_BANNER_CLOSE: () => MEMORY_CONTEXT_BANNER_CLOSE,
137
+ MEMORY_CONTEXT_BANNER_OPEN: () => MEMORY_CONTEXT_BANNER_OPEN,
138
+ METADATA_PATH: () => METADATA_PATH,
139
+ METHOD_REGISTRY: () => METHOD_REGISTRY,
140
+ MIN_BUDGET: () => MIN_BUDGET,
141
+ MemoryManager: () => MemoryManager,
142
+ NOTIFICATIONS: () => NOTIFICATIONS,
143
+ NoExecutorConfiguredError: () => NoExecutorConfiguredError,
144
+ OUTPUT_TOKEN_CAP: () => OUTPUT_TOKEN_CAP,
145
+ PERSISTED_OUTPUT_MAX_BYTES: () => PERSISTED_OUTPUT_MAX_BYTES,
146
+ PersistentRolloutStore: () => PersistentRolloutStore,
147
+ ProjectRepo: () => ProjectRepo,
148
+ ProjectRepoError: () => ProjectRepoError,
149
+ ProtocolDispatcher: () => ProtocolDispatcher,
150
+ Pulsar: () => Pulsar,
151
+ PulsarBuilder: () => PulsarBuilder,
152
+ PulsarThread: () => PulsarThread,
153
+ REDUCE_DEPTH: () => REDUCE_DEPTH,
154
+ REFUSING_SANDBOX: () => REFUSING_SANDBOX,
155
+ ReviewParseError: () => ReviewParseError,
156
+ RoundTripError: () => RoundTripError,
157
+ RuntimeToolRegistry: () => RuntimeToolRegistry,
158
+ SOURCE_TIERS: () => SOURCE_TIERS,
159
+ SandboxDelegationError: () => SandboxDelegationError,
160
+ SessionShare: () => SessionShare,
161
+ ShareDisabledError: () => ShareDisabledError,
162
+ SnapshotHistory: () => SnapshotHistory,
163
+ StreamingContextScrubber: () => StreamingContextScrubber,
164
+ TASK_KINDS: () => TASK_KINDS,
165
+ TASK_STATUSES: () => TASK_STATUSES,
166
+ TOKEN_CORRECTION: () => TOKEN_CORRECTION,
167
+ TaskRegistry: () => TaskRegistry,
168
+ TenantMismatchError: () => TenantMismatchError,
169
+ ToolRegistry: () => RuntimeToolRegistry,
170
+ UnknownChannelError: () => UnknownChannelError,
171
+ WorkbenchError: () => WorkbenchError,
172
+ activateMcpTools: () => activateMcpTools,
173
+ adaptMcpTool: () => adaptMcpTool,
174
+ admitInbound: () => admitInbound,
175
+ advanceState: () => advanceState,
176
+ analyzeEditIntent: () => analyzeEditIntent,
177
+ appendJsonlLine: () => appendJsonlLine,
178
+ applyEditBlock: () => applyEditBlock,
179
+ applyFileMutation: () => applyFileMutation,
180
+ approvalPolicySchema: () => approvalPolicySchema,
181
+ asChannelId: () => asChannelId,
182
+ assertNotPeeking: () => assertNotPeeking,
183
+ assertSafePosture: () => assertSafePosture,
184
+ assertTenantContext: () => assertTenantContext,
185
+ buildCommitPrompt: () => buildCommitPrompt,
186
+ buildDistillationPrompt: () => buildDistillationPrompt,
187
+ buildEditInstructions: () => buildEditInstructions,
188
+ buildImprovementPrompt: () => buildImprovementPrompt,
189
+ buildMemoryContextBlock: () => buildMemoryContextBlock,
190
+ buildReviewPrompt: () => buildReviewPrompt,
191
+ buildSkillListing: () => buildSkillListing,
192
+ capabilityPolicySchema: () => capabilityPolicySchema,
193
+ classifyMatch: () => classifyMatch,
194
+ compactTranscript: () => compactTranscript,
195
+ compileAllowlist: () => compileAllowlist,
196
+ computeBudget: () => computeBudget,
197
+ constantTimeEquals: () => constantTimeEquals,
198
+ costReport: () => costReport,
199
+ createDurableTurn: () => createDurableTurn,
200
+ createHttpSandbox: () => createHttpSandbox,
201
+ dedupeByText: () => dedupeByText,
202
+ deriveLatestStatus: () => deriveLatestStatus,
203
+ deriveTimelineFromCommits: () => deriveTimelineFromCommits,
204
+ diffProjects: () => diffProjects,
205
+ distillSkill: () => distillSkill,
206
+ domainForCommit: () => domainForCommit,
207
+ emptyFileMap: () => emptyFileMap,
208
+ emptyProjectMetadata: () => emptyProjectMetadata,
209
+ estimateTokens: () => estimateTokens,
210
+ expandCommand: () => expandCommand,
211
+ expandSkill: () => expandSkill,
212
+ fallbackMerger: () => fallbackMerger,
213
+ fanOutSubagents: () => fanOutSubagents,
214
+ fromToolHooks: () => fromToolHooks,
215
+ frontmatterSchema: () => frontmatterSchema,
216
+ generateCommitMessage: () => generateCommitMessage,
217
+ getDeploymentStatus: () => getDeploymentStatus,
218
+ getDeploymentTimeline: () => getDeploymentTimeline,
219
+ getFile: () => getFile,
220
+ granularApprovalConfigSchema: () => granularApprovalConfigSchema,
221
+ hasMention: () => hasMention,
222
+ historyCandidates: () => historyCandidates,
223
+ improveSkill: () => improveSkill,
224
+ ingestDesignContext: () => ingestDesignContext,
225
+ isApproval: () => isApproval,
226
+ isDistillable: () => isDistillable,
227
+ isPersisted: () => isPersisted,
228
+ isTurnTerminal: () => isTurnTerminal,
229
+ kebab: () => kebab,
230
+ listFiles: () => listFiles,
231
+ makeDeferred: () => makeDeferred,
232
+ makeProject: () => makeProject,
233
+ matchIndices: () => matchIndices,
234
+ matchIndicesCaseInsensitive: () => matchIndicesCaseInsensitive,
235
+ matchIndicesCaseInsensitiveIgnoreSpaces: () => matchIndicesCaseInsensitiveIgnoreSpaces,
236
+ matchWildcardPattern: () => matchWildcardPattern,
237
+ matchWildcardPatternCaseInsensitive: () => matchWildcardPatternCaseInsensitive,
238
+ matchesAllowlist: () => matchesAllowlist,
239
+ matchesMatcher: () => matchesMatcher,
240
+ mergeTurnConfig: () => mergeTurnConfig,
241
+ nextMode: () => nextMode,
242
+ normalizeScrapeResult: () => normalizeScrapeResult,
243
+ onHookEvent: () => onHookEvent,
244
+ parseDiff: () => parseDiff,
245
+ parseEditBlocks: () => parseEditBlocks,
246
+ parseFindings: () => parseFindings,
247
+ parseFrontmatter: () => parseFrontmatter,
248
+ parseJsonl: () => parseJsonl,
249
+ planEdit: () => planEdit,
250
+ planSubagentDispatch: () => planSubagentDispatch,
251
+ planWaves: () => planWaves,
252
+ prepareDispatch: () => prepareDispatch,
253
+ rankByFuzzy: () => rankByFuzzy,
254
+ rankSuggestions: () => rankSuggestions,
255
+ recordHistory: () => recordHistory,
256
+ removeFile: () => removeFile,
257
+ renderClipped: () => renderClipped,
258
+ replay: () => replay,
259
+ replyTo: () => replyTo,
260
+ requestEnvelopeSchema: () => requestEnvelopeSchema,
261
+ requiresMention: () => requiresMention,
262
+ resolveBranchBase: () => resolveBranchBase,
263
+ resolveRuleDecision: () => resolveRuleDecision,
264
+ resolveScope: () => resolveScope,
265
+ resolveSessionKey: () => resolveSessionKey,
266
+ resolveSubagentTools: () => resolveSubagentTools,
267
+ restore: () => restore,
268
+ runAgentWaves: () => runAgentWaves,
269
+ runHooks: () => runHooks,
270
+ runReview: () => runReview,
271
+ runTurn: () => runTurn,
272
+ sanitizeContext: () => sanitizeContext,
273
+ sanitizeForPersist: () => sanitizeForPersist,
274
+ scopeKey: () => scopeKey,
275
+ selectFilesForEdit: () => selectFilesForEdit,
276
+ setFile: () => setFile,
277
+ settleDeferred: () => settleDeferred,
278
+ shouldCompact: () => shouldCompact,
279
+ shouldNudgePersist: () => shouldNudgePersist,
280
+ snapshot: () => snapshot,
281
+ split: () => split,
282
+ stripFencedWrapper: () => stripFencedWrapper,
283
+ stripFormatting: () => stripFormatting,
284
+ substituteArguments: () => substituteArguments,
285
+ toGenerationSeed: () => toGenerationSeed,
286
+ unescapeEntities: () => unescapeEntities,
287
+ writableRootSchema: () => writableRootSchema
288
+ });
88
289
 
89
290
  // src/artifact-stream.ts
90
291
  import { z } from "zod";
@@ -1068,6 +1269,10 @@ async function generateCommitMessage(args) {
1068
1269
  }
1069
1270
 
1070
1271
  // src/context-compaction.ts
1272
+ import {
1273
+ estimateTokens as estimatePrimitiveTokens
1274
+ } from "@nebutra/ai-primitives";
1275
+ import pLimit from "p-limit";
1071
1276
  import { z as z6 } from "zod";
1072
1277
  var TOKEN_CORRECTION = 1.3;
1073
1278
  var BUDGET_RATIO = 0.6;
@@ -1099,7 +1304,7 @@ var compactInputSchema = z6.object({
1099
1304
  usableTokens: z6.number().int().positive()
1100
1305
  });
1101
1306
  function estimateTokens(text, base = defaultBase) {
1102
- return Math.ceil(base(text) * TOKEN_CORRECTION);
1307
+ return estimatePrimitiveTokens(text, { base, correction: TOKEN_CORRECTION });
1103
1308
  }
1104
1309
  function computeBudget(usableTokens) {
1105
1310
  return Math.max(MIN_BUDGET, Math.floor(usableTokens * BUDGET_RATIO));
@@ -1165,18 +1370,8 @@ function buildPrompt(rendered) {
1165
1370
  ].join("\n");
1166
1371
  }
1167
1372
  async function mapLimited(items, worker) {
1168
- const results = new Array(items.length);
1169
- let cursor = 0;
1170
- async function run() {
1171
- while (cursor < items.length) {
1172
- const index = cursor;
1173
- cursor += 1;
1174
- results[index] = await worker(items[index], index);
1175
- }
1176
- }
1177
- const lanes = Math.min(CONCURRENCY, items.length);
1178
- await Promise.all(Array.from({ length: lanes }, () => run()));
1179
- return results;
1373
+ const limit = pLimit(CONCURRENCY);
1374
+ return limit.map(items, worker);
1180
1375
  }
1181
1376
  async function summarizeChunks(chunks, summarize) {
1182
1377
  return mapLimited(chunks, async (chunk) => {
@@ -1370,8 +1565,8 @@ var DEFAULT_FORMATS = ["markdown", "screenshot", "branding"];
1370
1565
  var DEFAULT_MAX_CHARS = 4e3;
1371
1566
  var COLOR_RE = /^(#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgb|rgba|hsl|hsla)\([^)]+\))$/i;
1372
1567
  function stripTags(html) {
1373
- const withoutTags = html.replace(/<[^>]*>/g, " ");
1374
- const decoded = withoutTags.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&nbsp;/g, " ");
1568
+ const withoutTags = html.replace(/<[^>]{0,2000}>/g, " ");
1569
+ const decoded = withoutTags.replace(/&nbsp;/g, " ").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
1375
1570
  return decoded.replace(/\s+/g, " ").trim();
1376
1571
  }
1377
1572
  function dedupe(values) {
@@ -2148,96 +2343,12 @@ var MemoryManager = class {
2148
2343
  };
2149
2344
 
2150
2345
  // src/permission-ruleset.ts
2151
- function wildcardMatch(str, pattern) {
2152
- if (isOptionalTrailingStar(pattern)) {
2153
- const head = pattern.slice(0, -2);
2154
- if (globMatch2(str, head)) {
2155
- return true;
2156
- }
2157
- return globMatch2(str, pattern);
2158
- }
2159
- return globMatch2(str, pattern);
2160
- }
2161
- function isOptionalTrailingStar(pattern) {
2162
- return pattern.length >= 2 && pattern.endsWith(" *");
2163
- }
2164
- function globMatch2(str, pattern) {
2165
- let s = 0;
2166
- let p = 0;
2167
- let starP = -1;
2168
- let starS = 0;
2169
- while (s < str.length) {
2170
- const pc = p < pattern.length ? pattern[p] : void 0;
2171
- if (pc === "*") {
2172
- starP = p;
2173
- starS = s;
2174
- p += 1;
2175
- } else if (pc === "?" || pc === str[s]) {
2176
- p += 1;
2177
- s += 1;
2178
- } else if (starP !== -1) {
2179
- p = starP + 1;
2180
- starS += 1;
2181
- s = starS;
2182
- } else {
2183
- return false;
2184
- }
2185
- }
2186
- while (p < pattern.length && pattern[p] === "*") {
2187
- p += 1;
2188
- }
2189
- return p === pattern.length;
2190
- }
2191
- function evaluate(permission, pattern, ...rulesets) {
2192
- for (const ruleset of rulesets) {
2193
- for (const rule of ruleset) {
2194
- if (wildcardMatch(permission, rule.permission) && wildcardMatch(pattern, rule.pattern)) {
2195
- return rule;
2196
- }
2197
- }
2198
- }
2199
- return { permission, pattern: "*", action: "ask" };
2200
- }
2201
- var BUILTIN_ARITY = Object.freeze({
2202
- git: 2,
2203
- npm: 2,
2204
- "npm run": 3,
2205
- docker: 2,
2206
- kubectl: 2,
2207
- cargo: 2,
2208
- pnpm: 2,
2209
- yarn: 2,
2210
- go: 2,
2211
- ls: 1,
2212
- cat: 1,
2213
- cd: 1,
2214
- rm: 1,
2215
- cp: 1,
2216
- mv: 1,
2217
- mkdir: 1,
2218
- echo: 1,
2219
- grep: 1,
2220
- python: 1,
2221
- node: 1
2222
- });
2223
- function commandPrefix(tokens, arity) {
2224
- if (tokens.length === 0) {
2225
- return [];
2226
- }
2227
- const table = { ...BUILTIN_ARITY, ...arity ?? {} };
2228
- for (let len = tokens.length; len >= 1; len -= 1) {
2229
- const prefixKey = tokens.slice(0, len).join(" ");
2230
- const take = table[prefixKey];
2231
- if (take !== void 0) {
2232
- return tokens.slice(0, Math.min(take, tokens.length));
2233
- }
2234
- }
2235
- return tokens.slice(0, 1);
2236
- }
2237
- function commandPermissionKey(command) {
2238
- const tokens = command.split(/\s+/).filter((token) => token.length > 0 && !token.startsWith("-"));
2239
- return commandPrefix(tokens).join(" ");
2240
- }
2346
+ var permission_ruleset_exports = {};
2347
+ __reExport(permission_ruleset_exports, execution_policy_star);
2348
+ import * as execution_policy_star from "@nebutra/execution-policy";
2349
+
2350
+ // src/index.ts
2351
+ __reExport(src_exports, permission_ruleset_exports);
2241
2352
 
2242
2353
  // src/project-repo.ts
2243
2354
  import { z as z12 } from "zod";
@@ -2940,7 +3051,6 @@ export {
2940
3051
  ActionRunner,
2941
3052
  ArtifactStreamParser,
2942
3053
  BUDGET_RATIO,
2943
- BUILTIN_ARITY,
2944
3054
  CLIP_TEXT_CHARS,
2945
3055
  CLIP_TOOL_CHARS,
2946
3056
  COMPACT_SENTINEL,
@@ -2980,10 +3090,14 @@ export {
2980
3090
  ProjectRepo,
2981
3091
  ProjectRepoError,
2982
3092
  ProtocolDispatcher,
3093
+ Pulsar,
3094
+ PulsarBuilder,
3095
+ PulsarThread,
2983
3096
  REDUCE_DEPTH,
2984
3097
  REFUSING_SANDBOX,
2985
3098
  ReviewParseError,
2986
3099
  RoundTripError,
3100
+ RuntimeToolRegistry,
2987
3101
  SOURCE_TIERS,
2988
3102
  SandboxDelegationError,
2989
3103
  SessionShare,
@@ -2995,7 +3109,7 @@ export {
2995
3109
  TOKEN_CORRECTION,
2996
3110
  TaskRegistry,
2997
3111
  TenantMismatchError,
2998
- ToolRegistry,
3112
+ RuntimeToolRegistry as ToolRegistry,
2999
3113
  UnknownChannelError,
3000
3114
  WorkbenchError,
3001
3115
  activateMcpTools,
@@ -3020,12 +3134,11 @@ export {
3020
3134
  buildSkillListing,
3021
3135
  capabilityPolicySchema,
3022
3136
  classifyMatch,
3023
- commandPermissionKey,
3024
- commandPrefix,
3025
3137
  compactTranscript,
3026
3138
  compileAllowlist,
3027
3139
  computeBudget,
3028
3140
  constantTimeEquals,
3141
+ costReport,
3029
3142
  createDurableTurn,
3030
3143
  createHttpSandbox,
3031
3144
  dedupeByText,
@@ -3037,10 +3150,10 @@ export {
3037
3150
  emptyFileMap,
3038
3151
  emptyProjectMetadata,
3039
3152
  estimateTokens,
3040
- evaluate,
3041
3153
  expandCommand,
3042
3154
  expandSkill,
3043
3155
  fallbackMerger,
3156
+ fanOutSubagents,
3044
3157
  fromToolHooks,
3045
3158
  frontmatterSchema,
3046
3159
  generateCommitMessage,
@@ -3077,6 +3190,8 @@ export {
3077
3190
  parseFrontmatter,
3078
3191
  parseJsonl,
3079
3192
  planEdit,
3193
+ planSubagentDispatch,
3194
+ planWaves,
3080
3195
  prepareDispatch,
3081
3196
  rankByFuzzy,
3082
3197
  rankSuggestions,
@@ -3093,6 +3208,7 @@ export {
3093
3208
  resolveSessionKey,
3094
3209
  resolveSubagentTools,
3095
3210
  restore,
3211
+ runAgentWaves,
3096
3212
  runHooks,
3097
3213
  runReview,
3098
3214
  runTurn,
@@ -3111,7 +3227,6 @@ export {
3111
3227
  substituteArguments,
3112
3228
  toGenerationSeed,
3113
3229
  unescapeEntities,
3114
- wildcardMatch,
3115
3230
  writableRootSchema
3116
3231
  };
3117
3232
  //# sourceMappingURL=index.js.map