@corenel/harness 0.3.2 → 0.4.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 (79) hide show
  1. package/LICENSE +93 -0
  2. package/dist/acp/index.js +2 -2
  3. package/dist/api/backend.js +1 -1
  4. package/dist/api/fileMirrorSource.js +2 -2
  5. package/dist/api/mirror.js +1 -1
  6. package/dist/compression.d.ts +15 -1
  7. package/dist/compression.d.ts.map +1 -1
  8. package/dist/compression.js +32 -1
  9. package/dist/compression.js.map +1 -1
  10. package/dist/core/loop.d.ts +10 -0
  11. package/dist/core/loop.d.ts.map +1 -1
  12. package/dist/core/loop.js +137 -14
  13. package/dist/core/loop.js.map +1 -1
  14. package/dist/core/spawn.d.ts +54 -0
  15. package/dist/core/spawn.d.ts.map +1 -0
  16. package/dist/core/spawn.js +58 -0
  17. package/dist/core/spawn.js.map +1 -0
  18. package/dist/dag/executeNode.js +2 -2
  19. package/dist/fileSchema.js +1 -1
  20. package/dist/guardrail/guardrail.js +1 -1
  21. package/dist/guardrail/index.js +7 -7
  22. package/dist/guardrail/permission-service.js +1 -1
  23. package/dist/guardrail/serialize.js +1 -1
  24. package/dist/guardrail/store.js +2 -2
  25. package/dist/prompts/config.js +2 -2
  26. package/dist/prompts/host.d.ts +14 -0
  27. package/dist/prompts/host.d.ts.map +1 -1
  28. package/dist/prompts/host.js.map +1 -1
  29. package/dist/prompts/index.d.ts.map +1 -1
  30. package/dist/prompts/index.js +9 -6
  31. package/dist/prompts/index.js.map +1 -1
  32. package/dist/prompts/library/defaults.generated.js +1 -1
  33. package/dist/prompts/library/defaults.generated.js.map +1 -1
  34. package/dist/prompts/library/index.js +1 -1
  35. package/dist/providers/contextWindow.d.ts +19 -0
  36. package/dist/providers/contextWindow.d.ts.map +1 -0
  37. package/dist/providers/contextWindow.js +68 -0
  38. package/dist/providers/contextWindow.js.map +1 -0
  39. package/dist/providers/gateway.js +1 -1
  40. package/dist/sessions/apiLeaseStore.js +1 -1
  41. package/dist/sessions/blobGc.d.ts +62 -0
  42. package/dist/sessions/blobGc.d.ts.map +1 -0
  43. package/dist/sessions/blobGc.js +154 -0
  44. package/dist/sessions/blobGc.js.map +1 -0
  45. package/dist/sessions/fileRecallStore.js +1 -1
  46. package/dist/sessions/fileSessionStore.js +1 -1
  47. package/dist/sidecar/host.d.ts +18 -2
  48. package/dist/sidecar/host.d.ts.map +1 -1
  49. package/dist/sidecar/host.js +42 -3
  50. package/dist/sidecar/host.js.map +1 -1
  51. package/dist/sidecar/server.d.ts.map +1 -1
  52. package/dist/sidecar/server.js +16 -0
  53. package/dist/sidecar/server.js.map +1 -1
  54. package/dist/sidecar/wsChannel.d.ts +4 -0
  55. package/dist/sidecar/wsChannel.d.ts.map +1 -0
  56. package/dist/sidecar/wsChannel.js +62 -0
  57. package/dist/sidecar/wsChannel.js.map +1 -0
  58. package/dist/skills.d.ts +17 -1
  59. package/dist/skills.d.ts.map +1 -1
  60. package/dist/skills.js +82 -20
  61. package/dist/skills.js.map +1 -1
  62. package/dist/tools/builtins.js +6 -6
  63. package/dist/tools/callAgent.d.ts +16 -0
  64. package/dist/tools/callAgent.d.ts.map +1 -0
  65. package/dist/tools/callAgent.js +53 -0
  66. package/dist/tools/callAgent.js.map +1 -0
  67. package/dist/tools/files.d.ts +10 -0
  68. package/dist/tools/files.d.ts.map +1 -1
  69. package/dist/tools/files.js +159 -8
  70. package/dist/tools/files.js.map +1 -1
  71. package/dist/tools/http.js +1 -1
  72. package/dist/tools/namespaces.d.ts.map +1 -1
  73. package/dist/tools/namespaces.js +16 -2
  74. package/dist/tools/namespaces.js.map +1 -1
  75. package/dist/tools/procs.d.ts +18 -0
  76. package/dist/tools/procs.d.ts.map +1 -0
  77. package/dist/tools/procs.js +281 -0
  78. package/dist/tools/procs.js.map +1 -0
  79. package/package.json +15 -7
