@pstdio/sdk 0.36.1 → 0.37.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.
@@ -3087,6 +3087,9 @@ function handlePipeResult(left, next, ctx) {
3087
3087
  }
3088
3088
  return next._zod.run({ value: left.value, issues: left.issues }, ctx);
3089
3089
  }
3090
+ var $ZodPreprocess = /* @__PURE__ */ $constructor("$ZodPreprocess", (inst, def) => {
3091
+ $ZodPipe.init(inst, def);
3092
+ });
3090
3093
  var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
3091
3094
  $ZodType.init(inst, def);
3092
3095
  defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
@@ -6122,6 +6125,10 @@ function pipe(in_, out) {
6122
6125
  out
6123
6126
  });
6124
6127
  }
6128
+ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) => {
6129
+ ZodPipe.init(inst, def);
6130
+ $ZodPreprocess.init(inst, def);
6131
+ });
6125
6132
  var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
6126
6133
  $ZodReadonly.init(inst, def);
6127
6134
  ZodType.init(inst, def);
@@ -6157,12 +6164,41 @@ function refine(fn, _params = {}) {
6157
6164
  function superRefine(fn, params) {
6158
6165
  return _superRefine(fn, params);
6159
6166
  }
6167
+ function _instanceof(cls, params = {}) {
6168
+ const inst = new ZodCustom({
6169
+ type: "custom",
6170
+ check: "custom",
6171
+ fn: (data) => data instanceof cls,
6172
+ abort: true,
6173
+ ...normalizeParams(params)
6174
+ });
6175
+ inst._zod.bag.Class = cls;
6176
+ inst._zod.check = (payload) => {
6177
+ if (!(payload.value instanceof cls)) {
6178
+ payload.issues.push({
6179
+ code: "invalid_type",
6180
+ expected: cls.name,
6181
+ input: payload.value,
6182
+ inst,
6183
+ path: [...inst._zod.def.path ?? []]
6184
+ });
6185
+ }
6186
+ };
6187
+ return inst;
6188
+ }
6160
6189
  function json(params) {
6161
6190
  const jsonSchema = lazy(() => {
6162
6191
  return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
6163
6192
  });
6164
6193
  return jsonSchema;
6165
6194
  }
6195
+ function preprocess(fn, schema) {
6196
+ return new ZodPreprocess({
6197
+ type: "pipe",
6198
+ in: transform(fn),
6199
+ out: schema
6200
+ });
6201
+ }
6166
6202
  // ../../node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/coerce.js
6167
6203
  var exports_coerce = {};
6168
6204
  __export(exports_coerce, {
@@ -7314,7 +7350,8 @@ var workbenchExtensionNavigationTreeRecordSchema = object({
7314
7350
  extensionId: string2(),
7315
7351
  owner: union([modeRefSchema2, pageRefSchema2]),
7316
7352
  slot: _enum(["header", "content", "footer"]),
7317
- view: viewRefSchema2
7353
+ view: viewRefSchema2,
7354
+ resourceScope: _enum(["project", "selection"]).optional()
7318
7355
  });
7319
7356
  var workbenchExtensionResourceKindRecordSchema = object({
7320
7357
  id: string2(),
@@ -7541,10 +7578,6 @@ var setProjectExtensionEnabledRequestSchema = object({
7541
7578
  var setExtensionAutomationEnabledRequestSchema = object({
7542
7579
  enabled: boolean2()
7543
7580
  });
7544
- var attemptExtensionFixResponseSchema = object({
7545
- sessionId: string2(),
7546
- title: string2()
7547
- });
7548
7581
  var upgradeProjectExtensionResponseSchema = object({
7549
7582
  changed: boolean2(),
7550
7583
  extension: projectExtensionInstanceSchema
@@ -7552,6 +7585,13 @@ var upgradeProjectExtensionResponseSchema = object({
7552
7585
  var installMarketplaceExtensionResponseSchema = object({
7553
7586
  extension: projectExtensionInstanceSchema
7554
7587
  });
7588
+ var addLocalExtensionFolderRequestSchema = object({
7589
+ name: string2().min(1),
7590
+ files: preprocess((value) => Array.isArray(value) ? value : [value], array(_instanceof(File).meta({ type: "string", format: "binary" })).min(1))
7591
+ });
7592
+ var addLocalExtensionFolderResponseSchema = object({
7593
+ extension: projectExtensionInstanceSchema
7594
+ });
7555
7595
  var setupProjectExtensionResponseSchema = object({
7556
7596
  extensionId: string2(),
7557
7597
  name: string2(),
@@ -7876,10 +7916,11 @@ var packageAsset = (path, baseUrl) => ({
7876
7916
  baseUrl
7877
7917
  });
7878
7918
  // ../pstdio-api-contracts/src/extension-kernel/types/extension.ts
7879
- var EXTENSION_API_VERSION = "1.0.0-alpha.13";
7919
+ var EXTENSION_API_VERSION = "1.0.0-alpha.14";
7880
7920
  // ../pstdio-api-contracts/src/extension-kernel/types/webview-capabilities.ts
7881
7921
  var WEBVIEW_HOST_CAPABILITY_VERSION = 1;
7882
7922
  var WEBVIEW_DECLARABLE_CAPABILITIES = [
7923
+ "clipboard.write",
7883
7924
  "commands.execute",
7884
7925
  "navigation.open",
7885
7926
  "placement.close",
@@ -7901,7 +7942,7 @@ var WEBVIEW_DECLARABLE_CAPABILITIES = [
7901
7942
  var WEBVIEW_SCOPED_DECLARABLE_CAPABILITIES = ["artifacts.read"];
7902
7943
  var ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES = ["host.dispatchKeyboardEvent"];
7903
7944
  var WEBVIEW_HOST_CAPABILITIES = [
7904
- ...WEBVIEW_DECLARABLE_CAPABILITIES,
7945
+ ...WEBVIEW_DECLARABLE_CAPABILITIES.filter((capability) => capability !== "clipboard.write"),
7905
7946
  ...WEBVIEW_SCOPED_DECLARABLE_CAPABILITIES,
7906
7947
  ...ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES
7907
7948
  ];
@@ -7969,17 +8010,7 @@ var historyTurnEvidence = (known, native, prompt, body) => {
7969
8010
  return (turn) => keys.get(turn);
7970
8011
  };
7971
8012
 
7972
- // ../pstdio-api-contracts/src/history-reconciliation.ts
7973
- class HistoryConflict extends Error {
7974
- }
7975
- var submittedPrompt = (message) => message.parts.filter((part) => part.type === "text").map((part) => part.text).join(`
7976
- `).replace(/\n\n<session-attachments>[\s\S]*<\/session-attachments>\s*$/, "").trim();
7977
- var historyValueKey = (value) => JSON.stringify(value, (_key, item) => {
7978
- if (!item || typeof item !== "object" || Array.isArray(item))
7979
- return item;
7980
- return Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b)));
7981
- });
7982
- var historyMessageKey = (message) => historyValueKey([message.role, message.parts]);
8013
+ // ../pstdio-api-contracts/src/ordered-history-merge.ts
7983
8014
  var positions = (items, key) => {
7984
8015
  const result = new Map;
7985
8016
  items.forEach((item, index) => {
@@ -7990,24 +8021,53 @@ var positions = (items, key) => {
7990
8021
  });
7991
8022
  return result;
7992
8023
  };
7993
- var mergeOrderedHistory = (known, native, key, merge, refineKey) => {
8024
+ var orderedAnchors = (anchors) => {
8025
+ const tails = [];
8026
+ const previous = [];
8027
+ anchors.forEach(([, native], index) => {
8028
+ let low = 0;
8029
+ let high = tails.length;
8030
+ while (low < high) {
8031
+ const middle = low + high >> 1;
8032
+ if (anchors[tails[middle]][1] < native)
8033
+ low = middle + 1;
8034
+ else
8035
+ high = middle;
8036
+ }
8037
+ previous[index] = low > 0 ? tails[low - 1] : -1;
8038
+ tails[low] = index;
8039
+ });
8040
+ const kept = [];
8041
+ for (let index = tails.at(-1) ?? -1;index >= 0; index = previous[index])
8042
+ kept.unshift(anchors[index]);
8043
+ return kept;
8044
+ };
8045
+ var newerThanSaved = (known, native, options) => {
8046
+ const times = options.time ? known.map(options.time).filter((value) => value !== undefined) : [];
8047
+ if (!times.length)
8048
+ return [];
8049
+ const savedUntil = Math.max(...times);
8050
+ return native.filter((item) => (options.time?.(item) ?? savedUntil) > savedUntil);
8051
+ };
8052
+ var mergeOrderedHistory = (known, native, options, trailing = true) => {
8053
+ const { key, merge, refineKey, covered } = options;
8054
+ const missing = native.filter((item) => !covered?.(item));
7994
8055
  if (!known.length)
7995
- return native;
8056
+ return missing;
7996
8057
  if (!native.length)
7997
8058
  return known;
7998
8059
  const knownPositions = positions(known, key);
7999
8060
  const nativePositions = positions(native, key);
8000
- const anchors = [];
8061
+ const found = [];
8001
8062
  for (const [value, indices] of knownPositions) {
8002
8063
  const other = nativePositions.get(value);
8003
8064
  if (indices.length === 1 && other?.length === 1)
8004
- anchors.push([indices[0], other[0]]);
8065
+ found.push([indices[0], other[0]]);
8005
8066
  }
8067
+ const anchors = orderedAnchors(found.sort((a, b) => a[0] - b[0]));
8006
8068
  if (!anchors.length) {
8007
- if (refineKey) {
8008
- const refined = mergeOrderedHistory(known, native, refineKey(known, native), merge);
8009
- return refined;
8010
- }
8069
+ if (refineKey)
8070
+ return mergeOrderedHistory(known, native, { ...options, key: refineKey(known, native), refineKey: undefined }, trailing);
8011
8071
  const paired = Math.min(known.length, native.length);
8012
8072
  if (known.slice(0, paired).every((item, index) => key(item) === key(native[index]))) {
8013
8073
  return [
@@ -8016,22 +8076,35 @@ var mergeOrderedHistory = (known, native, key, merge, refineKey) => {
8016
8076
  ...native.slice(paired)
8017
8077
  ];
8018
8078
  }
8019
- throw new HistoryConflict("ambiguous_interval");
8079
+ return trailing ? [...known, ...newerThanSaved(known, missing, options)] : known;
8020
8080
  }
8081
+ const kept = new Set(anchors.map(([, index]) => index));
8082
+ const reordered = new Set(found.filter(([, index]) => !kept.has(index)).map(([, index]) => native[index]));
8083
+ const nativeSpan = (start, end) => native.slice(start, end).filter((item) => !reordered.has(item));
8021
8084
  let left = 0;
8022
8085
  let right = 0;
8023
8086
  const result = [];
8024
8087
  for (const [a, b] of anchors) {
8025
- if (b < right)
8026
- throw new HistoryConflict("conflicting_order");
8027
- result.push(...mergeOrderedHistory(known.slice(left, a), native.slice(right, b), key, merge, refineKey));
8088
+ result.push(...mergeOrderedHistory(known.slice(left, a), nativeSpan(right, b), options, false));
8028
8089
  result.push(merge(known[a], native[b]));
8029
8090
  left = a + 1;
8030
8091
  right = b + 1;
8031
8092
  }
8032
- result.push(...mergeOrderedHistory(known.slice(left), native.slice(right), key, merge, refineKey));
8093
+ result.push(...mergeOrderedHistory(known.slice(left), nativeSpan(right), options, trailing));
8033
8094
  return result;
8034
8095
  };
8096
+
8097
+ // ../pstdio-api-contracts/src/history-reconciliation.ts
8098
+ class HistoryConflict extends Error {
8099
+ }
8100
+ var submittedPrompt = (message) => message.parts.filter((part) => part.type === "text").map((part) => part.text).join(`
8101
+ `).replace(/\n\n<session-attachments>[\s\S]*<\/session-attachments>\s*$/, "").trim();
8102
+ var historyValueKey = (value) => JSON.stringify(value, (_key, item) => {
8103
+ if (!item || typeof item !== "object" || Array.isArray(item))
8104
+ return item;
8105
+ return Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b)));
8106
+ });
8107
+ var historyMessageKey = (message) => historyValueKey([message.role, message.parts]);
8035
8108
  var splitHistoryTurns = (messages) => {
8036
8109
  const turns = [];
8037
8110
  for (const message of messages) {
@@ -8069,7 +8142,14 @@ var reconcileMessageHistory = (input, projection = {}) => {
8069
8142
  const mergeTurn = (known, native) => {
8070
8143
  const startsWithUser = known[0]?.role === "user" && native[0]?.role === "user";
8071
8144
  const body = (turn) => combineTextRuns(turn.slice(startsWithUser ? 1 : 0).filter((message) => !generated(message)));
8072
- const messages = mergeOrderedHistory(body(known), body(native), key, merge);
8145
+ const shown = known.flatMap((message) => message.parts.flatMap((part) => part.type === "text" ? [part.text] : []));
8146
+ const saved = shown.join("");
8147
+ const messages = mergeOrderedHistory(body(known), body(native), {
8148
+ key,
8149
+ merge,
8150
+ time: (message) => message.createdAt,
8151
+ covered: (message) => message.parts.length > 0 && message.parts.every((part) => part.type === "text" && saved.includes(part.text))
8152
+ });
8073
8153
  const metadata = [...native.filter(generated)];
8074
8154
  const counts = new Map;
8075
8155
  metadata.forEach((message) => {
@@ -8087,7 +8167,12 @@ var reconcileMessageHistory = (input, projection = {}) => {
8087
8167
  };
8088
8168
  try {
8089
8169
  const prompt = (turn) => turn[0]?.role === "user" ? `user:${submittedPrompt(turn[0])}` : "prefix";
8090
- const turns = mergeOrderedHistory(splitHistoryTurns(input.knownMessages), splitHistoryTurns(input.nativeMessages), prompt, mergeTurn, (known, native) => historyTurnEvidence(known, native, prompt, (turn) => combineTextRuns(turn.slice(1).filter((message) => !generated(message))).map(key)));
8170
+ const turns = mergeOrderedHistory(splitHistoryTurns(input.knownMessages), splitHistoryTurns(input.nativeMessages), {
8171
+ key: prompt,
8172
+ merge: mergeTurn,
8173
+ refineKey: (known, native) => historyTurnEvidence(known, native, prompt, (turn) => combineTextRuns(turn.slice(1).filter((message) => !generated(message))).map(key)),
8174
+ time: (turn) => turn[0]?.createdAt
8175
+ });
8091
8176
  const messages = turns.flat().map((message, index) => message.index === undefined ? message : { ...message, index });
8092
8177
  return { kind: "recovered", messages };
8093
8178
  } catch (error) {
@@ -8352,10 +8437,6 @@ var followUpDecisionSchema = union([
8352
8437
  var followUpResponseSchema = sessionSchema.extend({
8353
8438
  follow_up: followUpDecisionSchema
8354
8439
  });
8355
- var sessionHistoryIssueSchema = object({
8356
- code: _enum(["reconciliation_conflict", "checkpoint_unreadable", "native_unavailable"]),
8357
- category: string2()
8358
- });
8359
8440
  var sessionQueuedMessagesResponseSchema = object({ messages: array(sessionMessageSchema) });
8360
8441
  var sessionConversationSourcesSchema = object({
8361
8442
  checkpoint: array(sessionMessageSchema).nullable(),
@@ -8364,7 +8445,6 @@ var sessionConversationSourcesSchema = object({
8364
8445
  nativeError: string2().nullable()
8365
8446
  });
8366
8447
  var sessionConversationResponseSchema = object({
8367
- historyIssue: sessionHistoryIssueSchema.optional(),
8368
8448
  session: sessionSchema,
8369
8449
  messages: array(sessionMessageSchema)
8370
8450
  });
@@ -1,4 +1,4 @@
1
- import { Fd as AgentModel, Id as AgentSkillsLayout, Ja as SkillFile, Ld as harnessLocalId, Nd as AgentAvailabilityType, Pd as AgentInfo, Ya as SkillWithContent, ao as Session, b as FileRecord, fo as SessionStatus, m as Settings, qa as Skill, v as Project } from "./index-CJUDgZmO.js";
2
- import { n as WorkspaceListItem, t as Workspace } from "./index-uADamSuQ.js";
1
+ import { Fd as AgentSkillsLayout, Id as harnessLocalId, Ja as SkillFile, Md as AgentAvailabilityType, Nd as AgentInfo, Pd as AgentModel, Ya as SkillWithContent, ao as Session, b as FileRecord, do as SessionStatus, m as Settings, qa as Skill, v as Project } from "./index-CnOTGr_I.js";
2
+ import { n as WorkspaceListItem, t as Workspace } from "./index-B0-v8E14.js";
3
3
  export { type AgentAvailabilityType, type AgentInfo, type AgentModel, type AgentSkillsLayout, type FileRecord, type Project, type Session, type SessionStatus, type Settings, type Skill, type SkillFile, type SkillWithContent, type Workspace, type WorkspaceListItem, harnessLocalId };
4
4
  export {};
@@ -0,0 +1,2 @@
1
+ import "./index-CnOTGr_I.js";
2
+ export {};
@@ -0,0 +1,2 @@
1
+ import "./index-CnOTGr_I.js";
2
+ export {};
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Gu as ExtensionResourcesApi, Ir as ArtifactMount, Lr as CommandContext, oi as ExtensionStorageApi } from "./index-CJUDgZmO.js";
1
+ import { Ir as ArtifactMount, Lr as CommandContext, Wu as ExtensionResourcesApi, oi as ExtensionStorageApi } from "./index-CnOTGr_I.js";
2
2
  //#region src/testing/command-context.d.ts
3
3
  type CommandContextOverrides = { [K in keyof CommandContext]?: Partial<CommandContext[K]>; };
4
4
  interface CommandContextInput<TParams extends Record<string, unknown>> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pstdio/sdk",
3
- "version": "0.36.1",
3
+ "version": "0.37.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/pufflyai/prompt-studio"
@@ -1,2 +0,0 @@
1
- import "./index-CJUDgZmO.js";
2
- export {};
@@ -1,2 +0,0 @@
1
- import "./index-CJUDgZmO.js";
2
- export {};