@tangle-network/agent-runtime 0.102.0 → 0.102.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 (77) hide show
  1. package/dist/agent.d.ts +1 -1
  2. package/dist/agent.js +5 -3
  3. package/dist/agent.js.map +1 -1
  4. package/dist/analyst-loop.d.ts +1 -1
  5. package/dist/candidate-execution/index.js +5 -4
  6. package/dist/{chunk-SPCD4IQQ.js → chunk-377GOJHJ.js} +2 -2
  7. package/dist/{chunk-LKKIM5QD.js → chunk-3DW5DEKQ.js} +3 -3
  8. package/dist/{chunk-KVJQV342.js → chunk-6MR4IJRW.js} +25 -1777
  9. package/dist/chunk-6MR4IJRW.js.map +1 -0
  10. package/dist/{chunk-4AMAFNUD.js → chunk-7FJJUC73.js} +311 -40
  11. package/dist/chunk-7FJJUC73.js.map +1 -0
  12. package/dist/{chunk-23Z7N5IG.js → chunk-CI7WS6S2.js} +5 -5
  13. package/dist/{chunk-DA7YL6I4.js → chunk-CK76OZPM.js} +3 -3
  14. package/dist/{chunk-KSBUSEUA.js → chunk-KJ2Q4T7F.js} +2 -2
  15. package/dist/{chunk-MAONWP4R.js → chunk-KPHTCHQ4.js} +611 -1419
  16. package/dist/chunk-KPHTCHQ4.js.map +1 -0
  17. package/dist/{chunk-AIBIRAJ6.js → chunk-KSM6GFHP.js} +2 -2
  18. package/dist/chunk-L5DST3QC.js +351 -0
  19. package/dist/chunk-L5DST3QC.js.map +1 -0
  20. package/dist/{chunk-TGDHHHH4.js → chunk-LJLG734E.js} +12 -253
  21. package/dist/chunk-LJLG734E.js.map +1 -0
  22. package/dist/chunk-ROILMKDL.js +1338 -0
  23. package/dist/chunk-ROILMKDL.js.map +1 -0
  24. package/dist/{chunk-N2CEE5Q3.js → chunk-RTB3TC73.js} +3 -3
  25. package/dist/chunk-SQ3ZJH3Y.js +3082 -0
  26. package/dist/chunk-SQ3ZJH3Y.js.map +1 -0
  27. package/dist/chunk-UPWGXKXB.js +254 -0
  28. package/dist/chunk-UPWGXKXB.js.map +1 -0
  29. package/dist/{completion-gate-C80jiRfN.d.ts → completion-gate-C6dhVN-N.d.ts} +2 -2
  30. package/dist/{coordination-BFE3Den7.d.ts → coordination-D9l_YmwW.d.ts} +6 -6
  31. package/dist/environment-provider.d.ts +2 -2
  32. package/dist/{improve-CIml6hT3.d.ts → improve-B40dRu0X.d.ts} +40 -19
  33. package/dist/index.d.ts +329 -21
  34. package/dist/index.js +541 -137
  35. package/dist/index.js.map +1 -1
  36. package/dist/intelligence.d.ts +5 -5
  37. package/dist/intelligence.js +7 -5
  38. package/dist/intelligence.js.map +1 -1
  39. package/dist/knowledge.d.ts +8 -8
  40. package/dist/knowledge.js +9 -7
  41. package/dist/{local-harness-ZqCx51u7.d.ts → local-harness-CtK9dSny.d.ts} +14 -2
  42. package/dist/{loop-runner-bin-Cn1N2rRo.d.ts → loop-runner-bin-PnWslIw4.d.ts} +2 -2
  43. package/dist/loop-runner-bin.d.ts +6 -6
  44. package/dist/loop-runner-bin.js +6 -4
  45. package/dist/loops.d.ts +231 -460
  46. package/dist/loops.js +58 -37
  47. package/dist/mcp/bin.js +2 -2
  48. package/dist/mcp/index.d.ts +184 -12
  49. package/dist/mcp/index.js +31 -9
  50. package/dist/mcp/index.js.map +1 -1
  51. package/dist/mcp/memory-bin.d.ts +1 -0
  52. package/dist/mcp/memory-bin.js +22 -0
  53. package/dist/mcp/memory-bin.js.map +1 -0
  54. package/dist/profiles.d.ts +3 -3
  55. package/dist/structural-rollout-D7xik9XR.d.ts +446 -0
  56. package/dist/{substrate-DO2GHNg2.d.ts → substrate-Dyiqmd3o.d.ts} +1 -1
  57. package/dist/{supervise-BLPI50-w.d.ts → supervise-BQdNAXtK.d.ts} +4 -4
  58. package/dist/testing.js +10 -8
  59. package/dist/testing.js.map +1 -1
  60. package/dist/{types-B3vAW0Oq.d.ts → types-CLat4bT9.d.ts} +1 -1
  61. package/dist/{types-CmnA2iL3.d.ts → types-D870JlH0.d.ts} +2 -2
  62. package/dist/{worktree-fanout-DCA3G4bO.d.ts → worktree-fanout-DsIR4d6w.d.ts} +234 -234
  63. package/package.json +4 -3
  64. package/dist/chunk-4AMAFNUD.js.map +0 -1
  65. package/dist/chunk-IKGCKPDX.js +0 -1115
  66. package/dist/chunk-IKGCKPDX.js.map +0 -1
  67. package/dist/chunk-KVJQV342.js.map +0 -1
  68. package/dist/chunk-MAONWP4R.js.map +0 -1
  69. package/dist/chunk-TGDHHHH4.js.map +0 -1
  70. package/dist/{chunk-SPCD4IQQ.js.map → chunk-377GOJHJ.js.map} +0 -0
  71. package/dist/{chunk-LKKIM5QD.js.map → chunk-3DW5DEKQ.js.map} +0 -0
  72. package/dist/{chunk-23Z7N5IG.js.map → chunk-CI7WS6S2.js.map} +0 -0
  73. package/dist/{chunk-DA7YL6I4.js.map → chunk-CK76OZPM.js.map} +0 -0
  74. package/dist/{chunk-KSBUSEUA.js.map → chunk-KJ2Q4T7F.js.map} +0 -0
  75. package/dist/{chunk-AIBIRAJ6.js.map → chunk-KSM6GFHP.js.map} +0 -0
  76. package/dist/{chunk-N2CEE5Q3.js.map → chunk-RTB3TC73.js.map} +0 -0
  77. package/dist/{sanitize-BTSsdBXw.d.ts → sanitize-DEbPNtyI.d.ts} +58 -58
