@pstdio/sdk 0.45.0-nightly.20261021030241 → 0.45.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/prompts.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- //#region src/prompts/render-prompt.d.ts
2
1
  export declare const renderPrompt: (template: string, data: Record<string, unknown>) => string;
3
- //#endregion
4
2
  export {};
@@ -1,3 +1,3 @@
1
- import { $s as NotificationPriority, Am as AssetTransfer, Bs as SkillFile, Cf as SessionDetails, Ef as SessionFollowUpResponse, Fm as AgentSkillsLayout, Gs as ListNotificationsQuery, Gt as WorkspaceListItem, Hs as SkillWithContentDetails, Js as NotificationAction, Ks as ListNotificationsResponse, Lm as harnessLocalId, Mm as AgentDetails, Nm as AgentInfo, Of as SessionStatus, Pm as AgentModel, Qs as NotificationOrigin, Rm as ActivityEntry, Rs as Skill, S as ProjectUpdateRequest, Sc as PageQuery, Sf as SessionCreateResponse, T as FileRecord, Tf as SessionFollowUpRequest, Vs as SkillWithContent, Ws as CreateNotificationInput, Wt as Workspace, Xs as NotificationFinalStatus, Ys as NotificationActorType, Zs as NotificationKind, _f as SessionAttachmentDetails, b as ProjectCreateRequest, ec as NotificationStatus, hf as Session, jm as AgentAvailabilityType, km as AssetReference, nc as UpdateNotificationInput, p as Settings, qs as Notification, s as WorkspaceEntryMoveInput, tc as SetNotificationStatusInput, v as InitialWorkspaceRequest, wf as SessionFollowUpDecision, x as ProjectDetails, xc as Page, xf as SessionCreateRequest, y as Project, zm as ActivityPage, zs as SkillDetails } from "./index-LeVI9OKi.js";
1
+ import { Bf as SessionCreateRequest, Gf as SessionFollowUpResponse, Gt as WorkspaceListItem, Hf as SessionDetails, If as SessionAttachmentDetails, Js as Skill, Nc as Page, Pc as PageQuery, Pf as Session, Qs as SkillWithContentDetails, S as ProjectUpdateRequest, T as FileRecord, Uf as SessionFollowUpDecision, Vf as SessionCreateResponse, Wf as SessionFollowUpRequest, Wt as Workspace, Xs as SkillFile, Ys as SkillDetails, Zs as SkillWithContent, ac as NotificationActorType, ah as AgentDetails, b as ProjectCreateRequest, cc as NotificationOrigin, ch as AgentSkillsLayout, dc as SetNotificationStatusInput, dh as ActivityEntry, ec as CreateNotificationInput, fc as UpdateNotificationInput, fh as ActivityPage, ic as NotificationAction, ih as AgentAvailabilityType, lc as NotificationPriority, nc as ListNotificationsResponse, nh as AssetReference, oc as NotificationFinalStatus, oh as AgentInfo, p as Settings, qf as SessionStatus, rc as Notification, rh as AssetTransfer, s as WorkspaceEntryMoveInput, sc as NotificationKind, sh as AgentModel, tc as ListNotificationsQuery, uc as NotificationStatus, uh as harnessLocalId, v as InitialWorkspaceRequest, x as ProjectDetails, y as Project } from "./index-j28tAAxd.js";
2
2
  export { type ActivityEntry, type ActivityPage, type AgentAvailabilityType, type AgentDetails, type AgentInfo, type AgentModel, type AgentSkillsLayout, type AssetReference, type AssetTransfer, type CreateNotificationInput, type FileRecord, type InitialWorkspaceRequest, type ListNotificationsQuery, type ListNotificationsResponse, type Notification, type NotificationAction, type NotificationActorType, type NotificationFinalStatus, type NotificationKind, type NotificationOrigin, type NotificationPriority, type NotificationStatus, type Page, type PageQuery, type Project, type ProjectCreateRequest, type ProjectDetails, type ProjectUpdateRequest, type Session, type SessionAttachmentDetails, type SessionCreateRequest, type SessionCreateResponse, type SessionDetails, type SessionFollowUpDecision, type SessionFollowUpRequest, type SessionFollowUpResponse, type SessionStatus, type SetNotificationStatusInput, type Settings, type Skill, type SkillDetails, type SkillFile, type SkillWithContent, type SkillWithContentDetails, type UpdateNotificationInput, type Workspace, type WorkspaceEntryMoveInput, type WorkspaceListItem, harnessLocalId };
