@namzu/sdk 7.0.0 → 8.0.0

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 (128) hide show
  1. package/CHANGELOG.md +437 -0
  2. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  3. package/dist/agents/SupervisorAgent.js +172 -162
  4. package/dist/agents/SupervisorAgent.js.map +1 -1
  5. package/dist/agents/__tests__/supervisor-inbox-scope.test.d.ts +2 -0
  6. package/dist/agents/__tests__/supervisor-inbox-scope.test.d.ts.map +1 -0
  7. package/dist/agents/__tests__/supervisor-inbox-scope.test.js +125 -0
  8. package/dist/agents/__tests__/supervisor-inbox-scope.test.js.map +1 -0
  9. package/dist/bridge/a2a/mapper.d.ts.map +1 -1
  10. package/dist/bridge/a2a/mapper.js +4 -0
  11. package/dist/bridge/a2a/mapper.js.map +1 -1
  12. package/dist/bridge/sse/mapper.d.ts.map +1 -1
  13. package/dist/bridge/sse/mapper.js +24 -0
  14. package/dist/bridge/sse/mapper.js.map +1 -1
  15. package/dist/contracts/api.d.ts +1 -1
  16. package/dist/contracts/api.d.ts.map +1 -1
  17. package/dist/gateway/__tests__/completion-inbox.test.js +292 -2
  18. package/dist/gateway/__tests__/completion-inbox.test.js.map +1 -1
  19. package/dist/gateway/completion-inbox.d.ts +94 -6
  20. package/dist/gateway/completion-inbox.d.ts.map +1 -1
  21. package/dist/gateway/completion-inbox.js +235 -15
  22. package/dist/gateway/completion-inbox.js.map +1 -1
  23. package/dist/manager/run/persistence.d.ts +8 -0
  24. package/dist/manager/run/persistence.d.ts.map +1 -1
  25. package/dist/manager/run/persistence.js +12 -0
  26. package/dist/manager/run/persistence.js.map +1 -1
  27. package/dist/run/reporter.d.ts.map +1 -1
  28. package/dist/run/reporter.js +11 -0
  29. package/dist/run/reporter.js.map +1 -1
  30. package/dist/runtime/query/__tests__/completion-does-not-erase-the-answer.test.d.ts +2 -0
  31. package/dist/runtime/query/__tests__/completion-does-not-erase-the-answer.test.d.ts.map +1 -0
  32. package/dist/runtime/query/__tests__/completion-does-not-erase-the-answer.test.js +142 -0
  33. package/dist/runtime/query/__tests__/completion-does-not-erase-the-answer.test.js.map +1 -0
  34. package/dist/runtime/query/__tests__/completion-notification.test.js +414 -32
  35. package/dist/runtime/query/__tests__/completion-notification.test.js.map +1 -1
  36. package/dist/runtime/query/__tests__/context-size-on-the-wire.test.d.ts +2 -0
  37. package/dist/runtime/query/__tests__/context-size-on-the-wire.test.d.ts.map +1 -0
  38. package/dist/runtime/query/__tests__/context-size-on-the-wire.test.js +100 -0
  39. package/dist/runtime/query/__tests__/context-size-on-the-wire.test.js.map +1 -0
  40. package/dist/runtime/query/guard.d.ts +28 -0
  41. package/dist/runtime/query/guard.d.ts.map +1 -1
  42. package/dist/runtime/query/guard.js +31 -0
  43. package/dist/runtime/query/guard.js.map +1 -1
  44. package/dist/runtime/query/iteration/__tests__/settle-grace.test.d.ts +2 -0
  45. package/dist/runtime/query/iteration/__tests__/settle-grace.test.d.ts.map +1 -0
  46. package/dist/runtime/query/iteration/__tests__/settle-grace.test.js +226 -0
  47. package/dist/runtime/query/iteration/__tests__/settle-grace.test.js.map +1 -0
  48. package/dist/runtime/query/iteration/index.d.ts +92 -0
  49. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  50. package/dist/runtime/query/iteration/index.js +814 -566
  51. package/dist/runtime/query/iteration/index.js.map +1 -1
  52. package/dist/runtime/query/iteration/phases/__tests__/compaction-declined.test.d.ts +2 -0
  53. package/dist/runtime/query/iteration/phases/__tests__/compaction-declined.test.d.ts.map +1 -0
  54. package/dist/runtime/query/iteration/phases/__tests__/compaction-declined.test.js +95 -0
  55. package/dist/runtime/query/iteration/phases/__tests__/compaction-declined.test.js.map +1 -0
  56. package/dist/runtime/query/iteration/phases/compaction.d.ts +34 -0
  57. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  58. package/dist/runtime/query/iteration/phases/compaction.js +61 -4
  59. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  60. package/dist/tools/__tests__/untrusted-envelope.test.js +16 -0
  61. package/dist/tools/__tests__/untrusted-envelope.test.js.map +1 -1
  62. package/dist/tools/coordinator/__tests__/completion-delivery.test.js +117 -0
  63. package/dist/tools/coordinator/__tests__/completion-delivery.test.js.map +1 -1
  64. package/dist/tools/coordinator/__tests__/task-list.test.js +57 -0
  65. package/dist/tools/coordinator/__tests__/task-list.test.js.map +1 -1
  66. package/dist/tools/coordinator/index.d.ts.map +1 -1
  67. package/dist/tools/coordinator/index.js +109 -11
  68. package/dist/tools/coordinator/index.js.map +1 -1
  69. package/dist/tools/untrusted-envelope.d.ts.map +1 -1
  70. package/dist/tools/untrusted-envelope.js +9 -1
  71. package/dist/tools/untrusted-envelope.js.map +1 -1
  72. package/dist/types/agent/gateway.d.ts +18 -0
  73. package/dist/types/agent/gateway.d.ts.map +1 -1
  74. package/dist/types/provider/interface.d.ts +35 -0
  75. package/dist/types/provider/interface.d.ts.map +1 -1
  76. package/dist/types/run/entity.d.ts +16 -0
  77. package/dist/types/run/entity.d.ts.map +1 -1
  78. package/dist/types/run/events.d.ts +75 -0
  79. package/dist/types/run/events.d.ts.map +1 -1
  80. package/dist/types/run/events.js.map +1 -1
  81. package/dist/types/run/prepare-step.d.ts +17 -2
  82. package/dist/types/run/prepare-step.d.ts.map +1 -1
  83. package/dist/types/verification/index.d.ts +98 -0
  84. package/dist/types/verification/index.d.ts.map +1 -1
  85. package/dist/types/verification/index.js +10 -0
  86. package/dist/types/verification/index.js.map +1 -1
  87. package/dist/verification/__tests__/argument-pattern.test.d.ts +2 -0
  88. package/dist/verification/__tests__/argument-pattern.test.d.ts.map +1 -0
  89. package/dist/verification/__tests__/argument-pattern.test.js +122 -0
  90. package/dist/verification/__tests__/argument-pattern.test.js.map +1 -0
  91. package/dist/verification/gate.d.ts.map +1 -1
  92. package/dist/verification/gate.js +44 -0
  93. package/dist/verification/gate.js.map +1 -1
  94. package/dist/verification/rules.d.ts.map +1 -1
  95. package/dist/verification/rules.js +27 -0
  96. package/dist/verification/rules.js.map +1 -1
  97. package/package.json +1 -1
  98. package/src/agents/SupervisorAgent.ts +175 -166
  99. package/src/agents/__tests__/supervisor-inbox-scope.test.ts +149 -0
  100. package/src/bridge/a2a/mapper.ts +4 -0
  101. package/src/bridge/sse/mapper.ts +25 -0
  102. package/src/contracts/api.ts +1 -0
  103. package/src/gateway/__tests__/completion-inbox.test.ts +348 -2
  104. package/src/gateway/completion-inbox.ts +248 -16
  105. package/src/manager/run/persistence.ts +12 -0
  106. package/src/run/reporter.ts +12 -0
  107. package/src/runtime/query/__tests__/completion-does-not-erase-the-answer.test.ts +163 -0
  108. package/src/runtime/query/__tests__/completion-notification.test.ts +486 -34
  109. package/src/runtime/query/__tests__/context-size-on-the-wire.test.ts +122 -0
  110. package/src/runtime/query/guard.ts +32 -0
  111. package/src/runtime/query/iteration/__tests__/settle-grace.test.ts +265 -0
  112. package/src/runtime/query/iteration/index.ts +902 -636
  113. package/src/runtime/query/iteration/phases/__tests__/compaction-declined.test.ts +124 -0
  114. package/src/runtime/query/iteration/phases/compaction.ts +83 -10
  115. package/src/tools/__tests__/untrusted-envelope.test.ts +23 -0
  116. package/src/tools/coordinator/__tests__/completion-delivery.test.ts +147 -0
  117. package/src/tools/coordinator/__tests__/task-list.test.ts +72 -0
  118. package/src/tools/coordinator/index.ts +122 -15
  119. package/src/tools/untrusted-envelope.ts +9 -1
  120. package/src/types/agent/gateway.ts +18 -0
  121. package/src/types/provider/interface.ts +39 -0
  122. package/src/types/run/entity.ts +17 -0
  123. package/src/types/run/events.ts +75 -0
  124. package/src/types/run/prepare-step.ts +17 -2
  125. package/src/types/verification/index.ts +61 -0
  126. package/src/verification/__tests__/argument-pattern.test.ts +158 -0
  127. package/src/verification/gate.ts +45 -0
  128. package/src/verification/rules.ts +28 -0