@@ -1,3 +1,9 @@
1
+ import {
2
+ assertNoProtectedBytes,
3
+ createProtectedRecordRedactor,
4
+ redactProtectedReason,
5
+ redactProtectedValue
6
+ } from "./chunk-UPWGXKXB.js";
1
7
  import {
2
8
  contentAddress
3
9
  } from "./chunk-IMSNJSXH.js";
@@ -2839,7 +2845,7 @@ function requireRecord(value, label) {
2839
2845
  }
2840
2846
 
2841
2847
  // src/candidate-execution/finalize.ts
2842
- import { isLlmSpan as isLlmSpan2, REDACTION_VERSION as REDACTION_VERSION2 } from "@tangle-network/agent-eval";
2848
+ import { isLlmSpan as isLlmSpan2, REDACTION_VERSION } from "@tangle-network/agent-eval";
2843
2849
  import {
2844
2850
  agentCandidateRunReceiptSchema,
2845
2851
  agentCandidateWorkspaceSnapshotEvidenceSchema
@@ -3067,253 +3073,6 @@ function safeAdd(left, right, label) {
3067
3073
  return total;
3068
3074
  }
3069
3075
 
3070
- // src/candidate-execution/protected-redaction.ts
3071
- import { createHmac, randomBytes as randomBytes2 } from "crypto";
3072
- import {
3073
- DEFAULT_REDACTION_RULES,
3074
- REDACTION_VERSION,
3075
- redactString
3076
- } from "@tangle-network/agent-eval";
3077
- function createProtectedRecordRedactor(protectedValues) {
3078
- const identityKey = randomBytes2(32);
3079
- const aggregate = {
3080
- version: REDACTION_VERSION,
3081
- redactionCount: 0,
3082
- byRule: {}
3083
- };
3084
- const mergeReport = (report) => {
3085
- aggregate.version = report.version;
3086
- aggregate.redactionCount += report.redactionCount;
3087
- for (const [rule, count] of Object.entries(report.byRule)) {
3088
- aggregate.byRule[rule] = (aggregate.byRule[rule] ?? 0) + count;
3089
- }
3090
- };
3091
- const redactScalar = (value, record) => {
3092
- const redacted = redactProtectedValue(value, protectedValues);
3093
- if (record) mergeReport(redacted.report);
3094
- return redacted.value;
3095
- };
3096
- const identifier = (value, record) => {
3097
- const redacted = redactScalar(value, record);
3098
- if (redacted === value) return value;
3099
- const digest = createHmac("sha256", identityKey).update(value).digest("hex");
3100
- return `${redacted}:hmac-sha256:${digest}`;
3101
- };
3102
- const transform = (value, record) => {
3103
- const transformed = transformProtectedRecord(
3104
- value,
3105
- void 0,
3106
- record,
3107
- redactScalar,
3108
- identifier
3109
- );
3110
- assertNoProtectedEvidence(transformed, protectedValues);
3111
- return transformed;
3112
- };
3113
- return Object.freeze({
3114
- record: (value) => transform(value, true),
3115
- query: (value) => transform(value, false),
3116
- identifier: (value) => identifier(value, false),
3117
- traceIdentity: (trace) => transform(trace, false),
3118
- report: () => ({
3119
- version: aggregate.version,
3120
- redactionCount: aggregate.redactionCount,
3121
- byRule: { ...aggregate.byRule }
3122
- })
3123
- });
3124
- }
3125
- function redactProtectedValue(value, protectedValues) {
3126
- const report = {
3127
- version: REDACTION_VERSION,
3128
- redactionCount: 0,
3129
- byRule: {}
3130
- };
3131
- const rules = protectedRedactionRules(protectedValues);
3132
- const redacted = redactNode(value, protectedValues, rules, report);
3133
- assertNoProtectedEvidence(redacted, protectedValues);
3134
- return { value: redacted, report };
3135
- }
3136
- function redactProtectedReason(reason, protectedValues) {
3137
- try {
3138
- return redactProtectedValue(reason, protectedValues).value;
3139
- } catch {
3140
- return "candidate execution failed with a protected error";
3141
- }
3142
- }
3143
- function assertNoProtectedEvidence(value, protectedValues) {
3144
- if (value instanceof Uint8Array) {
3145
- assertNoProtectedBytes(value, protectedValues);
3146
- return;
3147
- }
3148
- if (typeof value === "string") {
3149
- for (const protectedValue of protectedValueVariants(protectedValues)) {
3150
- if (value.includes(protectedValue)) {
3151
- throw new Error("protected value survived candidate evidence redaction");
3152
- }
3153
- }
3154
- if (decodedBase64ContainsProtectedValue(value, protectedValues)) {
3155
- throw new Error("base64 protected value survived candidate evidence redaction");
3156
- }
3157
- return;
3158
- }
3159
- if (Array.isArray(value)) {
3160
- for (const entry of value) assertNoProtectedEvidence(entry, protectedValues);
3161
- return;
3162
- }
3163
- if (value && typeof value === "object") {
3164
- for (const [key, entry] of Object.entries(value)) {
3165
- assertNoProtectedEvidence(key, protectedValues);
3166
- assertNoProtectedEvidence(entry, protectedValues);
3167
- }
3168
- }
3169
- }
3170
- function assertNoProtectedBytes(bytes, protectedValues) {
3171
- if (containsProtectedBytes(bytes, protectedValues)) {
3172
- throw new Error("protected value survived candidate evidence byte redaction");
3173
- }
3174
- }
3175
- function redactNode(value, protectedValues, rules, report) {
3176
- if (value instanceof Uint8Array) {
3177
- if (containsProtectedBytes(value, protectedValues)) {
3178
- recordRedaction(report, "candidate-access-binary", 1);
3179
- return Uint8Array.from(Buffer.from("[redacted:candidate-access-binary]", "utf8"));
3180
- }
3181
- return Uint8Array.from(value);
3182
- }
3183
- if (typeof value === "string") {
3184
- if (decodedBase64ContainsProtectedValue(value, protectedValues)) {
3185
- recordRedaction(report, "candidate-access-binary", 1);
3186
- return "[redacted:candidate-access-binary]";
3187
- }
3188
- const redacted = redactString(value, [...rules]);
3189
- for (const [rule, count] of Object.entries(redacted.report.byRule)) {
3190
- recordRedaction(report, rule, count);
3191
- }
3192
- return redacted.output;
3193
- }
3194
- if (Array.isArray(value)) {
3195
- return value.map((entry) => redactNode(entry, protectedValues, rules, report));
3196
- }
3197
- if (value && typeof value === "object") {
3198
- const entries = [];
3199
- const seenKeys = /* @__PURE__ */ new Set();
3200
- for (const [key, entry] of Object.entries(value)) {
3201
- const redactedKey = redactNode(key, protectedValues, rules, report);
3202
- if (typeof redactedKey !== "string" || seenKeys.has(redactedKey)) {
3203
- throw new Error("protected evidence redaction produced an ambiguous object key");
3204
- }
3205
- seenKeys.add(redactedKey);
3206
- entries.push([redactedKey, redactNode(entry, protectedValues, rules, report)]);
3207
- }
3208
- return Object.fromEntries(entries);
3209
- }
3210
- return value;
3211
- }
3212
- function transformProtectedRecord(value, fieldName, record, redactScalar, redactIdentifier) {
3213
- if (value instanceof Uint8Array) return redactScalar(value, record);
3214
- if (typeof value === "string") {
3215
- return fieldName && isIdentifierFieldName(fieldName) ? redactIdentifier(value, record) : redactScalar(value, record);
3216
- }
3217
- if (Array.isArray(value)) {
3218
- return value.map(
3219
- (entry) => transformProtectedRecord(entry, fieldName, record, redactScalar, redactIdentifier)
3220
- );
3221
- }
3222
- if (!value || typeof value !== "object") return value;
3223
- if (fieldName === "tags") {
3224
- return transformTagMap(value, record, redactScalar, redactIdentifier);
3225
- }
3226
- if (fieldName === "tag") {
3227
- return transformTagFilter(value, record, redactScalar, redactIdentifier);
3228
- }
3229
- const entries = [];
3230
- const seenKeys = /* @__PURE__ */ new Set();
3231
- for (const [key, entry] of Object.entries(value)) {
3232
- const redactedKey = redactScalar(key, record);
3233
- if (seenKeys.has(redactedKey)) {
3234
- throw new Error("protected evidence redaction produced an ambiguous object key");
3235
- }
3236
- seenKeys.add(redactedKey);
3237
- entries.push([
3238
- redactedKey,
3239
- transformProtectedRecord(entry, key, record, redactScalar, redactIdentifier)
3240
- ]);
3241
- }
3242
- return Object.fromEntries(entries);
3243
- }
3244
- function transformTagMap(value, record, redactScalar, redactIdentifier) {
3245
- const entries = [];
3246
- const seenKeys = /* @__PURE__ */ new Set();
3247
- for (const [key, entry] of Object.entries(value)) {
3248
- const redactedKey = redactIdentifier(key, record);
3249
- if (seenKeys.has(redactedKey)) {
3250
- throw new Error("protected evidence redaction produced an ambiguous trace tag");
3251
- }
3252
- seenKeys.add(redactedKey);
3253
- entries.push([
3254
- redactedKey,
3255
- typeof entry === "string" ? redactIdentifier(entry, record) : transformProtectedRecord(entry, key, record, redactScalar, redactIdentifier)
3256
- ]);
3257
- }
3258
- return Object.fromEntries(entries);
3259
- }
3260
- function transformTagFilter(value, record, redactScalar, redactIdentifier) {
3261
- const output = {};
3262
- for (const [key, entry] of Object.entries(value)) {
3263
- const redactedKey = redactScalar(key, record);
3264
- output[redactedKey] = (key === "key" || key === "value") && typeof entry === "string" ? redactIdentifier(entry, record) : transformProtectedRecord(entry, key, record, redactScalar, redactIdentifier);
3265
- }
3266
- return output;
3267
- }
3268
- function isIdentifierFieldName(name) {
3269
- return /ids?$/i.test(name);
3270
- }
3271
- function protectedRedactionRules(protectedValues) {
3272
- const exactRules = protectedValueVariants(protectedValues).sort((left, right) => right.length - left.length || left.localeCompare(right)).map((value, index) => ({
3273
- id: `candidate-access-${index}`,
3274
- pattern: new RegExp(escapeRegularExpression(value), "g"),
3275
- replacement: "[redacted:candidate-access]"
3276
- }));
3277
- return [...exactRules, ...DEFAULT_REDACTION_RULES];
3278
- }
3279
- function recordRedaction(report, rule, count) {
3280
- if (count <= 0) return;
3281
- report.redactionCount += count;
3282
- report.byRule[rule] = (report.byRule[rule] ?? 0) + count;
3283
- }
3284
- function containsProtectedBytes(bytes, protectedValues) {
3285
- const source = Buffer.from(bytes);
3286
- return protectedValueVariants(protectedValues).some(
3287
- (value) => source.includes(Buffer.from(value, "utf8"))
3288
- );
3289
- }
3290
- function decodedBase64ContainsProtectedValue(value, protectedValues) {
3291
- if (value.length < 4 || value.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(value)) {
3292
- return false;
3293
- }
3294
- try {
3295
- return containsProtectedBytes(Buffer.from(value, "base64"), protectedValues);
3296
- } catch {
3297
- return false;
3298
- }
3299
- }
3300
- function protectedValueVariants(protectedValues) {
3301
- const variants = /* @__PURE__ */ new Set();
3302
- for (const value of normalizedProtectedValues(protectedValues)) {
3303
- variants.add(value);
3304
- variants.add(Buffer.from(value, "utf8").toString("base64"));
3305
- variants.add(Buffer.from(value, "utf8").toString("base64url"));
3306
- variants.add(encodeURIComponent(value));
3307
- }
3308
- return [...variants];
3309
- }
3310
- function normalizedProtectedValues(values) {
3311
- return [...new Set(values.filter((value) => value.length > 0))];
3312
- }
3313
- function escapeRegularExpression(value) {
3314
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3315
- }
3316
-
3317
3076
  // src/candidate-execution/finalize.ts
3318
3077
  async function finalizeAgentCandidateRun(state, capture, traceStore, traceIdentity, settlement, evidence, protectedValues, writeRedactionReport, signal) {
3319
3078
  let termination;
@@ -3361,7 +3120,7 @@ async function finalizeAgentCandidateRun(state, capture, traceStore, traceIdenti
3361
3120
  );
3362
3121
  const redacted = redactProtectedValue(
3363
3122
  {
3364
- run: { ...run, redactionVersion: REDACTION_VERSION2 },
3123
+ run: { ...run, redactionVersion: REDACTION_VERSION },
3365
3124
  spans: orderedSpans,
3366
3125
  events: orderedEvents,
3367
3126
  budget: orderedBudget,
@@ -3377,7 +3136,7 @@ async function finalizeAgentCandidateRun(state, capture, traceStore, traceIdenti
3377
3136
  ...redacted.value,
3378
3137
  evaluatorLimits: { resultTimeoutMs: state.resultTimeoutMs },
3379
3138
  redaction: {
3380
- version: REDACTION_VERSION2,
3139
+ version: REDACTION_VERSION,
3381
3140
  redactionCount: (writeRedactionReport?.redactionCount ?? 0) + redacted.report.redactionCount,
3382
3141
  byRule: combinedByRule
3383
3142
  }
@@ -4971,7 +4730,7 @@ var CandidateExecutionDeadlineError = class extends Error {
4971
4730
  };
4972
4731
 
4973
4732
  // src/candidate-execution/prepare.ts
4974
- import { randomBytes as randomBytes3 } from "crypto";
4733
+ import { randomBytes as randomBytes2 } from "crypto";
4975
4734
  import { lstat as lstat2, readdir as readdir2 } from "fs/promises";
4976
4735
  import { isAbsolute, posix as posix2, relative as relative2, resolve as resolveHostPath } from "path";
4977
4736
  import {
@@ -5097,7 +4856,7 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
5097
4856
  const profileActivation = profileApplication.profileActivation;
5098
4857
  const container = await resolveContainer(candidate, task, ports);
5099
4858
  const resolvedModel = await resolveModel(candidate, task, ports);
5100
- const preparationId = `candidate-preparation.${randomBytes3(32).toString("base64url")}`;
4859
+ const preparationId = `candidate-preparation.${randomBytes2(32).toString("base64url")}`;
5101
4860
  const reservationExpiresAtMs = Date.now() + Math.max(MIN_RESERVATION_TTL_MS, reservationWindowMs);
5102
4861
  const modelReservation = await withinCandidateCleanupDeadline(
5103
4862
  () => ports.models.reserveGrant({
@@ -5815,4 +5574,4 @@ export {
5815
5574
  executePreparedAgentCandidate,
5816
5575
  prepareAgentCandidateExecution
5817
5576
  };
5818
- //# sourceMappingURL=chunk-TGDHHHH4.js.map
5577
+ //# sourceMappingURL=chunk-LJLG734E.js.map