3
3
  export {};
@@ -0,0 +1,2 @@
1
+ import "./index-j28tAAxd.js";
2
+ export {};
@@ -0,0 +1,2 @@
1
+ import "./index-j28tAAxd.js";
2
+ export {};
@@ -954,6 +954,19 @@ var createCommandContextDefaults = (input) => {
954
954
  automation: { enqueue: unavailable, get: async () => {
955
955
  return;
956
956
  }, list: async () => [], cancel: unavailable },
957
+ account: {
958
+ status: async () => ({ login: null, cloudProjects: [], cloudProjectsLoaded: true }),
959
+ login: unavailable,
960
+ loginStatus: unavailable,
961
+ cancelLogin: unavailable,
962
+ logout: unavailable,
963
+ devices: unavailable,
964
+ renameDevice: unavailable,
965
+ removeDevice: unavailable,
966
+ projectSyncStatus: async () => ({ state: "local", offlineReady: false }),
967
+ syncProject: unavailable,
968
+ stopProjectSync: unavailable
969
+ },
957
970
  process: { run: unavailable, runOrThrow: unavailable, spawnDetached: unavailable },
958
971
  net: { findFreePort: unavailable },
959
972
  connections: { request: unavailable, stream: unavailable },
@@ -7765,18 +7778,35 @@ var createStoragePositions = (deviceId) => {
7765
7778
  };
7766
7779
  };
7767
7780
  // src/testing/memory-resources.ts
7768
- var createMemoryResources = (prefixes, sequences = new Map, links = createMemoryResourceLinks({ projectId: "proj-1", extensionId: "test.extension", edges: new Map })) => ({
7769
- ...links,
7770
- allocate: async ({ kind, idPrefix }) => {
7771
- const prefix = prefixes[kind];
7772
- if (!prefix)
7773
- throw new Error(`Undeclared resource kind: ${kind}`);
7774
- const id = createStorageId(idPrefix);
7775
- const next = (sequences.get(kind) ?? 0) + 1;
7776
- sequences.set(kind, next);
7777
- return { id, shorthand: `${prefix}-${next}` };
7778
- }
7779
- });
7781
+ var identitiesBySequence = new WeakMap;
7782
+ var createMemoryResources = (prefixes, sequences = new Map, links = createMemoryResourceLinks({ projectId: "proj-1", extensionId: "test.extension", edges: new Map }), owner = { projectId: "proj-1", extensionId: "test.extension" }) => {
7783
+ const scope = JSON.stringify([owner.projectId, owner.extensionId]);
7784
+ let identities = identitiesBySequence.get(sequences);
7785
+ if (!identities) {
7786
+ identities = new Map;
7787
+ identitiesBySequence.set(sequences, identities);
7788
+ }
7789
+ const resources = identities;
7790
+ return {
7791
+ ...links,
7792
+ allocate: async ({ kind, idPrefix }) => {
7793
+ const prefix = prefixes[kind];
7794
+ if (!prefix)
7795
+ throw new Error(`Undeclared resource kind: ${kind}`);
7796
+ const id = createStorageId(idPrefix);
7797
+ const next = (sequences.get(kind) ?? 0) + 1;
7798
+ sequences.set(kind, next);
7799
+ const identity = { id, kind, shorthand: `${prefix}-${next}`, aliases: [] };
7800
+ resources.set(identity.id, { identity, scope });
7801
+ return { id: identity.id, shorthand: identity.shorthand };
7802
+ },
7803
+ identity: async ({ kind, id }) => {
7804
+ const found = resources.get(id);
7805
+ return found?.scope === scope && found.identity.kind === kind ? structuredClone(found.identity) : null;
7806
+ },
7807
+ findByShorthand: async ({ kind, shorthand }) => [...resources.values()].filter((entry) => entry.scope === scope).map((entry) => entry.identity).filter((resource) => resource.kind === kind && (resource.shorthand === shorthand || resource.aliases.includes(shorthand))).sort((a, b) => Number(b.shorthand === shorthand) - Number(a.shorthand === shorthand)).map((resource) => structuredClone(resource))
7808
+ };
7809
+ };
7780
7810
 
