@agentsky/sky 2.20.0 → 2.20.2

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.
@@ -1,7 +1,8 @@
1
1
  import {
2
+ admittedInputScopeSchema,
2
3
  external_exports,
3
4
  messagePartSchema
4
- } from "./chunk-DC3R6BV2.js";
5
+ } from "./chunk-GHTAIKQ6.js";
5
6
  import "./chunk-MLKGABMK.js";
6
7
 
7
8
  // ../../packages/chat/src/stream.ts
@@ -97,6 +98,16 @@ var internalEventSchema = external_exports.object({
97
98
  * session.deleted) — emitted verbatim; the host already persisted it. */
98
99
  lifecycle: external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough().optional()
99
100
  });
101
+ function workspaceIdentityForPod(body, supported) {
102
+ const { workspace_identity: token, ...rest } = body;
103
+ if (!token || supported) return body;
104
+ const text = `This runtime cannot receive the private workspace-identity file. Use this value instead wherever the instructions read the file ~/.config/agentsky/workspace-identity: ${token}. Never print, persist or share it.`;
105
+ const parts = [...rest.parts, { type: "text", index: Math.max(-1, ...rest.parts.map((part) => part.index)) + 1, text }];
106
+ if (!rest.events) return { ...rest, parts };
107
+ const previous = rest.events.find((event) => event.type === "system.message");
108
+ const system = { type: "system.message", content: [{ type: "text", text: [...previous?.type === "system.message" ? previous.content.map((block) => block.text) : [], text].join("\n\n") }] };
109
+ return { ...rest, parts, events: [...rest.events.filter((event) => event.type !== "system.message"), system] };
110
+ }
100
111
  function personalContextForPod(body, supported) {
101
112
  const { personal_context: grant, ...rest } = body;
102
113
  if (!grant || supported) return body;
@@ -107,15 +118,18 @@ function personalContextForPod(body, supported) {
107
118
  const system = { type: "system.message", content: [{ type: "text", text: [...previous?.type === "system.message" ? previous.content.map((block) => block.text) : [], text].join("\n\n") }] };
108
119
  return { ...rest, parts, events: [...rest.events.filter((event) => event.type !== "system.message"), system] };
109
120
  }
110
- function podMessageBody(messageId, turn, resourcesRevision = 0) {
121
+ function podMessageBody(messageId, turn, resourcesRevision = 0, inputScope) {
122
+ const scope = inputScope ? admittedInputScopeSchema.parse(inputScope) : void 0;
123
+ if (scope && scope.message_id !== messageId) throw new Error("input_scope_identity_mismatch");
124
+ const preparation = scope ? { input_scope: scope } : {};
111
125
  if ("events" in turn) {
112
126
  const envelope = {
113
127
  events: turn.events.system ? [turn.events.message, turn.events.system] : [turn.events.message],
114
128
  ...resourcesRevision > 0 ? { resources_revision: resourcesRevision } : {}
115
129
  };
116
- return { id: messageId, ...envelope, parts: legacyPartsOf(envelope) };
130
+ return { id: messageId, ...envelope, parts: legacyPartsOf(envelope), ...preparation };
117
131
  }
118
- return { id: messageId, parts: turn.parts, ...resourcesRevision > 0 ? { resources_revision: resourcesRevision } : {} };
132
+ return { id: messageId, parts: turn.parts, ...resourcesRevision > 0 ? { resources_revision: resourcesRevision } : {}, ...preparation };
119
133
  }
120
134
  var UNREACHABLE_CODES = /* @__PURE__ */ new Set([
121
135
  "ECONNREFUSED",
@@ -155,6 +169,7 @@ function classifyPodSendStatus(status, detail) {
155
169
  return { kind: "rejected", status, detail };
156
170
  }
157
171
  var PERSONAL_CONTEXT_PODS = /* @__PURE__ */ new Set();
172
+ var WORKSPACE_IDENTITY_PODS = /* @__PURE__ */ new Set();
158
173
  async function sendPodMessage(baseUrl, body, options = {}) {
159
174
  const headers = {
160
175
  "content-type": "application/json",
@@ -168,6 +183,11 @@ async function sendPodMessage(baseUrl, body, options = {}) {
168
183
  if (health.personalContext) PERSONAL_CONTEXT_PODS.add(baseUrl);
169
184
  else if (health.ok) body = personalContextForPod(body, false);
170
185
  }
186
+ if (body.workspace_identity && !WORKSPACE_IDENTITY_PODS.has(baseUrl)) {
187
+ const health = await getPodHealth(baseUrl, options);
188
+ if (health.workspaceIdentity) WORKSPACE_IDENTITY_PODS.add(baseUrl);
189
+ else if (health.ok) body = workspaceIdentityForPod(body, false);
190
+ }
171
191
  const user = body.events?.find((event) => event.type === "user.message");
172
192
  const mode = user?.type === "user.message" ? user.interaction_mode : body.interaction_mode;
173
193
  if (mode) {
@@ -214,7 +234,8 @@ async function getPodHealth(baseUrl, options = {}) {
214
234
  state: typeof body.state === "string" ? body.state : void 0,
215
235
  openMessageId: typeof open === "string" && open ? open : null,
216
236
  interactionModes: Array.isArray(body.interaction_modes) ? body.interaction_modes.filter((mode) => mode === "plan" || mode === "build") : void 0,
217
- personalContext: body.personal_context === true
237
+ personalContext: body.personal_context === true,
238
+ workspaceIdentity: body.workspace_identity === true
218
239
  };
219
240
  } catch {
220
241
  return { ok: false, openMessageId: null };
@@ -317,5 +338,6 @@ export {
317
338
  postSessionEvents,
318
339
  sendPodMessage,
319
340
  streamAgentEvents,
320
- textFromParts
341
+ textFromParts,
342
+ workspaceIdentityForPod
321
343
  };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  USER_AGENT,
3
3
  configPath
4
- } from "./chunk-BHW2NAXP.js";
4
+ } from "./chunk-HB7SPKQ5.js";
5
5
  import {
6
6
  TRACE_CONTENT_SCOPES,
7
7
  redactTraceText
8
- } from "./chunk-DC3R6BV2.js";
8
+ } from "./chunk-GHTAIKQ6.js";
9
9
  import "./chunk-MLKGABMK.js";
10
10
 
11
11
  // src/trace.ts
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  ApiError
3
- } from "./chunk-ICSGMEG5.js";
3
+ } from "./chunk-WTFBVTMI.js";
4
4
  import {
5
5
  USER_AGENT,
6
6
  apiBase,
7
7
  apiToken
8
- } from "./chunk-BHW2NAXP.js";
8
+ } from "./chunk-HB7SPKQ5.js";
9
9
  import {
10
10
  SessionSourceCollector,
11
11
  publicRemote,
12
12
  redactTraceText
13
- } from "./chunk-DC3R6BV2.js";
13
+ } from "./chunk-GHTAIKQ6.js";
14
14
  import "./chunk-MLKGABMK.js";
15
15
 
16
16
  // src/trace-library.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentsky/sky",
3
- "version": "2.20.0",
3
+ "version": "2.20.2",
4
4
  "description": "sky \u2014 the AgentSky developer CLI: launch and talk to long-lived agents from your terminal.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "scripts": {
17
17
  "dev": "tsx src/index.ts",
18
- "build": "tsup src/index.ts src/products.ts --format esm --target node20 --clean",
18
+ "build": "tsup src/index.ts --format esm --target node20 --clean",
19
19
  "test": "vitest run",
20
20
  "typecheck": "tsc --noEmit"
21
21
  },
@@ -45,15 +45,9 @@
45
45
  "ignoreDeprecations": "6.0"
46
46
  },
47
47
  "resolve": [
48
- "@agent/spec",
49
- "@agent/spec/products"
48
+ "@agent/spec"
50
49
  ]
51
50
  }
52
51
  },
53
- "exports": {
54
- "./products": {
55
- "types": "./dist/products.d.ts",
56
- "import": "./dist/products.js"
57
- }
58
- }
52
+ "exports": {}
59
53
  }