@theokit/sdk 4.21.1 → 4.23.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.
- package/dist/compaction.cjs +31 -0
- package/dist/compaction.cjs.map +1 -1
- package/dist/compaction.d.cts +79 -0
- package/dist/compaction.d.ts +79 -0
- package/dist/compaction.js +28 -1
- package/dist/compaction.js.map +1 -1
- package/dist/{cron-Bhdyjl0B.d.ts → cron-B_NkE_VM.d.ts} +15 -1
- package/dist/{cron-M2Xz7lq2.d.cts → cron-x3muPNgg.d.cts} +15 -1
- package/dist/cron.cjs +461 -332
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +461 -332
- package/dist/cron.js.map +1 -1
- package/dist/{errors-gE8612p9.d.cts → errors-BdL-buYn.d.cts} +1 -1
- package/dist/{errors-CG2RpeW-.d.ts → errors-DHZtSNnj.d.ts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +461 -332
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +461 -332
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +634 -503
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -12
- package/dist/index.d.ts +21 -12
- package/dist/index.js +634 -503
- package/dist/index.js.map +1 -1
- package/dist/internal/global-singleton.d.ts +13 -0
- package/dist/internal/llm/openai-messages.d.ts +2 -0
- package/dist/internal/local-agent/mcp-pool.d.ts +41 -0
- package/dist/internal/local-agent/real-local-run.d.ts +2 -0
- package/dist/internal/persistence/index.cjs +3 -1
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.js +3 -1
- package/dist/internal/persistence/index.js.map +1 -1
- package/dist/internal/providers/registry.d.ts +1 -0
- package/dist/internal/runtime/lifecycle/context-budget-event.d.ts +25 -0
- package/dist/internal/runtime/lifecycle/goal-marker.d.ts +13 -0
- package/dist/internal/runtime/lifecycle/run-until.d.ts +0 -1
- package/dist/internal/session/agent-session.d.ts +1 -1
- package/dist/internal/session/session-cache.d.ts +20 -0
- package/dist/models.cjs +11 -15
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +11 -15
- package/dist/models.js.map +1 -1
- package/dist/persistence.cjs +3 -1
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +3 -1
- package/dist/persistence.js.map +1 -1
- package/dist/provider-catalog.json +144 -469
- package/dist/{run-DFM1H2jW.d.cts → run-OJbGyweZ.d.cts} +20 -1
- package/dist/{run-DFM1H2jW.d.ts → run-OJbGyweZ.d.ts} +20 -1
- package/dist/sandbox/index.cjs +47 -15
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.js +47 -15
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/linux-sandbox.d.cts +16 -6
- package/dist/sandbox/linux-sandbox.d.ts +16 -6
- package/dist/types/agent.d.ts +14 -0
- package/dist/types/run-events.d.ts +20 -1
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.js.map +1 -1
- package/package.json +2 -2
- package/dist/goal-loop.d.ts +0 -35
|
@@ -105,7 +105,7 @@ declare class PermissionEngine {
|
|
|
105
105
|
*
|
|
106
106
|
* @public
|
|
107
107
|
*/
|
|
108
|
-
type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunTripwireEvent | RunCompletionCheckEvent;
|
|
108
|
+
type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunCompactionFallbackEvent | RunTripwireEvent | RunCompletionCheckEvent;
|
|
109
109
|
/**
|
|
110
110
|
* SE24 — a guardrail processor called `abort()`; the run stops with a tripwire.
|
|
111
111
|
* Delivered via {@link SendOptions.onRunEvent} (mirrors the `RunResult.tripwire`
|
|
@@ -180,6 +180,25 @@ interface RunCompactBoundaryEvent {
|
|
|
180
180
|
/** Token count before compaction, when known. */
|
|
181
181
|
readonly preTokens?: number;
|
|
182
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* M77 — auto-compaction is budgeting against a FLOOR, because neither the catalog nor the caller
|
|
185
|
+
* supplied a context window for this model.
|
|
186
|
+
*
|
|
187
|
+
* The prior behaviour was to disable auto-compaction entirely and write one line to stderr per
|
|
188
|
+
* process. That is fail-OPEN: the conversation grows until the provider rejects it. This event exists
|
|
189
|
+
* so a surface can say "I am running without a real budget" instead of the user discovering it at the
|
|
190
|
+
* moment of failure.
|
|
191
|
+
*
|
|
192
|
+
* Not emitted when the window came from the catalog (the normal path) or from an explicit caller
|
|
193
|
+
* override (the caller already knows).
|
|
194
|
+
*/
|
|
195
|
+
interface RunCompactionFallbackEvent {
|
|
196
|
+
readonly type: "compaction_fallback";
|
|
197
|
+
/** The model whose window is unknown — what the user needs to fix in configuration. */
|
|
198
|
+
readonly model: string;
|
|
199
|
+
/** The floor being budgeted against, after the safety margin. */
|
|
200
|
+
readonly window: number;
|
|
201
|
+
}
|
|
183
202
|
/**
|
|
184
203
|
* SE2 — the opt-in sink for {@link RunEvent}s. Supplied via `SendOptions.onRunEvent`.
|
|
185
204
|
* Synchronous + best-effort: a throwing sink must never break the run (the emitter
|
|
@@ -105,7 +105,7 @@ declare class PermissionEngine {
|
|
|
105
105
|
*
|
|
106
106
|
* @public
|
|
107
107
|
*/
|
|
108
|
-
type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunTripwireEvent | RunCompletionCheckEvent;
|
|
108
|
+
type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunCompactionFallbackEvent | RunTripwireEvent | RunCompletionCheckEvent;
|
|
109
109
|
/**
|
|
110
110
|
* SE24 — a guardrail processor called `abort()`; the run stops with a tripwire.
|
|
111
111
|
* Delivered via {@link SendOptions.onRunEvent} (mirrors the `RunResult.tripwire`
|
|
@@ -180,6 +180,25 @@ interface RunCompactBoundaryEvent {
|
|
|
180
180
|
/** Token count before compaction, when known. */
|
|
181
181
|
readonly preTokens?: number;
|
|
182
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* M77 — auto-compaction is budgeting against a FLOOR, because neither the catalog nor the caller
|
|
185
|
+
* supplied a context window for this model.
|
|
186
|
+
*
|
|
187
|
+
* The prior behaviour was to disable auto-compaction entirely and write one line to stderr per
|
|
188
|
+
* process. That is fail-OPEN: the conversation grows until the provider rejects it. This event exists
|
|
189
|
+
* so a surface can say "I am running without a real budget" instead of the user discovering it at the
|
|
190
|
+
* moment of failure.
|
|
191
|
+
*
|
|
192
|
+
* Not emitted when the window came from the catalog (the normal path) or from an explicit caller
|
|
193
|
+
* override (the caller already knows).
|
|
194
|
+
*/
|
|
195
|
+
interface RunCompactionFallbackEvent {
|
|
196
|
+
readonly type: "compaction_fallback";
|
|
197
|
+
/** The model whose window is unknown — what the user needs to fix in configuration. */
|
|
198
|
+
readonly model: string;
|
|
199
|
+
/** The floor being budgeted against, after the safety margin. */
|
|
200
|
+
readonly window: number;
|
|
201
|
+
}
|
|
183
202
|
/**
|
|
184
203
|
* SE2 — the opt-in sink for {@link RunEvent}s. Supplied via `SendOptions.onRunEvent`.
|
|
185
204
|
* Synchronous + best-effort: a throwing sink must never break the run (the emitter
|
package/dist/sandbox/index.cjs
CHANGED
|
@@ -542,7 +542,7 @@ var LinuxSandbox = class extends LocalSandbox {
|
|
|
542
542
|
this.cwd = config.workDir ?? process.cwd();
|
|
543
543
|
this.bin = opts.bin ?? "bwrap";
|
|
544
544
|
this.env = opts.env ?? allowlistedEnv();
|
|
545
|
-
this.seccompPath = this.network
|
|
545
|
+
this.seccompPath = seccompPathParaRede(this.network);
|
|
546
546
|
}
|
|
547
547
|
/** Extracted for test visibility — delegates to the pure `wrapCommandForSandbox` (M57, single wrap SoT). */
|
|
548
548
|
wrapCommand(command) {
|
|
@@ -558,6 +558,32 @@ var LinuxSandbox = class extends LocalSandbox {
|
|
|
558
558
|
command
|
|
559
559
|
);
|
|
560
560
|
}
|
|
561
|
+
/**
|
|
562
|
+
* M75 review (arquitetura, HIGH) — sem este override a classe MENTIA.
|
|
563
|
+
*
|
|
564
|
+
* `LinuxSandbox` se documenta como "kernel-enforced sandbox backend", mas sobrescrevia apenas
|
|
565
|
+
* `execute`. `uploadFile` continuava o herdado de `LocalSandbox`, que escreve direto no host via
|
|
566
|
+
* `fs/promises` e aceita caminho ABSOLUTO — sem bwrap, sem seccomp, sem restrição de caminho. E
|
|
567
|
+
* `SandboxBackend.writeFile` delega a ele. O resultado era uma classe incoerente: ler, buscar e
|
|
568
|
+
* listar passavam pelo confinamento; escrever, não.
|
|
569
|
+
*
|
|
570
|
+
* Rotear pelo `execute` embrulhado resolve na raiz: a escrita passa a viver sob a MESMA política
|
|
571
|
+
* do resto — se o bwrap nega o caminho, a escrita falha, como deve. O conteúdo vai por stdin (não
|
|
572
|
+
* por argv) porque argv tem limite de tamanho e conteúdo de arquivo não tem.
|
|
573
|
+
*/
|
|
574
|
+
async uploadFile(caminho, conteudo) {
|
|
575
|
+
if (this.mode === "danger-full-access") return super.uploadFile(caminho, conteudo);
|
|
576
|
+
const alvo = caminho.startsWith("/") ? caminho : `${this.cwd}/${caminho}`;
|
|
577
|
+
const b64 = Buffer.from(conteudo).toString("base64");
|
|
578
|
+
const r = await this.execute(
|
|
579
|
+
`mkdir -p ${shellQuote(path.dirname(alvo))} && printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(alvo)}`
|
|
580
|
+
);
|
|
581
|
+
if (r.exitCode !== 0) {
|
|
582
|
+
throw new Error(
|
|
583
|
+
`uploadFile bloqueado ou falhou sob confinamento (${alvo}): ${r.stderr.trim() || `exit ${r.exitCode}`}`
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
561
587
|
execute(command, opts) {
|
|
562
588
|
const wrapped = this.wrapCommand(command);
|
|
563
589
|
if (wrapped === null) return super.execute(command, opts);
|
|
@@ -632,28 +658,34 @@ var avisouInterativo = false;
|
|
|
632
658
|
function resetInteractiveWarnLatch() {
|
|
633
659
|
avisouInterativo = false;
|
|
634
660
|
}
|
|
661
|
+
function seccompPathParaRede(redeLiberada) {
|
|
662
|
+
return redeLiberada ? void 0 : restrictedSeccompPath();
|
|
663
|
+
}
|
|
664
|
+
function decidirConfinamento(opts) {
|
|
665
|
+
if (opts.mode === "danger-full-access") return null;
|
|
666
|
+
const detection = (opts.detect ?? detectBwrapMemoizado)();
|
|
667
|
+
if (detection.ok) return detection.bin;
|
|
668
|
+
if (!avisouInterativo) {
|
|
669
|
+
avisouInterativo = true;
|
|
670
|
+
const warn = opts.warn ?? ((m) => console.warn(redactSecrets(m)));
|
|
671
|
+
warn(
|
|
672
|
+
`[sandbox] OS-level enforcement unavailable (${detection.reason}) \u2014 interactive session runs WITHOUT kernel confinement (sandbox_mode=${opts.mode}).`
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
return null;
|
|
676
|
+
}
|
|
635
677
|
function interactiveWrapCommand(opts) {
|
|
636
678
|
return (command, cwd) => {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
if (!detection.ok) {
|
|
640
|
-
if (!avisouInterativo) {
|
|
641
|
-
avisouInterativo = true;
|
|
642
|
-
const warn = opts.warn ?? ((m) => console.warn(redactSecrets(m)));
|
|
643
|
-
warn(
|
|
644
|
-
`[sandbox] OS-level enforcement unavailable (${detection.reason}) \u2014 interactive session runs WITHOUT kernel confinement (sandbox_mode=${opts.mode}).`
|
|
645
|
-
);
|
|
646
|
-
}
|
|
647
|
-
return null;
|
|
648
|
-
}
|
|
679
|
+
const bin = decidirConfinamento(opts);
|
|
680
|
+
if (bin === null) return null;
|
|
649
681
|
return wrapCommandForSandbox(
|
|
650
682
|
opts.mode,
|
|
651
683
|
{
|
|
652
684
|
cwd,
|
|
653
685
|
network: opts.network ?? false,
|
|
654
686
|
env: allowlistedEnv(),
|
|
655
|
-
bin
|
|
656
|
-
seccompPath:
|
|
687
|
+
bin,
|
|
688
|
+
seccompPath: seccompPathParaRede(opts.network ?? false)
|
|
657
689
|
},
|
|
658
690
|
command
|
|
659
691
|
);
|