7781
7811
  // src/testing/command-context.ts
7782
7812
  var linksByStorage = new WeakMap;
@@ -7794,7 +7824,7 @@ var makeCommandContext = (input) => {
7794
7824
  edges = new Map;
7795
7825
  linksByStorage.set(storage, edges);
7796
7826
  }
7797
- const resources = createMemoryResources(input.resourcePrefixes ?? {}, sequences, createMemoryResourceLinks({ projectId, extensionId: overrides?.extensionId ?? "test.extension", edges }));
7827
+ const resources = createMemoryResources(input.resourcePrefixes ?? {}, sequences, createMemoryResourceLinks({ projectId, extensionId: overrides?.extensionId ?? "test.extension", edges }), { projectId, extensionId: overrides?.extensionId ?? "test.extension" });
7798
7828
  const base = createCommandContextDefaults({ projectId, storage, resources });
7799
7829
  const context = {
7800
7830
  ...base,
@@ -7822,6 +7852,7 @@ var makeCommandContext = (input) => {
7822
7852
  connections: { ...base.connections, ...overrides?.connections },
7823
7853
  logger: { ...base.logger, ...overrides?.logger },
7824
7854
  settings: { ...base.settings, ...overrides?.settings },
7855
+ account: { ...base.account, ...overrides?.account },
7825
7856
  stream: { ...base.stream, ...overrides?.stream },
7826
7857
  invocation: { ...base.invocation, ...overrides?.invocation }
7827
7858
  };
@@ -13870,6 +13901,9 @@ var documentHistory = (document2) => {
13870
13901
  ]));
13871
13902
  return { fields, sequences };
13872
13903
  };
13904
+ // ../pstdio-sync/src/document-values.ts
13905
+ var import_fast_diff = __toESM(require_diff(), 1);
13906
+
13873
13907
  // ../pstdio-sync/src/document-author.ts