package/LICENSE ADDED
@@ -0,0 +1,93 @@
1
+ Elastic License 2.0
2
+
3
+ URL: https://www.elastic.co/licensing/elastic-license
4
+
5
+ ## Acceptance
6
+
7
+ By using the software, you agree to all of the terms and conditions below.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
12
+ non-sublicensable, non-transferable license to use, copy, distribute, make
13
+ available, and prepare derivative works of the software, in each case subject to
14
+ the limitations and conditions below.
15
+
16
+ ## Limitations
17
+
18
+ You may not provide the software to third parties as a hosted or managed
19
+ service, where the service provides users with access to any substantial set of
20
+ the features or functionality of the software.
21
+
22
+ You may not move, change, disable, or circumvent the license key functionality
23
+ in the software, and you may not remove or obscure any functionality in the
24
+ software that is protected by the license key.
25
+
26
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
27
+ of the licensor in the software. Any use of the licensor's trademarks is subject
28
+ to applicable law.
29
+
30
+ ## Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can
33
+ license, or becomes able to license, to make, have made, use, sell, offer for
34
+ sale, import and have imported the software, in each case subject to the
35
+ limitations and conditions in this license. This license does not cover any
36
+ patent claims that you cause to be infringed by modifications or additions to
37
+ the software. If you or your company make any written claim that the software
38
+ infringes or contributes to infringement of any patent, your patent license for
39
+ the software granted under these terms ends immediately. If your company makes
40
+ such a claim, your patent license ends immediately for work on behalf of your
41
+ company.
42
+
43
+ ## Notices
44
+
45
+ You must ensure that anyone who gets a copy of any part of the software from you
46
+ also gets a copy of these terms.
47
+
48
+ If you modify the software, you must include in any modified copies of the
49
+ software prominent notices stating that you have modified the software.
50
+
51
+ ## No Other Rights
52
+
53
+ These terms do not imply any licenses other than those expressly granted in
54
+ these terms.
55
+
56
+ ## Termination
57
+
58
+ If you use the software in violation of these terms, such use is not licensed,
59
+ and your licenses will automatically terminate. If the licensor provides you
60
+ with a notice of your violation, and you cease all violation of this license no
61
+ later than 30 days after you receive that notice, your licenses will be
62
+ reinstated retroactively. However, if you violate these terms after such
63
+ reinstatement, any additional violation of these terms will cause your licenses
64
+ to terminate automatically and permanently.
65
+
66
+ ## No Liability
67
+
68
+ *As far as the law allows, the software comes as is, without any warranty or
69
+ condition, and the licensor will not be liable to you for any damages arising out
70
+ of these terms or the use or nature of the software, under any kind of legal
71
+ claim.*
72
+
73
+ ## Definitions
74
+
75
+ The **licensor** is the entity offering these terms, and the **software** is the
76
+ software the licensor makes available under these terms, including any portion of
77
+ it.
78
+
79
+ **you** refers to the individual or entity agreeing to these terms.
80
+
81
+ **your company** is any legal entity, sole proprietorship, or other kind of
82
+ organization that you work for, plus all organizations that have control over, are
83
+ under the control of, or are under common control with that organization.
84
+ **control** means ownership of substantially all the assets of an entity, or the
85
+ power to direct its management and policies by vote, contract, or otherwise.
86
+ Control can be direct or indirect.
87
+
88
+ **your licenses** are all the licenses granted to you for the software under these
89
+ terms.
90
+
91
+ **use** means anything you do with the software requiring one of your licenses.
92
+
93
+ **trademark** means trademarks, service marks, and similar rights.
package/dist/acp/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* ACP module barrel — the client-side translation between the Agent Client
2
2
  * Protocol and this harness's governance layer. Pure: no transport, no node.
3
3
  * The wire lives in packages/sidecar/src/acp/. */
4
- export { acpToSubject, acpDisplayTitle, levelToOptionId, ACP_KIND_ADDRESSES, ALLOW_KINDS, REJECT_KINDS, } from './policyMap';
5
- export { kindForTool, eventToSessionUpdate, stopReasonForAcp, } from './agentMap';
4
+ export { acpToSubject, acpDisplayTitle, levelToOptionId, ACP_KIND_ADDRESSES, ALLOW_KINDS, REJECT_KINDS, } from './policyMap.js';
5
+ export { kindForTool, eventToSessionUpdate, stopReasonForAcp, } from './agentMap.js';
6
6
  //# sourceMappingURL=index.js.map
@@ -20,7 +20,7 @@
20
20
  * Absent is normal. No backend means local-only, which is the correct state for a
