@byok-sdk/client 0.17.0 → 0.18.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/adapters/detect-outcome.d.ts +1 -1
- package/dist/adapters/index.js +17 -6
- package/dist/adapters/index.js.map +1 -1
- package/dist/bin/byok-agent.js +28 -11
- package/dist/bin/byok-agent.js.map +1 -1
- package/dist/daemon/agent-egress-sanitizer.d.ts +2 -0
- package/dist/daemon/task-runner.d.ts +2 -0
- package/dist/index.js +27 -10
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -33,6 +33,8 @@ export type SanitizedEnvelope = Readonly<{
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function sanitizeEgressEnvelope(envelope: Envelope, policy: Readonly<AgentEgressPolicy>, sanitizer: AgentEgressSanitizer | undefined, context?: Omit<AgentEgressSanitizerContext, 'lane' | 'policyRevision' | 'envelopeType'> & {
|
|
35
35
|
lane?: 'latest-value' | 'reliable';
|
|
36
|
+
/** Set only from the active task's frozen terminalProjection, never payload inference. */
|
|
37
|
+
resultDocumentSelected?: boolean;
|
|
36
38
|
}): SanitizedEnvelope;
|
|
37
39
|
/** Sanitizes a reliable payload before it is hashed/appended, never after. */
|
|
38
40
|
export declare function sanitizeReliablePayload(payload: unknown, policy: Readonly<AgentEgressPolicy>, sanitizer: AgentEgressSanitizer | undefined, context?: Omit<AgentEgressSanitizerContext, 'lane' | 'policyRevision'>): unknown;
|
|
@@ -584,6 +584,8 @@ export declare class TaskRunner {
|
|
|
584
584
|
* egress contract must never reclassify their existing wire semantics.
|
|
585
585
|
*/
|
|
586
586
|
usesAgentEgress(taskId: string): boolean;
|
|
587
|
+
/** Frozen offer authority for the outbound result-document lane. */
|
|
588
|
+
selectsResultDocument(taskId: string): boolean;
|
|
587
589
|
/** M5 batch-3 (workstream 2): effective `maxTaskOutputBytes` cap for this daemon — see {@link DEFAULT_MAX_TASK_OUTPUT_BYTES}'s own doc comment. */
|
|
588
590
|
private get maxTaskOutputBytes();
|
|
589
591
|
/** Effective per-event inline ceiling for this daemon — see `DaemonConfig.maxInlineEventBytes`. */
|
package/dist/index.js
CHANGED
|
@@ -4019,13 +4019,13 @@ function classifyDetectError(error) {
|
|
|
4019
4019
|
if (code === "EACCES" || code === "EPERM" || code === "ENOEXEC") return { kind: "not-executable" };
|
|
4020
4020
|
return { kind: "probe-failed" };
|
|
4021
4021
|
}
|
|
4022
|
-
async function probeRuntimeVersion(command, timeoutMs) {
|
|
4022
|
+
async function probeRuntimeVersion(command, timeoutMs, prefixArgs = []) {
|
|
4023
4023
|
if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0) throw new TypeError("invalid runtime probe timeout");
|
|
4024
4024
|
return new Promise((resolve) => {
|
|
4025
4025
|
let timer;
|
|
4026
4026
|
let timedOut = false;
|
|
4027
4027
|
try {
|
|
4028
|
-
const child = execFile(command, ["--version"], { encoding: "utf8" }, (error, stdout, stderr) => {
|
|
4028
|
+
const child = execFile(command, [...prefixArgs, "--version"], { encoding: "utf8" }, (error, stdout, stderr) => {
|
|
4029
4029
|
if (timer) clearTimeout(timer);
|
|
4030
4030
|
if (error?.code === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER") resolve({ kind: "probe-failed" });
|
|
4031
4031
|
else if (timedOut) resolve({ kind: "timeout" });
|
|
@@ -4959,6 +4959,9 @@ function withoutProviderCredentials(env) {
|
|
|
4959
4959
|
// src/adapters/pi/pi-adapter.ts
|
|
4960
4960
|
var execFileAsync = promisify(execFile);
|
|
4961
4961
|
var DETECT_TIMEOUT_MS = 5e3;
|
|
4962
|
+
function piInvocation(bin) {
|
|
4963
|
+
return bin.source === "package" ? { command: process.execPath, entry: bin.command } : { command: bin.command };
|
|
4964
|
+
}
|
|
4962
4965
|
function errorMessage3(err) {
|
|
4963
4966
|
return err instanceof Error ? err.message : String(err);
|
|
4964
4967
|
}
|
|
@@ -5007,6 +5010,7 @@ function validatePiByokLauncherConfig(launcher) {
|
|
|
5007
5010
|
const reserved = /* @__PURE__ */ new Set([
|
|
5008
5011
|
"--",
|
|
5009
5012
|
"--pi-bin",
|
|
5013
|
+
"--pi-entry",
|
|
5010
5014
|
"--profile-db",
|
|
5011
5015
|
"--session-dir",
|
|
5012
5016
|
"--macos-keychain-path",
|
|
@@ -5055,7 +5059,12 @@ var PiAdapter = class {
|
|
|
5055
5059
|
async detect() {
|
|
5056
5060
|
try {
|
|
5057
5061
|
const bin = this.resolveBin();
|
|
5058
|
-
const
|
|
5062
|
+
const invocation = piInvocation(bin);
|
|
5063
|
+
const probe = await probeRuntimeVersion(
|
|
5064
|
+
invocation.command,
|
|
5065
|
+
DETECT_TIMEOUT_MS,
|
|
5066
|
+
invocation.entry === void 0 ? [] : [invocation.entry]
|
|
5067
|
+
);
|
|
5059
5068
|
if (probe.kind !== "available") return probe;
|
|
5060
5069
|
const version = probe.stdout.trim() || probe.stderr.trim();
|
|
5061
5070
|
const authPresent = PROVIDER_CREDENTIAL_ENV_NAMES.some((name) => process.env[name] !== void 0);
|
|
@@ -5086,7 +5095,8 @@ var PiAdapter = class {
|
|
|
5086
5095
|
requiredCapabilities: Object.freeze([...selection.providerProfile.requiredCapabilities])
|
|
5087
5096
|
})
|
|
5088
5097
|
}) : Object.freeze({ ...selection });
|
|
5089
|
-
|
|
5098
|
+
const invocation = piInvocation(bin);
|
|
5099
|
+
let command = invocation.command;
|
|
5090
5100
|
let launcherArgs;
|
|
5091
5101
|
if (pinnedSelection !== void 0) {
|
|
5092
5102
|
if (pinnedSelection.lane !== "byok" && pinnedSelection.lane !== "byok-profile" || pinnedSelection.runtimeId !== "pi") {
|
|
@@ -5115,7 +5125,8 @@ var PiAdapter = class {
|
|
|
5115
5125
|
launcherArgs = [
|
|
5116
5126
|
...launcher.args ?? [],
|
|
5117
5127
|
"--pi-bin",
|
|
5118
|
-
|
|
5128
|
+
invocation.command,
|
|
5129
|
+
...invocation.entry === void 0 ? [] : ["--pi-entry", invocation.entry],
|
|
5119
5130
|
"--profile-db",
|
|
5120
5131
|
launcher.profileDbPath,
|
|
5121
5132
|
"--session-dir",
|
|
@@ -5209,7 +5220,7 @@ var PiAdapter = class {
|
|
|
5209
5220
|
...resumeSessionId ? ["--session", resumeSessionId] : [],
|
|
5210
5221
|
...mapping.args
|
|
5211
5222
|
];
|
|
5212
|
-
const args = launcherArgs === void 0 ? piArgs : [...launcherArgs, "--", ...piArgs];
|
|
5223
|
+
const args = launcherArgs === void 0 ? [...invocation.entry === void 0 ? [] : [invocation.entry], ...piArgs] : [...launcherArgs, "--", ...piArgs];
|
|
5213
5224
|
let rpc;
|
|
5214
5225
|
try {
|
|
5215
5226
|
rpc = new PiRpcClient({
|
|
@@ -15578,6 +15589,10 @@ var TaskRunner = class {
|
|
|
15578
15589
|
usesAgentEgress(taskId) {
|
|
15579
15590
|
return this.tasks.get(taskId)?.egressEnabled === true;
|
|
15580
15591
|
}
|
|
15592
|
+
/** Frozen offer authority for the outbound result-document lane. */
|
|
15593
|
+
selectsResultDocument(taskId) {
|
|
15594
|
+
return this.tasks.get(taskId)?.terminalProjection?.mode === "result-document";
|
|
15595
|
+
}
|
|
15581
15596
|
/** M5 batch-3 (workstream 2): effective `maxTaskOutputBytes` cap for this daemon — see {@link DEFAULT_MAX_TASK_OUTPUT_BYTES}'s own doc comment. */
|
|
15582
15597
|
get maxTaskOutputBytes() {
|
|
15583
15598
|
return this.deps.maxTaskOutputBytes ?? DEFAULT_MAX_TASK_OUTPUT_BYTES;
|
|
@@ -18681,7 +18696,7 @@ function cloneJson(value) {
|
|
|
18681
18696
|
function asRecord(value) {
|
|
18682
18697
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
18683
18698
|
}
|
|
18684
|
-
function contentlessPayload(envelope) {
|
|
18699
|
+
function contentlessPayload(envelope, resultDocumentSelected) {
|
|
18685
18700
|
const payload = cloneJson(envelope.payload);
|
|
18686
18701
|
const record3 = asRecord(payload);
|
|
18687
18702
|
if (!record3) return payload;
|
|
@@ -18695,7 +18710,7 @@ function contentlessPayload(envelope) {
|
|
|
18695
18710
|
}
|
|
18696
18711
|
case "task.complete":
|
|
18697
18712
|
if (typeof record3.summary === "string") record3.summary = "[content omitted]";
|
|
18698
|
-
delete record3.document;
|
|
18713
|
+
if (!resultDocumentSelected) delete record3.document;
|
|
18699
18714
|
return record3;
|
|
18700
18715
|
case "task.fail":
|
|
18701
18716
|
case "task.decline":
|
|
@@ -18726,7 +18741,7 @@ function applyHostSanitizer(value, sanitizer, context) {
|
|
|
18726
18741
|
}
|
|
18727
18742
|
function sanitizeEgressEnvelope(envelope, policy, sanitizer, context = {}) {
|
|
18728
18743
|
try {
|
|
18729
|
-
const payload = policy.activity.mode === "metadata-status" ? contentlessPayload(envelope) : cloneJson(envelope.payload);
|
|
18744
|
+
const payload = policy.activity.mode === "metadata-status" ? contentlessPayload(envelope, context.resultDocumentSelected === true) : cloneJson(envelope.payload);
|
|
18730
18745
|
if (payload === void 0) return { ok: false, reason: "policy_denied" };
|
|
18731
18746
|
const sanitizedPayload = applyHostSanitizer(payload, sanitizer, {
|
|
18732
18747
|
lane: context.lane ?? "latest-value",
|
|
@@ -20626,7 +20641,9 @@ function buildDaemonWithAdapters(config, adapters, overrides = {}, assertionProb
|
|
|
20626
20641
|
sendSanitizedEnvelope(candidate);
|
|
20627
20642
|
return;
|
|
20628
20643
|
}
|
|
20629
|
-
const sanitized = sanitizeEgressEnvelope(candidate, egressPolicy, config.agentEgress?.sanitizer
|
|
20644
|
+
const sanitized = sanitizeEgressEnvelope(candidate, egressPolicy, config.agentEgress?.sanitizer, {
|
|
20645
|
+
resultDocumentSelected: runner.selectsResultDocument(candidate.task_id)
|
|
20646
|
+
});
|
|
20630
20647
|
if (!sanitized.ok) {
|
|
20631
20648
|
agentEgress.noteTransportDrop(sanitized.reason);
|
|
20632
20649
|
return;
|