13874
13908
  var documentAuthorId = (key) => {
13875
13909
  let first = 2166136261;
@@ -13902,7 +13936,6 @@ var migrationAuthor = (document2, seed, history) => {
13902
13936
  };
13903
13937
 
13904
13938
  // ../pstdio-sync/src/document-values.ts
13905
- var import_fast_diff = __toESM(require_diff(), 1);
13906
13939
  var readValue = (value, document2) => {
13907
13940
  if (value === null || typeof value !== "object")
13908
13941
  return value ?? null;
@@ -14012,6 +14045,80 @@ var seedText = (document2, name, value) => {
14012
14045
  }
14013
14046
  };
14014
14047
 
14048
+ // ../pstdio-sync/src/document-replacements.ts
14049
+ var snapshotDocumentRecords = (document2) => {
14050
+ const records = new Map;
14051
+ for (const [id, name] of document2.getMap("records")) {
14052
+ const record = document2.getMap(name);
14053
+ const channels = {};
14054
+ if (record.has("value"))
14055
+ channels.value = readValue(record.get("value"), document2);
14056
+ if (record.has("asset"))
14057
+ channels.asset = structuredClone(record.get("asset"));
14058
+ if (record.has("shared"))
14059
+ channels.shared = { kind: record.get("sharedKind"), value: readValue(record.get("shared"), document2) };
14060
+ records.set(id, channels);
14061
+ }
14062
+ return records;
14063
+ };
14064
+ var equal = (left, right) => left === right || left !== undefined && right !== undefined && canonicalJson(left) === canonicalJson(right);
14065
+ var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
14066
+ var concurrent = (before, left, right) => !equal(left, right) && !equal(before, left) && !equal(before, right);
14067
+ var findDocumentReplacements = (base, first, second, merged) => {
14068
+ const replacements = [];
14069
+ const report = (recordId, path, before, left, right, kept) => {
14070
+ if (!concurrent(before, left, right))
14071
+ return;
14072
+ if (equal(kept, left))
14073
+ replacements.push({ recordId, path, kept, replaced: right });
14074
+ else if (equal(kept, right))
14075
+ replacements.push({ recordId, path, kept, replaced: left });
14076
+ };
14077
+ const visit = (recordId, path, before, left, right, kept) => {
14078
+ if (!concurrent(before, left, right))
14079
+ return;
14080
+ const leftObject = object2(left);
14081
+ const rightObject = object2(right);
14082
+ const keptObject = object2(kept);
14083
+ if (leftObject && rightObject && keptObject) {
14084
+ const original = object2(before);
14085
+ for (const key of [...new Set([...Object.keys(leftObject), ...Object.keys(rightObject)])].sort())
14086
+ visit(recordId, [...path, key], original?.[key], leftObject[key], rightObject[key], keptObject[key]);
14087
+ return;
14088
+ }
14089
+ if (Array.isArray(left) && Array.isArray(right) && Array.isArray(kept)) {
14090
+ const original = Array.isArray(before) ? before : [];
14091
+ const indexed = (values) => new Map(listKeys(values).map((key, index) => [key, values[index]]));
14092
+ const originalItems = indexed(original);
14093
+ const leftItems = indexed(left);
14094
+ const rightItems = indexed(right);
14095
+ const keptItems = indexed(kept);
14096
+ const keptKeys = listKeys(kept);
14097
+ const removedKeys = [...new Set([...listKeys(left), ...listKeys(right)])].filter((key) => !keptItems.has(key)).sort();
14098
+ const keys = [...keptKeys, ...removedKeys];
14099
+ for (const [index, key] of keys.entries())
14100
+ visit(recordId, [...path, index], originalItems.get(key), leftItems.get(key), rightItems.get(key), keptItems.get(key));
14101
+ return;
14102
+ }
14103
+ report(recordId, path, before, left, right, kept);
14104
+ };
14105
+ for (const id of [...new Set([...first.keys(), ...second.keys()])].sort()) {
14106
+ if (base.has(id) && !merged.has(id)) {
14107
+ const survivor = first.get(id) ?? second.get(id);
14108
+ for (const key of ["value", "asset", "shared"]) {
14109
+ const replaced = survivor?.[key];
14110
+ if (replaced !== undefined && !equal(base.get(id)?.[key], replaced))
14111
+ replacements.push({ recordId: id, path: [key], kept: undefined, replaced });
14112
+ }
14113
+ continue;
14114
+ }
14115
+ for (const key of ["value", "asset", "shared"]) {
14116
+ const inspect = key === "asset" ? report : visit;
14117
+ inspect(id, [key], base.get(id)?.[key], first.get(id)?.[key], second.get(id)?.[key], merged.get(id)?.[key]);
14118
+ }
14119
+ }
14120
+ return replacements;
14121
+ };
14015
14122
  // ../pstdio-sync/src/document-edits.ts
14016
14123
  var applyShared = (document2, record, name, shared, author) => {
14017
14124
  const kind = shared.kind.split(".")[0];
@@ -14438,6 +14545,9 @@ var createMemoryRecordOwner = (assets, seed = {}, identity = {}) => {
14438
14545
  extensionId: owner.extensionId,
14439
14546
  dataVersion: storage.dataVersion,
14440
14547
  setDataVersion: storage.setDataVersion,
14548
+ exportUpdate: storage.exportUpdate,
14549
+ applyUpdate: storage.applyUpdate,
14550
+ snapshot: () => store.transaction(owner, async ({ document: document2 }) => snapshotDocumentRecords(document2)),
14441
14551
  duringMigration: async (key, run) => {
14442
14552
  await initialized;
14443
14553
  return baseStore.duringMigration(key, run);
@@ -14450,7 +14560,8 @@ var createMemoryRecordOwner = (assets, seed = {}, identity = {}) => {
14450
14560
  };
14451
14561
 
14452
14562
  // src/testing/memory-storage.ts
14453
- var createMemoryStorage = (options = {}) => {
14563
+ var createMemoryStorage = (options = {}) => createMemoryStorageDevice(options).storage;
14564
+ var createMemoryStorageDevice = (options = {}) => {
14454
14565
  const assets = createMemoryAssets();
14455
14566
  const owner = createMemoryRecordOwner(assets, options, {
14456
14567
  workbenchId: options.workbenchId ?? crypto.randomUUID(),
@@ -14588,13 +14699,47 @@ var createMemoryStorage = (options = {}) => {
14588
14699
  };
14589
14700
  return api;
14590
14701
  };
14591
- return scopedApi("project", owner.workbenchId);
14702
+ return {
14703
+ storage: scopedApi("project", owner.workbenchId),
14704
+ workbenchId: owner.workbenchId,
14705
+ exportUpdate: owner.exportUpdate,
14706
+ applyUpdate: owner.applyUpdate,
14707
+ snapshot: owner.snapshot
14708
+ };
14709
+ };
14710
+ // src/testing/memory-storage-devices.ts
14711
+ var createMemoryStorageDevices = async (options = {}) => {
14712
+ const first = createMemoryStorageDevice(options);
14713
+ const second = createMemoryStorageDevice({
14714
+ legacyData: options.legacyData,
14715
+ workbenchId: first.workbenchId,
14716
+ extensionId: options.extensionId
14717
+ });
14718
+ await second.applyUpdate(await first.exportUpdate());
14719
+ const devices = [first.storage, second.storage];
14720
+ let base = await first.snapshot();
14721
+ return {
14722
+ devices,
14723
+ async merge() {
14724
+ const left = await first.snapshot();
14725
+ const right = await second.snapshot();
14726
+ const firstUpdate = await first.exportUpdate();
14727
+ const secondUpdate = await second.exportUpdate();
14728
+ await first.applyUpdate(secondUpdate);
14729
+ await second.applyUpdate(firstUpdate);
14730
+ const merged = await first.snapshot();
14731
+ const replacements = findDocumentReplacements(base, left, right, merged);
14732
+ base = merged;
14733
+ return replacements;
14734
+ }
14735
+ };
14592
14736
  };
14593
14737
  export {
14594
14738
  commandParamsFor,
14595
14739
  createMemoryRepoFiles,
14596
14740
  createMemoryResources,
14597
14741
  createMemoryStorage,
14742
+ createMemoryStorageDevices,
14598
14743
  makeCommandArgs,
14599
14744
  makeCommandContext
14600
14745
  };
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { Dp as JsonValue, Tp as JsonObject, da as CommandContext, fc as ResourceAnchorQuery, gc as ResourceRef, la as ArtifactFile, lc as ResourceAnchor, rc as ExtensionResourcesApi, ss as ExtensionStorageApi } from "./index-LeVI9OKi.js";
2
- //#region src/testing/command-context.d.ts
3
- type ContextNamespace = "project" | "resources" | "views" | "navigation" | "artifacts" | "projectFiles" | "packageFiles" | "extensionFiles" | "files" | "skills" | "sessions" | "workspaces" | "commands" | "events" | "activity" | "notify" | "automation" | "process" | "net" | "connections" | "logger" | "settings" | "stream" | "invocation";
1
+ import { Dc as ResourceRef, Qp as JsonObject, Sc as ResourceAnchorQuery, _s as ExtensionStorageApi, em as JsonValue, pc as ExtensionResourcesApi, xa as CommandContext, ya as ArtifactFile, yc as ResourceAnchor } from "./index-j28tAAxd.js";
2
+ type ContextNamespace = "project" | "resources" | "views" | "navigation" | "artifacts" | "projectFiles" | "packageFiles" | "extensionFiles" | "files" | "skills" | "sessions" | "workspaces" | "commands" | "events" | "activity" | "notify" | "automation" | "process" | "net" | "connections" | "logger" | "settings" | "account" | "stream" | "invocation";
4
3
  type CommandContextOverrides = Partial<Omit<CommandContext, ContextNamespace>> & { [K in ContextNamespace]?: Partial<CommandContext[K]>; };
5
4
  interface CommandContextInput<TParams extends Record<string, unknown>> {
6
5
  storage: ExtensionStorageApi;
@@ -12,8 +11,6 @@ interface CommandContextInput<TParams extends Record<string, unknown>> {
12
11
  export declare const makeCommandContext: <TParams extends Record<string, unknown>>(input: CommandContextInput<TParams>) => CommandContext<Record<string, unknown>, JsonValue>;
13
12
  export declare const commandParamsFor: <TParams extends Record<string, unknown>>(context: CommandContext) => TParams;
14
13
  export declare const makeCommandArgs: <TParams extends Record<string, unknown>>(input: CommandContextInput<TParams>) => readonly [CommandContext<Record<string, unknown>, JsonValue>, TParams];
15
- //#endregion
16
- //#region src/testing/memory-repo-files.d.ts
17
14
  export declare const createMemoryRepoFiles: () => {
18
15
  exists(path: string): Promise<boolean>;
19
16
  readText(path: string): Promise<string>;
@@ -39,8 +36,6 @@ export declare const createMemoryRepoFiles: () => {
39
36
  readonly [Symbol.toStringTag]: string;
40
37
  };
41
38
  };
42
- //#endregion
43
- //#region src/testing/memory-resources.d.ts
44
39
  export declare const createMemoryResources: (prefixes: Record<string, string>, sequences?: Map<string, number>, links?: {
45
40
  addAnchors: (resource: ResourceRef, anchors: ResourceAnchor[]) => Promise<void>;
46
41
  removeAnchors: (resource: ResourceRef, refs: ResourceRef[]) => Promise<void>;
@@ -65,15 +60,14 @@ export declare const createMemoryResources: (prefixes: Record<string, string>, s
65
60
  }[];
66
61
  nextCursor: string | null;
67
62
  }>;
63
+ }, owner?: {
64
+ projectId: string;
65
+ extensionId: string;
68
66
  }) => ExtensionResourcesApi;
69
- //#endregion
70
- //#region src/testing/memory-record-owner.d.ts
71
67
  interface MemoryStorageSeed {
72
68
  kv?: Record<string, unknown>;
73
69
  collections?: Record<string, Record<string, unknown>>;
74
70
  }
75
- //#endregion
76
- //#region src/testing/memory-storage.d.ts
77
71
  interface MemoryStorageOptions extends MemoryStorageSeed {
78
72
  /** Reuse these owner IDs to simulate the same extension and workbench on two devices. */
79
73
  workbenchId?: string;
@@ -85,6 +79,19 @@ interface MemoryStorageOptions extends MemoryStorageSeed {
85
79
  }>;
86
80
  }
87
81
  export declare const createMemoryStorage: (options?: MemoryStorageOptions) => ExtensionStorageApi;
88
- //#endregion
89
- export type { CommandContextInput, CommandContextOverrides, MemoryStorageSeed };
82
+ interface MemoryStorageReplacement {
83
+ recordId: string;
84
+ /** Starts with value, asset or shared. List positions follow the merged list, then removed items. */
85
+ path: (string | number)[];
86
+ /** Undefined means the value was removed. */
87
+ kept: JsonValue | undefined;
88
+ /** Undefined means a concurrent removal was replaced. */
89
+ replaced: JsonValue | undefined;
90
+ }
91
+ /** Two offline devices for one extension. Finish writes before calling merge. */
92
+ export declare const createMemoryStorageDevices: (options?: MemoryStorageOptions) => Promise<{
93
+ devices: [ExtensionStorageApi, ExtensionStorageApi];
94
+ merge(): Promise<MemoryStorageReplacement[]>;
95
+ }>;
96
+ export type { CommandContextInput, CommandContextOverrides, MemoryStorageOptions, MemoryStorageReplacement, MemoryStorageSeed };
90
97
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pstdio/sdk",
3
- "version": "0.45.0-nightly.20261021030241",
3
+ "version": "0.45.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/pufflyai/prompt-studio"
@@ -1,2 +0,0 @@
1
- import "./index-LeVI9OKi.js";
2
- export {};
@@ -1,2 +0,0 @@
1
- import "./index-LeVI9OKi.js";
2
- export {};