21
21
  * laptop working alone and never an error to report.
22
22
  */
23
- import { CorenelApiClient } from './client';
23
+ import { CorenelApiClient } from './client.js';
24
24
  /** Capabilities a backend may advertise. Strings, not an enum: an older client
25
25
  * must be able to read a newer backend's list without choking on a name it does
26
26
  * not know. */
@@ -1,5 +1,5 @@
1
- import { foldTimeline } from '../sessions/timeline';
2
- import { deriveHead, parseHead } from '../sessions/head';
1
+ import { foldTimeline } from '../sessions/timeline.js';
2
+ import { deriveHead, parseHead } from '../sessions/head.js';
3
3
  export function makeFileMirrorSource(deps) {
4
4
  const now = deps.now ?? Date.now;
5
5
  const rootFor = (sessionId) => (typeof deps.sessionsRoot === 'function' ? deps.sessionsRoot(sessionId) : deps.sessionsRoot);
@@ -1,4 +1,4 @@
1
- import { LeaseConflict } from './client';
1
+ import { LeaseConflict } from './client.js';
2
2
  const blank = () => ({
3
3
  pushedIndex: 0, lastPushedAt: 0, lastError: '', authoritative: false, epoch: 0,
4
4
  });
@@ -1,9 +1,23 @@
1
1
  import type { CompressionMode, OffloadRef } from '@corenel/protocol';
2
- export type { CompressionMode, CompressionConfig, OffloadRef } from '@corenel/protocol';
2
+ export type { CompressionMode, CompressionConfig, CompressionStrategy, OffloadRef } from '@corenel/protocol';
3
3
  /** How much of an offloaded output to keep inline as a preview. */
4
4
  export declare const PREVIEW_BYTES = 800;
5
5
  /** Threshold for a given fill ratio (0–1). As the window fills, offload sooner. */
6
6
  export declare function effectiveThreshold(mode: CompressionMode, fill?: number): number;
7
+ export declare const OFFLOAD_MARKER_PREFIX = "[offloaded tool result \u00B7 ";
8
+ /** True if `content` is already a formatOffloadRef() pointer — i.e. this
9
+ * result was already offloaded and must not be recorded/rewritten again. */
10
+ export declare function isOffloadPointer(content: string): boolean;
11
+ /** The blob id (and recorded byte count) a formatOffloadRef() pointer carries,
12
+ * for a caller that needs to read the real content back — e.g. a restored
13
+ * transcript row recognizing a persisted pointer as still-offloaded (see
14
+ * @corenel/term's persist.ts). Returns `null` for anything that isn't a
15
+ * pointer, or a pointer whose tail doesn't parse (never thrown on — this can
16
+ * be read back out of a session log written by an older/different format). */
17
+ export declare function parseOffloadPointer(content: string): {
18
+ id: string;
19
+ bytes: number;
20
+ } | null;
7
21
  /** The self-describing reference that replaces a large output in the history.
8
22
  * Carries enough (tool, size, preview, recall instruction) for the model to
9
23
  * decide whether to pull the full content back. */
@@ -1 +1 @@
1
- {"version":3,"file":"compression.d.ts","sourceRoot":"","sources":["../compression.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACrE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAExF,mEAAmE;AACnE,eAAO,MAAM,aAAa,MAAM,CAAC;AAOjC,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,SAAI,GAAG,MAAM,CAI1E;AAED;;mDAEmD;AACnD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAGxD"}
1
+ {"version":3,"file":"compression.d.ts","sourceRoot":"","sources":["../compression.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACrE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE7G,mEAAmE;AACnE,eAAO,MAAM,aAAa,MAAM,CAAC;AAOjC,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,SAAI,GAAG,MAAM,CAI1E;AAQD,eAAO,MAAM,qBAAqB,mCAA8B,CAAC;AAEjE;4EAC4E;AAC5E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEzD;AAOD;;;;;8EAK8E;AAC9E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAMzF;AAED;;mDAEmD;AACnD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAGxD"}
@@ -17,11 +17,42 @@ export function effectiveThreshold(mode, fill = 0) {
17
17
  const factor = fill < 0.5 ? 1 : fill < 0.7 ? 0.7 : fill < 0.85 ? 0.5 : 0.35;
18
18
  return Math.max(FLOOR[mode], Math.round(BASE[mode] * factor));
19
19
  }
20
+ // The stable, load-bearing prefix every formatOffloadRef() output starts with.
21
+ // Exported (not just used internally) so any pass that needs to recognize an
22
+ // ALREADY-offloaded message — the deferred strategy's history-compaction pass
23
+ // in loop.ts is the first caller — checks this instead of re-deriving it or
24
+ // loose-matching a substring that could coincidentally appear in real tool
25
+ // output. Keep formatOffloadRef's head in sync with this if either changes.
26
+ export const OFFLOAD_MARKER_PREFIX = '[offloaded tool result · ';
27
+ /** True if `content` is already a formatOffloadRef() pointer — i.e. this
28
+ * result was already offloaded and must not be recorded/rewritten again. */
29
+ export function isOffloadPointer(content) {
30
+ return content.startsWith(OFFLOAD_MARKER_PREFIX);
31
+ }
32
+ // Matches the `{bytes} bytes · recall the full content with recall_result({ id: "{id}" })`
33
+ // tail formatOffloadRef() writes. Kept beside it so there is exactly one place
34
+ // that knows both directions of the pointer format.
35
+ const POINTER_TAIL_RE = /· ([\d,]+) bytes · recall the full content with recall_result\(\{ id: "([^"]+)" \}\)/;
36
+ /** The blob id (and recorded byte count) a formatOffloadRef() pointer carries,
37
+ * for a caller that needs to read the real content back — e.g. a restored
38
+ * transcript row recognizing a persisted pointer as still-offloaded (see
39
+ * @corenel/term's persist.ts). Returns `null` for anything that isn't a
40
+ * pointer, or a pointer whose tail doesn't parse (never thrown on — this can
41
+ * be read back out of a session log written by an older/different format). */
42
+ export function parseOffloadPointer(content) {
43
+ if (!isOffloadPointer(content))
44
+ return null;
45
+ const m = POINTER_TAIL_RE.exec(content);
46
+ if (!m)
47
+ return null;
48
+ const bytes = Number(m[1].replace(/,/g, ''));
49
+ return { id: m[2], bytes: Number.isFinite(bytes) ? bytes : 0 };
50
+ }
20
51
  /** The self-describing reference that replaces a large output in the history.
21
52
  * Carries enough (tool, size, preview, recall instruction) for the model to
22
53
  * decide whether to pull the full content back. */
23
54
  export function formatOffloadRef(ref) {
24
- const head = `[offloaded tool result · ${ref.toolName} · ${ref.bytes.toLocaleString()} bytes · recall the full content with recall_result({ id: "${ref.id}" })]`;
55
+ const head = `${OFFLOAD_MARKER_PREFIX}${ref.toolName} · ${ref.bytes.toLocaleString()} bytes · recall the full content with recall_result({ id: "${ref.id}" })]`;
25
56
  return ref.preview ? `${head}\n--- preview ---\n${ref.preview}${ref.bytes > ref.preview.length ? '\n…(truncated)' : ''}` : head;
26
57
  }
27
58
  //# sourceMappingURL=compression.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compression.js","sourceRoot":"","sources":["../compression.ts"],"names":[],"mappings":"AAAA;;;;;yFAKyF;AAOzF,mEAAmE;AACnE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC,+EAA+E;AAC/E,8BAA8B;AAC9B,MAAM,IAAI,GAAoC,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAM,EAAE,QAAQ,EAAE,KAAM,EAAE,UAAU,EAAE,IAAK,EAAE,CAAC;AAC3H,MAAM,KAAK,GAAoC,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAK,EAAE,QAAQ,EAAE,IAAK,EAAE,UAAU,EAAE,IAAK,EAAE,CAAC;AAE1H,mFAAmF;AACnF,MAAM,UAAU,kBAAkB,CAAC,IAAqB,EAAE,IAAI,GAAG,CAAC;IAChE,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,QAAQ,CAAC;IACpC,MAAM,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5E,OAAO,IAAI,CAAC,GAAG,CAA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IAC9C,MAAM,IAAI,GAAG,GAAG,qBAAqB,GAAG,GAAG,CAAC,QAAQ,MAAM,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,8DAA8D,GAAG,CAAC,EAAE,OAAO,CAAC;IAChK,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,sBAAsB,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAClI,CAAC"}
@@ -20,6 +20,16 @@ export interface RunAgentArgs {
20
20
  policy?: Policy;
21
21
  /** Per-tool permission resolver. When omitted, tools run without an approval gate. */
22
22
  permission?: PermissionService;
23
+ /** Customize the tool-result text a refused tool call gets. The kernel is
24
+ * host-agnostic and cannot know WHY a decision came back "deny" — a real
25
+ * person declining an interactive prompt, and a non-interactive host that
26
+ * has nobody to ask, are both just "deny" by the time they reach here. The
27
+ * default wording ("denied by the user") is only honest for the former;
28
+ * a host that fails closed with no prompt at all (see `run`/`run-agent` in
29
+ * @corenel/cli) should supply this so the model — and whoever reads the
30
+ * transcript — hears the actual cause and the actual remedy, not a claim
31
+ * that a person was asked and said no when nobody was asked anything. */
32
+ describePermissionDenial?: (toolName: string) => string;
23
33
  /** Context-compression config (rung-1 offload). Omit to disable. */
24
34
  compression?: CompressionConfig;
25
35
  /** Intra-run self-healing budget (stream-retry + tool-steer). Omit for defaults. */
@@ -1 +1 @@
1
- {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../core/loop.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,0BAA0B,EAAsB,MAAM,mCAAmC,CAAC;AACxG,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,mBAAmB,CA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AC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,0BAA0B,EAAE,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CA2U1E"}
package/dist/core/loop.js CHANGED
@@ -1,19 +1,31 @@
1
- import { streamCompletion } from '../providers/gateway';
2
- import { resolveRecovery, classifyStreamError, classifyToolError, shouldRetryStream, backoffDelay, toolRecoveryHint, ToolFailureTracker, abortableSleep, } from './recovery';
3
- import { alog } from '../log';
4
- import { initialState, evaluateTurnStart, evaluateToolCall, evaluateCompletion } from '../guardrail/guardrail';
5
- import { checkFeature } from '../guards';
6
- import { STANDARD_POLICY } from '../guardrail/builtins';
7
- import { toolAddress } from '../tools/namespaces';
8
- import { effectiveThreshold, formatOffloadRef } from '../compression';
9
- import { fillToolsMarker } from '../prompts/toolsMarker';
1
+ import { streamCompletion } from '../providers/gateway.js';
2
+ import { resolveRecovery, classifyStreamError, classifyToolError, shouldRetryStream, backoffDelay, toolRecoveryHint, ToolFailureTracker, abortableSleep, } from './recovery.js';
3
+ import { alog } from '../log.js';
4
+ import { initialState, evaluateTurnStart, evaluateToolCall, evaluateCompletion } from '../guardrail/guardrail.js';
5
+ import { checkFeature } from '../guards.js';
6
+ import { STANDARD_POLICY } from '../guardrail/builtins.js';
7
+ import { toolAddress } from '../tools/namespaces.js';
8
+ import { effectiveThreshold, formatOffloadRef, isOffloadPointer } from '../compression.js';
9
+ import { fillToolsMarker } from '../prompts/toolsMarker.js';
10
10
  export async function runAgent(args) {
11
11
  const { client, system, tools, toolCtx } = args;
12
12
  const policy = args.policy ?? STANDARD_POLICY;
13
13
  const permission = args.permission;
14
14
  const compression = args.compression;
15
15
  const ctxWindow = compression?.contextWindow;
16
+ const compressionStrategy = compression?.strategy ?? 'eager';
16
17
  let fill = 0; // window fill ratio; drives the adaptive offload threshold
18
+ // 'deferred' strategy only: results offloaded THIS turn, awaiting the ONE
19
+ // streamCompletion call that sends them in full (the turn right after
20
+ // they're produced — the model that asked for the result reads it). As soon
21
+ // as that call succeeds, they're rewritten in place to the compact pointer —
22
+ // immediately, not on some later "next call": the model already saw the full
23
+ // text in the call that just completed, so there is nothing left to wait
24
+ // for. This is what makes the returned/persisted `messages` show the pointer
25
+ // even for a run that ends right after (tool call, then answer, done — the
26
+ // common case), not only when a further call happens to follow within the
27
+ // same run.
28
+ const deferredOffloads = [];
17
29
  const maxTurns = policy.maxTurns ?? args.maxTurns ?? 8;
18
30
  const signal = args.signal ?? new AbortController().signal;
19
31
  const emit = (e) => args.onEvent?.(e);
@@ -31,6 +43,19 @@ export async function runAgent(args) {
31
43
  function: { name: t.name, description: t.description, parameters: t.parameters },
32
44
  }));
33
45
  const toolByName = new Map(tools.map((t) => [t.name, t]));
46
+ // 'deferred' strategy only, and CRITICAL to the design: compact the INCOMING
47
+ // history too, not just what this run produces. Without this, a result that
48
+ // was sent full and never got a "subsequent call" WITHIN the run that
49
+ // produced it (the common case — one tool call, one answer, done) stays full
50
+ // forever: the next conversation turn is a SEPARATE runAgent() invocation
51
+ // that starts from an empty compaction table and never rescans its input.
52
+ // Doing this at the very START of the run — before the first model call —
53
+ // means the one prefix-cache miss this rewrite costs lands on THIS run's
54
+ // first call, the cheapest place for it (a fresh prefix on a call about to
55
+ // happen anyway, rather than an extra rewrite mid-run).
56
+ if (compressionStrategy === 'deferred' && compression && compression.mode !== 'off' && toolCtx.recall) {
57
+ await compactIncomingOffloads(messages, toolByName, compression, toolCtx.recall, emit);
58
+ }
34
59
  const usage = { promptTokens: 0, completionTokens: 0 };
35
60
  let text = '';
36
61
  let stopReason = 'stop';
@@ -108,6 +133,27 @@ export async function runAgent(args) {
108
133
  stopReason = 'error';
109
134
  break;
110
135
  } // type-narrowing; unreachable
136
+ // Deferred compression: the call that just succeeded included every
137
+ // pending offloaded entry in FULL — that was their one required full send
138
+ // (the turn right after they were produced). Compact them to the pointer
139
+ // NOW, in place, and forget them: there is no "wait for a subsequent call"
140
+ // — the model already read the full text in the call that just completed,
141
+ // so the returned/persisted `messages` should show the pointer from this
142
+ // point on, even if the run ends immediately after (tool call, then
143
+ // answer, done — the common case, not a corner one). This also means a
144
+ // wholly separate runAgent() call over this same `messages` array (the
145
+ // CLI session persists `result.messages` verbatim and replays it on the
146
+ // next conversation turn/resume) inherits the compaction with no special
147
+ // knowledge of offload — and compactIncomingOffloads() above additionally
148
+ // catches any entry that predates THIS run's history for the same reason.
149
+ if (compressionStrategy === 'deferred' && deferredOffloads.length) {
150
+ for (const o of deferredOffloads) {
151
+ const orig = messages[o.index];
152
+ if (orig.role === 'tool')
153
+ messages[o.index] = { ...orig, content: formatOffloadRef(o.ref) };
154
+ }
155
+ deferredOffloads.length = 0;
156
+ }
111
157
  usage.promptTokens += streamed.usage.promptTokens;
112
158
  usage.completionTokens += streamed.usage.completionTokens;
113
159
  if (ctxWindow && ctxWindow > 0 && streamed.usage.promptTokens) {
@@ -195,16 +241,29 @@ export async function runAgent(args) {
195
241
  const decision = await permission.check({ name: tool.name, address, mutates: tool.mutates, permission: tool.permission }, parsed);
196
242
  emit({ type: 'permission', tool: tool.name, decision });
197
243
  if (decision === 'deny') {
198
- messages.push({ role: 'tool', tool_call_id: call.id, content: 'Permission denied by the user — the action was not performed.' });
244
+ const denialMsg = args.describePermissionDenial?.(tool.name)
245
+ ?? 'Permission denied by the user — the action was not performed.';
246
+ messages.push({ role: 'tool', tool_call_id: call.id, content: denialMsg });
199
247
  emit({ type: 'tool-result', id: call.id, name: tool.name, result: 'permission denied', isError: true });
200
248
  continue;
201
249
  }
202
250
  }
203
251
  const startedAt = Date.now();
252
+ // Live output port for this call: emits tool-delta while the tool runs.
253
+ // Closed the instant tool.run settles (success or throw) so a process that
254
+ // outlives its tool call can't emit a stray delta after tool-result — an
255
+ // out-of-order delta would corrupt any consumer reducing the event stream.
256
+ let callSettled = false;
257
+ const stream = (text) => {
258
+ if (callSettled)
259
+ return;
260
+ emit({ type: 'tool-delta', id: call.id, name: call.name, delta: text });
261
+ };
204
262
  try {
205
263
  // Per-call context: callId lets a tool correlate with UI state keyed by
206
264
  // tool_call id (propose_edit blocks on its review).
207
- const result = await tool.run(parsed, { ...toolCtx, callId: call.id });
265
+ const result = await tool.run(parsed, { ...toolCtx, callId: call.id, stream });
266
+ callSettled = true;
208
267
  const durationMs = Date.now() - startedAt;
209
268
  gstate.toolCalls++;
210
269
  gstate.calledTools.add(tool.name);
@@ -217,8 +276,12 @@ export async function runAgent(args) {
217
276
  emit({ type: 'heal', record: { site: 'tool', tool: tool.name, kind: recovered.kind, strategy: 'steer', attempt: recovered.count, outcome: 'recovered', error: '' } });
218
277
  }
219
278
  // Context compression (rung-1): offload a large, offloadable output to the
220
- // RecallStore and append a compact reference instead. Append-only — never
221
- // rewrites prior messages, so the OpenAI prefix cache stays valid.
279
+ // RecallStore. 'eager' (default) replaces it with the compact reference
280
+ // right here, before the model ever sees the full text — append-only, so
281
+ // the OpenAI prefix cache stays valid. 'deferred' still records it, but
282
+ // pushes the FULL result now; it is compacted in place as soon as the
283
+ // model's one required full-send call completes (see the deferredOffloads
284
+ // pass below, after the call succeeds).
222
285
  // Offload is an optimization, never a failure: if recording fails (e.g. a
223
286
  // read-only workspace), fall back to the full inline result rather than
224
287
  // discarding an otherwise-successful tool call.
@@ -227,8 +290,13 @@ export async function runAgent(args) {
227
290
  if (result.length > effectiveThreshold(compression.mode, fill)) {
228
291
  try {
229
292
  const ref = await toolCtx.recall.record(tool.name, result);
230
- out = formatOffloadRef(ref);
231
293
  emit({ type: 'offload', id: ref.id, name: tool.name, bytes: ref.bytes });
294
+ if (compressionStrategy === 'deferred') {
295
+ deferredOffloads.push({ index: messages.length, ref });
296
+ }
297
+ else {
298
+ out = formatOffloadRef(ref);
299
+ }
232
300
  }
233
301
  catch {
234
302
  out = result;
@@ -239,6 +307,7 @@ export async function runAgent(args) {
239
307
  emit({ type: 'tool-result', id: call.id, name: call.name, result: out, durationMs });
240
308
  }
241
309
  catch (e) {
310
+ callSettled = true;
242
311
  // Self-heal a failed tool call: classify it, count repeated same-kind
243
312
  // failures, and feed back a DIRECTED hint (re-read the schema / try an
244
313
  // alternative / stop hammering this tool) instead of a bare error — so the
@@ -274,6 +343,60 @@ export async function runAgent(args) {
274
343
  emit({ type: 'done', reason: stopReason });
275
344
  return { messages, text, usage, stopReason };
276
345
  }
346
+ /** 'deferred' strategy: compact any ALREADY-oversized tool result already
347
+ * sitting in the incoming history — i.e. produced by an earlier `runAgent()`
348
+ * call (a prior conversation turn, a resumed session) rather than this one.
349
+ * Mutates `messages` in place, using fill=0 (no usage feedback exists yet at
350
+ * the start of a run) so this reuses the exact same effectiveThreshold ramp
351
+ * the in-run offload path uses.
352
+ *
353
+ * Conservative by design, matching the report's stated limits:
354
+ * - Idempotent: `isOffloadPointer` recognizes an already-compacted message and
355
+ * skips it, so re-running this on the same history never re-records a blob
356
+ * or double-wraps a pointer.
357
+ * - A tool result whose producing tool cannot be identified (its tool_call_id
358
+ * has no matching assistant `tool_calls` entry earlier in this SAME history —
359
+ * should not happen for a well-formed conversation, but a truncated/edited
360
+ * history is possible) is left untouched rather than guessed at.
361
+ * - A tool result whose producing tool IS identified by name, but that name is
362
+ * not in THIS run's `tools` list (so its `noOffload` flag can't be read),
363
+ * is also left untouched — offloading it could violate a `noOffload`
364
+ * contract this pass has no way to check. */
365
+ async function compactIncomingOffloads(messages, toolByName, compression, recall, emit) {
366
+ // tool_call_id -> producing tool name, from every assistant tool_calls entry
367
+ // in this history. A tool message always follows the assistant call that
368
+ // produced it, so scanning once up front covers every tool message below.
369
+ const nameForCallId = new Map();
370
+ for (const m of messages) {
371
+ if (m.role === 'assistant' && m.tool_calls) {
372
+ for (const c of m.tool_calls)
373
+ nameForCallId.set(c.id, c.function.name);
374
+ }
375
+ }
376
+ for (let i = 0; i < messages.length; i++) {
377
+ const m = messages[i];
378
+ if (m.role !== 'tool' || typeof m.content !== 'string')
379
+ continue;
380
+ if (isOffloadPointer(m.content))
381
+ continue; // already compacted — idempotent
382
+ const toolName = nameForCallId.get(m.tool_call_id);
383
+ if (!toolName)
384
+ continue; // can't identify the producing tool — conservative
385
+ const tool = toolByName.get(toolName);
386
+ if (!tool || tool.noOffload)
387
+ continue; // unknown to this run, or explicitly exempt
388
+ if (m.content.length <= effectiveThreshold(compression.mode, 0))
389
+ continue;
390
+ try {
391
+ const ref = await recall.record(toolName, m.content);
392
+ messages[i] = { ...m, content: formatOffloadRef(ref) };
393
+ emit({ type: 'offload', id: ref.id, name: toolName, bytes: ref.bytes });
394
+ }
395
+ catch {
396
+ // Non-fatal, same as the in-run offload path: leave the full result inline.
397
+ }
398
+ }
399
+ }
277
400
  /** Ensure every tool_call in the final assistant message has a following tool
278
401
  * result — appending a synthetic one for any the run stopped before answering —
279
402
  * so the returned messages stay a valid conversation prefix. */
@@ -1 +1 @@
1
- {"version":3,"file":"loop.js","sourceRoot":"","sources":["../../core/loop.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAA2B,MAAM,sBAAsB,CAAC;AACjF,OAAO,EACL,eAAe,EAAuB,mBAAmB,EAAE,iBAAiB,EAC5E,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,GACtF,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC/G,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAA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,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAAC,GAAG,GAAG,CAAC,CAAC;YAAC,MAAM;QAAC,CAAC;IACxF,CAAC;IACD,IAAI,GAAG,GAAG,CAAC;QAAE,OAAO;IACpB,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,IAAI,CAAC,UAAU;QAAE,OAAO;IAC1D,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/C,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;YAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QAChC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;YACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,kDAAkD,EAAE,CAAC,CAAC;QACnH,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,54 @@
1
+ import type OpenAI from 'openai';
2
+ import type { AgentTool, ToolContext, Policy, CompressionConfig, NodeEvent } from '@corenel/protocol';
3
+ import type { PermissionService } from '../guardrail/permission-service';
4
+ /** How deep delegation may nest (spawn -> spawn -> spawn -> depth cap). */
5
+ export declare const SUB_MAX_DEPTH = 2;
6
+ /** Total spawns allowed across one run, at any depth. */
7
+ export declare const SUB_MAX_COUNT = 8;
8
+ /** Meta describing a spawned child, handed to `onNodeEvent` alongside its raw
9
+ * event so a host can tag/forward it however its own UI needs (see
10
+ * tools-web/workerHandler.ts's DAG-canvas tagging). */
11
+ export interface SpawnEventMeta {
12
+ /** The depth the child runs AT (the spawning context's depth + 1). */
13
+ depth: number;
14
+ /** The spawning node's id — the parent→child edge for a DAG canvas. */
15
+ parentNodeId: string;
16
+ /** This child's own node id. */
17
+ childId: string;
18
+ /** The child's task, truncated to a short label (falls back to `childId`). */
19
+ label: string;
20
+ }
21
+ export interface SpawnDeps {
22
+ depth: number;
23
+ /** Shared per-run spawn counter — the SAME object instance flows into every
24
+ * nested spawn, so it counts across the whole run, not per branch. */
25
+ counter: {
26
+ n: number;
27
+ };
28
+ parentSignal: AbortSignal;
29
+ /** The full tool set a spawned child may draw from (before its own request
30
+ * narrows it — see dag/executeNode.ts's `resolveTools`). */
31
+ tools: AgentTool[];
32
+ /** Everything the child's ToolContext needs except `signal` and `spawn`,
33
+ * which this module fills in per child. */
34
+ toolCtxBase: Omit<ToolContext, 'signal' | 'spawn'>;
35
+ client: OpenAI;
36
+ defaultModel: string;
37
+ policy?: Policy;
38
+ permission?: PermissionService;
39
+ compression?: CompressionConfig;
40
+ /** The spawning node's id — `ROOT_NODE_ID` at depth 0, the parent sub-agent's
41
+ * id when nested. Drives the parent->child edge a host may want to draw. */
42
+ nodeId: string;
43
+ /** Forwarded every event a spawned node emits (node-start/-event/-done/-error).
44
+ * Absent hosts (the CLI, today) simply don't observe sub-agent progress. */
45
+ onNodeEvent?: (event: NodeEvent, meta: SpawnEventMeta) => void;
46
+ /** Override the depth/count caps (tests only — production hosts use the
47
+ * defaults above so the guard can't drift between them). */
48
+ maxDepth?: number;
49
+ maxCount?: number;
50
+ }
51
+ /** Build a `ctx.spawn` bound to these deps. Recurses to build the CHILD's own
52
+ * `spawn` at `depth + 1`, `undefined` once `maxDepth` is reached. */
53
+ export declare function makeSpawn(deps: SpawnDeps): NonNullable<ToolContext['spawn']>;
54
+ //# sourceMappingURL=spawn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../core/spawn.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAGzE,2EAA2E;AAC3E,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,yDAAyD;AACzD,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B;;uDAEuD;AACvD,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,YAAY,EAAE,MAAM,CAAC;IACrB,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd;0EACsE;IACtE,OAAO,EAAE;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,YAAY,EAAE,WAAW,CAAC;IAC1B;gEAC4D;IAC5D,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB;+CAC2C;IAC3C,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,iBAAiB,CAAC;I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