agentbox-sdk 0.1.500 → 0.1.501

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.
@@ -2,7 +2,7 @@ import {
2
2
  Agent,
3
3
  agentboxRoot,
4
4
  getAgentLayout
5
- } from "../chunk-JYI7MRGO.js";
5
+ } from "../chunk-2FCUUUXG.js";
6
6
  import "../chunk-775FIGGL.js";
7
7
  import {
8
8
  AGENT_RESERVED_PORTS,
@@ -1518,7 +1518,7 @@ function mapOpenCodeTools(tools) {
1518
1518
  }
1519
1519
  return Object.fromEntries(tools.map((tool) => [tool, true]));
1520
1520
  }
1521
- function buildOpenCodeSubagentConfig(subAgents) {
1521
+ function buildOpenCodeSubagentConfig(subAgents, permission) {
1522
1522
  return Object.fromEntries(
1523
1523
  (subAgents ?? []).map((subAgent) => [
1524
1524
  subAgent.name,
@@ -1526,6 +1526,7 @@ function buildOpenCodeSubagentConfig(subAgents) {
1526
1526
  mode: "subagent",
1527
1527
  description: subAgent.description,
1528
1528
  prompt: subAgent.instructions,
1529
+ ...permission ? { permission } : {},
1529
1530
  // opencode reads a per-agent `model` as a "<providerID>/<modelID>"
1530
1531
  // string (e.g. "openrouter/deepseek/deepseek-v4-flash"). Without it,
1531
1532
  // the sub-agent silently inherits the orchestrator's model instead of
@@ -4406,7 +4407,10 @@ function buildOpenCodeConfig(options, interactiveApproval) {
4406
4407
  agent: {
4407
4408
  agentbox: baseAgent,
4408
4409
  ...reasoningVariants,
4409
- ...buildOpenCodeSubagentConfig(options.subAgents)
4410
+ ...buildOpenCodeSubagentConfig(
4411
+ options.subAgents,
4412
+ buildOpenCodePermissionConfig(interactiveApproval)
4413
+ )
4410
4414
  }
4411
4415
  };
4412
4416
  }
@@ -4887,6 +4891,33 @@ var OpenCodeAgentAdapter = class {
4887
4891
  }
4888
4892
  const announcedUserMessageIds = /* @__PURE__ */ new Set();
4889
4893
  const foreignMessageIds = /* @__PURE__ */ new Set();
4894
+ const runSessionIds = /* @__PURE__ */ new Set([sessionId]);
4895
+ const resolveRunSession = async (candidate) => {
4896
+ if (runSessionIds.has(candidate)) return true;
4897
+ try {
4898
+ const sessions = await fetchJson(`${runtime.baseUrl}/session`, {
4899
+ headers: runtime.previewHeaders
4900
+ });
4901
+ if (!Array.isArray(sessions)) return false;
4902
+ const parentById = /* @__PURE__ */ new Map();
4903
+ for (const session of sessions) {
4904
+ if (typeof session?.id === "string" && typeof session?.parentID === "string") {
4905
+ parentById.set(session.id, session.parentID);
4906
+ }
4907
+ }
4908
+ const lineage = [];
4909
+ let cursor = candidate;
4910
+ while (cursor && !runSessionIds.has(cursor) && lineage.length < 16) {
4911
+ lineage.push(cursor);
4912
+ cursor = parentById.get(cursor);
4913
+ }
4914
+ if (!cursor || !runSessionIds.has(cursor)) return false;
4915
+ for (const id of lineage) runSessionIds.add(id);
4916
+ return true;
4917
+ } catch {
4918
+ return false;
4919
+ }
4920
+ };
4890
4921
  sseTask = (async () => {
4891
4922
  try {
4892
4923
  for await (const event of streamSseResilient(
@@ -4920,6 +4951,13 @@ var OpenCodeAgentAdapter = class {
4920
4951
  }
4921
4952
  sink.emitRaw(raw);
4922
4953
  const eventType = typeof payload?.type === "string" ? String(payload.type) : event.event;
4954
+ if (eventType === "session.created" || eventType === "session.updated") {
4955
+ const properties = payload.properties;
4956
+ const info = properties?.info;
4957
+ if (info && typeof info.id === "string" && typeof info.parentID === "string" && runSessionIds.has(info.parentID)) {
4958
+ runSessionIds.add(info.id);
4959
+ }
4960
+ }
4923
4961
  if (eventType === "message.updated") {
4924
4962
  const properties = payload.properties;
4925
4963
  const info = properties?.info;
@@ -4960,7 +4998,8 @@ var OpenCodeAgentAdapter = class {
4960
4998
  }
4961
4999
  if (eventType === "permission.asked") {
4962
5000
  const properties = payload.properties;
4963
- if (properties && typeof properties.sessionID === "string" && properties.sessionID === sessionId) {
5001
+ if (properties && typeof properties.sessionID === "string" && await resolveRunSession(properties.sessionID)) {
5002
+ const askingSessionId = properties.sessionID;
4964
5003
  const permissionEvent = createOpenCodePermissionEvent(
4965
5004
  request,
4966
5005
  raw,
@@ -4971,7 +5010,7 @@ var OpenCodeAgentAdapter = class {
4971
5010
  decision: "allow"
4972
5011
  };
4973
5012
  await fetchJson(
4974
- `${runtime.baseUrl}/session/${sessionId}/permissions/${permissionEvent.requestId}`,
5013
+ `${runtime.baseUrl}/session/${askingSessionId}/permissions/${permissionEvent.requestId}`,
4975
5014
  {
4976
5015
  method: "POST",
4977
5016
  headers: {
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  Agent,
3
3
  agentboxRoot,
4
4
  getAgentLayout
5
- } from "./chunk-JYI7MRGO.js";
5
+ } from "./chunk-2FCUUUXG.js";
6
6
  import {
7
7
  ProviderLogAssembler,
8
8
  createNormalizedEvent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentbox-sdk",
3
- "version": "0.1.500",
3
+ "version": "0.1.501",
4
4
  "description": "Swappable coding agents and sandbox providers for Bun and TypeScript.",
5
5
  "license": "MIT",
6
6
  "repository": {