@@ -44,6 +44,14 @@ export function describeRule(rule: VerificationRule): string {
44
44
  return `allowed by category (${rule.categories.join(', ')})`
45
45
  case 'allow_by_tier':
46
46
  return `allowed by tier (${rule.tiers.join(', ')})`
47
+ case 'argument_pattern': {
48
+ // Names the argument, not just the pattern. That is what tells a
49
+ // model whether a different value could get through — which is the
50
+ // difference between rewording once and rewording forever.
51
+ const verb = rule.decision === 'deny' ? 'denied' : 'allowed'
52
+ return `${verb} because the \`${rule.argument}\` argument matched ${rule.pattern} (this rule applies to ${rule.toolNames.join(', ')})`
53
+ }
54
+
47
55
  case 'custom_pattern': {
48
56
  const where = rule.target === 'both' ? 'name or arguments' : rule.target
49
57
  const verb = rule.decision === 'deny' ? 'denied' : 'allowed'
@@ -126,6 +134,43 @@ export class VerificationGate {
126
134
  }
127
135
  }
128
136
 
137
+ if (rule.type === 'argument_pattern') {
138
+ // Needs BOTH, because it is the rule that names both.
139
+ //
140
+ // The name set is recorded only after the pattern compiles, so
141
+ // a rule with a typo'd regex leaves neither half behind. That
142
+ // ordering is defence in depth and NOT what makes the guarantee
143
+ // — `evaluateRule` returns null on a missing compiled pattern
144
+ // before it ever looks at the name set, so reversing these two
145
+ // lines changes no behaviour. Measured: reversing them fails no
146
+ // test, and the test that looks like it covers this is really
147
+ // covering the check in `evaluateRule`.
148
+ //
149
+ // Written down because the alternative is someone later reading
150
+ // the order as load-bearing and preserving it for the wrong
151
+ // reason, or removing the real check believing this one covers
152
+ // it.
153
+ if (rule.pattern.length > MAX_CUSTOM_PATTERN_LENGTH) {
154
+ this.log.warn('Argument pattern exceeds max length, skipping', {
155
+ index: i,
156
+ length: rule.pattern.length,
157
+ maxLength: MAX_CUSTOM_PATTERN_LENGTH,
158
+ })
159
+ continue
160
+ }
161
+ try {
162
+ const compiled = new RegExp(rule.pattern)
163
+ this.compiledPatterns.set(i, compiled)
164
+ this.nameSets.set(i, new Set(rule.toolNames))
165
+ } catch (err) {
166
+ this.log.warn('Invalid argument pattern regex, skipping', {
167
+ index: i,
168
+ pattern: rule.pattern,
169
+ error: err instanceof Error ? err.message : String(err),
170
+ })
171
+ }
172
+ }
173
+
129
174
  if (rule.type === 'allow_by_name') {
130
175
  this.nameSets.set(i, new Set(rule.toolNames))
131
176
  }
@@ -63,6 +63,34 @@ export function evaluateRule(
63
63
  return compiledPattern.test(target) ? rule.decision : null
64
64
  }
65
65
 
66
+ case 'argument_pattern': {
67
+ if (!compiledPattern) return null
68
+ if (!nameSet?.has(toolName)) return null
69
+
70
+ if (typeof toolInput !== 'object' || toolInput === null) return null
71
+ const value = (toolInput as Record<string, unknown>)[rule.argument]
72
+
73
+ // The subject is the argument's own value, which is the whole point
74
+ // — `^git push` here means what a reader expects, where the same
75
+ // pattern against the serialised object could never match.
76
+ //
77
+ // Numbers and booleans are rendered rather than skipped, because
78
+ // `String(4000)` is unambiguous and anchorable. Objects and arrays
79
+ // are NOT: no string a pattern could match says anything true about
80
+ // a structured value, and serialising one would put us back where
81
+ // `custom_pattern` already is. A rule about the shape of an input
82
+ // is a rule about the tool, and `deny_by_name` is where it belongs.
83
+ const subject =
84
+ typeof value === 'string'
85
+ ? value
86
+ : typeof value === 'number' || typeof value === 'boolean'
87
+ ? String(value)
88
+ : undefined
89
+ if (subject === undefined) return null
90
+
91
+ return compiledPattern.test(subject) ? rule.decision : null
92
+ }
93
+
66
94
  case 'allow_by_tier': {
67
95
  if (toolDef?.tier && rule.tiers.includes(toolDef.tier)) {
68
96
  return 'allow'