@workflow-code/cli 0.2.4-20261012006.codex-studio-integration → 0.2.4-20261013001.codex-studio-integration

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/index.js CHANGED
@@ -24,7 +24,7 @@ async function main(argv = process.argv.slice(2)) {
24
24
  const prepared = prepareCliInvocation(argv);
25
25
  argv = prepared.argv;
26
26
  if (argv[0] === "web") {
27
- const webCli = await import("./web-FDREEISF.js");
27
+ const webCli = await import("./web-JXC3WIJK.js");
28
28
  return webCli.main(argv.slice(1));
29
29
  }
30
30
  if (argv[0] === "workspace") {
@@ -80,6 +80,22 @@ function isWorkflowProjectDataStorageLocationAllowed(projectInfo, location) {
80
80
  const mode = projectInfo.dataStorage?.mode;
81
81
  return mode === "both" || mode === location;
82
82
  }
83
+ function resolveWorkflowProjectName(defaultName, projectInfo, locale) {
84
+ const fallback = defaultName.trim();
85
+ const localizedNames = projectInfo.localizedNames;
86
+ const normalizedLocale = locale?.trim().toLowerCase() ?? "";
87
+ const exact = Object.entries(localizedNames).find(([key]) => key.toLowerCase() === normalizedLocale)?.[1];
88
+ if (exact) return exact;
89
+ if (normalizedLocale.startsWith("zh")) {
90
+ const chinese = Object.entries(localizedNames).find(([key]) => key.toLowerCase() === "zh-cn")?.[1];
91
+ if (chinese) return chinese;
92
+ }
93
+ if (normalizedLocale.startsWith("en")) {
94
+ const english = Object.entries(localizedNames).find(([key]) => key.toLowerCase() === "en")?.[1];
95
+ if (english) return english;
96
+ }
97
+ return fallback;
98
+ }
83
99
  function normalizeLocalizedNames(value) {
84
100
  if (value === void 0) return {};
85
101
  if (!isRecord(value)) {
@@ -518,7 +534,6 @@ function isRecord2(value) {
518
534
  }
519
535
 
520
536
  // src/web/kanban-data.ts
521
- var readKanbanProjectInfo = readWorkflowProjectInfo;
522
537
  var webProjectDataDirectory = (storageDir, projectDir) => path.join(storageDir, createHash("sha256").update(projectDir).digest("hex").slice(0, 24));
523
538
  async function localKanbanRelatedProjects(project) {
524
539
  const info = readWorkflowProjectInfo(JSON.parse(await readFile(path.join(project.folderPath, "package.json"), "utf8")));
@@ -607,7 +622,8 @@ async function runKanbanDataCall(core, project, storageDir, value) {
607
622
  }
608
623
  export {
609
624
  localKanbanRelatedProjects,
610
- readKanbanProjectInfo,
625
+ readWorkflowProjectInfo,
626
+ resolveWorkflowProjectName,
611
627
  runKanbanDataCall,
612
628
  webProjectDataDirectory
613
629
  };
@@ -1072,23 +1072,89 @@ main {
1072
1072
  margin-top: 12px;
1073
1073
  }
1074
1074
  .resource-card {
1075
- display: flex;
1076
- align-items: center;
1077
- gap: 8px;
1075
+ display: block;
1076
+ width: 100%;
1078
1077
  min-width: 0;
1079
- max-width: 100%;
1080
- min-height: 36px;
1081
- padding: 6px 10px;
1078
+ margin: 8px 0;
1082
1079
  border: 1px solid var(--border);
1083
1080
  border-radius: 6px;
1084
1081
  background: var(--vscode-editor-background);
1082
+ overflow: hidden;
1083
+ container-type: inline-size;
1084
+ }
1085
+ .resource-card-row {
1086
+ display: flex;
1087
+ align-items: center;
1088
+ gap: 4px;
1089
+ min-height: 44px;
1090
+ padding: 4px 8px;
1091
+ }
1092
+ .resource-target {
1093
+ display: flex;
1094
+ align-items: center;
1095
+ gap: 10px;
1096
+ flex: 1;
1097
+ min-width: 0;
1098
+ min-height: 36px;
1099
+ padding: 6px 4px;
1100
+ border: 0;
1101
+ background: transparent;
1085
1102
  text-align: left;
1086
1103
  }
1087
- .resource-card > span:not(.codicon) {
1104
+ .resource-target > .codicon {
1105
+ flex: none;
1106
+ color: var(--muted);
1107
+ }
1108
+ .resource-title {
1088
1109
  min-width: 0;
1089
- overflow: hidden;
1090
- text-overflow: ellipsis;
1091
- white-space: nowrap;
1110
+ white-space: normal;
1111
+ overflow-wrap: anywhere;
1112
+ line-height: 1.5;
1113
+ }
1114
+ .resource-card-row > .icon-button {
1115
+ flex: none;
1116
+ width: 28px;
1117
+ height: 28px;
1118
+ }
1119
+ @container (max-width: 280px) {
1120
+ .resource-card-row {
1121
+ flex-wrap: wrap;
1122
+ }
1123
+ .resource-target {
1124
+ flex-basis: 100%;
1125
+ }
1126
+ }
1127
+ .resource-inline {
1128
+ height: 360px;
1129
+ max-height: 70vh;
1130
+ min-height: 160px;
1131
+ border-top: 1px solid var(--border);
1132
+ overflow: auto;
1133
+ }
1134
+ .resource-inline[role] {
1135
+ padding: 12px;
1136
+ color: var(--muted);
1137
+ }
1138
+ .resource-inline[role=alert] {
1139
+ color: var(--vscode-errorForeground);
1140
+ }
1141
+ .resource-inline iframe {
1142
+ display: block;
1143
+ width: 100%;
1144
+ height: 100%;
1145
+ border: 0;
1146
+ }
1147
+ .resource-call-details {
1148
+ padding: 8px 12px;
1149
+ border-top: 1px solid var(--border);
1150
+ max-height: 320px;
1151
+ overflow: auto;
1152
+ }
1153
+ .resource-call-details pre {
1154
+ margin: 0;
1155
+ font-size: 11px;
1156
+ white-space: pre-wrap;
1157
+ overflow-wrap: anywhere;
1092
1158
  }
1093
1159
  .input-prompt {
1094
1160
  margin: 16px 0;
@@ -12885,7 +12885,33 @@
12885
12885
  "Write file": "\u5199\u5165\u6587\u4EF6",
12886
12886
  Yes: "\u662F",
12887
12887
  "Zoom in": "\u653E\u5927",
12888
- "Zoom out": "\u7F29\u5C0F"
12888
+ "Zoom out": "\u7F29\u5C0F",
12889
+ "Open resource": "\u6253\u5F00\u8D44\u6E90",
12890
+ "Show in conversation": "\u5728\u5BF9\u8BDD\u4E2D\u5C55\u793A",
12891
+ "Hide preview": "\u6536\u8D77\u9884\u89C8",
12892
+ "Open in new window": "\u5728\u65B0\u7A97\u53E3\u4E2D\u6253\u5F00",
12893
+ "Tool call details": "\u5DE5\u5177\u8C03\u7528\u8BE6\u60C5",
12894
+ "Please sign in to preview this server resource.": "\u8BF7\u767B\u5F55\u540E\u9884\u89C8\u670D\u52A1\u5668\u8D44\u6E90\u3002",
12895
+ "You do not have access to this resource.": "\u4F60\u6CA1\u6709\u6B64\u8D44\u6E90\u7684\u8BBF\u95EE\u6743\u9650\u3002",
12896
+ "The resource project is unavailable.": "\u8D44\u6E90\u6240\u5C5E\u9879\u76EE\u4E0D\u53EF\u7528\u3002",
12897
+ "The resource project is unavailable. Import or open the target project first.": "\u8D44\u6E90\u6240\u5C5E\u9879\u76EE\u4E0D\u53EF\u7528\uFF0C\u8BF7\u5148\u5BFC\u5165\u6216\u6253\u5F00\u76EE\u6807\u9879\u76EE\u3002",
12898
+ "The project does not allow this storage location.": "\u9879\u76EE\u4E0D\u5141\u8BB8\u4F7F\u7528\u6B64\u5B58\u50A8\u4F4D\u7F6E\u3002",
12899
+ "This resource no longer exists.": "\u6B64\u8D44\u6E90\u5DF2\u4E0D\u5B58\u5728\u3002",
12900
+ "Server source files cannot be previewed by this card.": "\u6B64\u5361\u7247\u4E0D\u652F\u6301\u9884\u89C8\u670D\u52A1\u5668\u6E90\u7801\u6587\u4EF6\u3002",
12901
+ "File is outside this project.": "\u6587\u4EF6\u4E0D\u5728\u6B64\u9879\u76EE\u4E2D\u3002",
12902
+ "File preview exceeds 2 MiB.": "\u6587\u4EF6\u9884\u89C8\u5927\u5C0F\u8D85\u8FC7 2 MiB\u3002",
12903
+ "This project does not provide a Kanban preview.": "\u6B64\u9879\u76EE\u4E0D\u63D0\u4F9B\u770B\u677F\u9884\u89C8\u3002",
12904
+ "Invalid resource preview URL.": "\u8D44\u6E90\u9884\u89C8\u5730\u5740\u65E0\u6548\u3002",
12905
+ "This preview configuration no longer exists.": "\u6B64\u9884\u89C8\u914D\u7F6E\u5DF2\u4E0D\u5B58\u5728\u3002",
12906
+ "Resource access changed. Open the card again.": "\u8D44\u6E90\u8BBF\u95EE\u72B6\u6001\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u5361\u7247\u3002",
12907
+ "This resource preview is read-only.": "\u6B64\u8D44\u6E90\u9884\u89C8\u4E3A\u53EA\u8BFB\u3002",
12908
+ "Invalid resource action.": "\u8D44\u6E90\u64CD\u4F5C\u65E0\u6548\u3002",
12909
+ "Run no longer exists.": "\u6B64\u8FD0\u884C\u5DF2\u4E0D\u5B58\u5728\u3002",
12910
+ "Conversation changed.": "\u4F1A\u8BDD\u5DF2\u53D8\u5316\u3002",
12911
+ "Unable to load this preview. Retry or open it separately.": "\u65E0\u6CD5\u52A0\u8F7D\u6B64\u9884\u89C8\uFF0C\u8BF7\u91CD\u8BD5\u6216\u5355\u72EC\u6253\u5F00\u3002",
12912
+ "Open in browser": "\u5728\u6D4F\u89C8\u5668\u4E2D\u6253\u5F00",
12913
+ "No resources": "\u6682\u65E0\u8D44\u6E90",
12914
+ "Allow popups to open this resource in a new window.": "\u8BF7\u5141\u8BB8\u5F39\u51FA\u7A97\u53E3\u4EE5\u5355\u72EC\u6253\u5F00\u6B64\u8D44\u6E90\u3002"
12889
12915
  };
12890
12916
 
12891
12917
  // src/web/localization.ts
@@ -15333,11 +15359,14 @@ ${state2.user?.avatarUrl ?? ""}`;
15333
15359
  var ConnectionError = class extends Error {
15334
15360
  };
15335
15361
  var BrowserConnection = class {
15336
- constructor(emit) {
15362
+ constructor(emit, live = true) {
15337
15363
  this.emit = emit;
15364
+ this.live = live;
15338
15365
  if (this.token) {
15366
+ const query = new URLSearchParams(location.search);
15367
+ query.delete("session");
15339
15368
  sessionStorage.setItem("workflow-web-session", this.token);
15340
- history.replaceState(null, "", `${location.pathname}${location.search}`);
15369
+ history.replaceState(null, "", `${location.pathname}${query.size ? `?${query}` : ""}`);
15341
15370
  }
15342
15371
  queueMicrotask(() => {
15343
15372
  this.banner = document.createElement("div");
@@ -15371,6 +15400,7 @@ ${state2.user?.avatarUrl ?? ""}`;
15371
15400
  });
15372
15401
  }
15373
15402
  emit;
15403
+ live;
15374
15404
  clientId = crypto.randomUUID();
15375
15405
  source;
15376
15406
  banner;
@@ -15378,10 +15408,11 @@ ${state2.user?.avatarUrl ?? ""}`;
15378
15408
  handshake;
15379
15409
  epoch = 0;
15380
15410
  retry;
15411
+ snapshotTimer;
15381
15412
  status = "connecting";
15382
15413
  attempts = 0;
15383
15414
  closed = false;
15384
- token = new URLSearchParams(location.hash.slice(1)).get("session") ?? sessionStorage.getItem("workflow-web-session");
15415
+ token = new URLSearchParams(location.hash.slice(1)).get("session") ?? new URLSearchParams(location.search).get("session") ?? sessionStorage.getItem("workflow-web-session");
15385
15416
  update(status) {
15386
15417
  this.status = status;
15387
15418
  this.emit({ type: "connection", status });
@@ -15404,6 +15435,7 @@ ${state2.user?.avatarUrl ?? ""}`;
15404
15435
  this.source?.close();
15405
15436
  this.source = void 0;
15406
15437
  clearTimeout(this.retry);
15438
+ clearTimeout(this.snapshotTimer);
15407
15439
  }
15408
15440
  interrupted() {
15409
15441
  this.disconnect();
@@ -15457,6 +15489,10 @@ ${state2.user?.avatarUrl ?? ""}`;
15457
15489
  if (!session.ok) {
15458
15490
  throw new Error("Cannot connect to the project.");
15459
15491
  }
15492
+ if (!this.live) {
15493
+ await this.snapshot(epoch);
15494
+ return;
15495
+ }
15460
15496
  const eventsUrl = new URL(this.fileUrl("/api/events"), location.href);
15461
15497
  eventsUrl.searchParams.set("clientId", this.clientId);
15462
15498
  const source = this.source = new EventSource(eventsUrl.href);
@@ -15493,6 +15529,39 @@ ${state2.user?.avatarUrl ?? ""}`;
15493
15529
  });
15494
15530
  return this.connecting;
15495
15531
  }
15532
+ async snapshot(epoch) {
15533
+ if (epoch !== this.epoch || this.closed) {
15534
+ return;
15535
+ }
15536
+ const response = await fetch("/api/resource-state", { headers: this.headers(), signal: AbortSignal.timeout(1e4) });
15537
+ if (epoch !== this.epoch || this.closed) {
15538
+ return;
15539
+ }
15540
+ if (response.status === 401) {
15541
+ this.disconnect();
15542
+ this.update("expired");
15543
+ return;
15544
+ }
15545
+ if (!response.ok) {
15546
+ throw new Error("Cannot connect to the project.");
15547
+ }
15548
+ const state2 = await response.json();
15549
+ if (epoch !== this.epoch || this.closed) {
15550
+ return;
15551
+ }
15552
+ if (this.status !== "connected") {
15553
+ this.attempts = 0;
15554
+ this.update("connected");
15555
+ }
15556
+ this.emit(state2);
15557
+ this.snapshotTimer = setTimeout(() => {
15558
+ void this.snapshot(epoch).catch(() => {
15559
+ if (epoch === this.epoch && !this.closed) {
15560
+ this.interrupted();
15561
+ }
15562
+ });
15563
+ }, 5e3);
15564
+ }
15496
15565
  async request(message) {
15497
15566
  await this.connecting;
15498
15567
  if (this.status !== "connected") {
@@ -15538,7 +15607,12 @@ ${state2.user?.avatarUrl ?? ""}`;
15538
15607
  return this.token ? { Authorization: `Bearer ${this.token}` } : {};
15539
15608
  }
15540
15609
  fileUrl(path) {
15541
- return this.token ? `${path}?session=${encodeURIComponent(this.token)}` : path;
15610
+ if (!this.token) {
15611
+ return path;
15612
+ }
15613
+ const url = new URL(path, location.href);
15614
+ url.searchParams.set("session", this.token);
15615
+ return `${url.pathname}${url.search}${url.hash}`;
15542
15616
  }
15543
15617
  publicFiles(value) {
15544
15618
  if (Array.isArray(value)) {
@@ -15759,7 +15833,7 @@ ${state2.user?.avatarUrl ?? ""}`;
15759
15833
  };
15760
15834
 
15761
15835
  // src/web/ui/host.ts
15762
- function acquireWorkflowHost() {
15836
+ function acquireWorkflowHost(options = {}) {
15763
15837
  const embedded = globalThis.acquireVsCodeApi;
15764
15838
  if (embedded) {
15765
15839
  return embedded();
@@ -15779,6 +15853,7 @@ ${state2.user?.avatarUrl ?? ""}`;
15779
15853
  window.parent.postMessage(message, "*");
15780
15854
  }
15781
15855
  });
15856
+ let resourceHost = false;
15782
15857
  const clipboard = new ClipboardBridge(
15783
15858
  (message) => window.parent.postMessage(message, "*"),
15784
15859
  (text2) => navigator.clipboard.writeText(text2),
@@ -15791,7 +15866,7 @@ ${state2.user?.avatarUrl ?? ""}`;
15791
15866
  }
15792
15867
  trace.receive(message);
15793
15868
  emit(message);
15794
- });
15869
+ }, options.live);
15795
15870
  const request2 = async (message) => {
15796
15871
  for (const entry of await connection.request(message)) {
15797
15872
  handleReply(entry);
@@ -15810,6 +15885,12 @@ ${state2.user?.avatarUrl ?? ""}`;
15810
15885
  if (event.data.clipboardVersion !== void 0) {
15811
15886
  clipboard.enable(event.data.clipboardVersion);
15812
15887
  }
15888
+ if (event.data.resourceVersion === 1) {
15889
+ resourceHost = true;
15890
+ }
15891
+ if (event.data.resourceError) {
15892
+ emit(event.data.resourceError);
15893
+ }
15813
15894
  clipboard.receive(event.data.clipboard);
15814
15895
  const traceCommand = trace.command(event.data.traceCommand);
15815
15896
  if (traceCommand) {
@@ -15827,7 +15908,14 @@ ${state2.user?.avatarUrl ?? ""}`;
15827
15908
  }
15828
15909
  return;
15829
15910
  }
15830
- if (reply.type === "download") {
15911
+ if (reply.type === "resource-preview") {
15912
+ reply.url = connection.fileUrl(reply.url);
15913
+ if (reply.action === "inline") {
15914
+ emit(reply);
15915
+ } else {
15916
+ window.open(reply.url, "_blank", "noopener");
15917
+ }
15918
+ } else if (reply.type === "download") {
15831
15919
  const url = URL.createObjectURL(new Blob([reply.content], { type: reply.mimeType ?? "application/json" }));
15832
15920
  const link = document.createElement("a");
15833
15921
  link.href = url;
@@ -15895,6 +15983,29 @@ ${state2.user?.avatarUrl ?? ""}`;
15895
15983
  if (message.type === "ready") {
15896
15984
  return;
15897
15985
  }
15986
+ if (message.type === "resource" && message.action !== "inline" && resourceHost) {
15987
+ window.parent.postMessage({ type: "workflow-resource", version: 1, request: message }, "*");
15988
+ return;
15989
+ }
15990
+ if (message.type === "resource" && message.action !== "inline") {
15991
+ const popup = window.open("", "_blank");
15992
+ try {
15993
+ const reply = (await connection.request(message)).find((reply2) => reply2.type === "resource-preview");
15994
+ if (reply && popup) {
15995
+ popup.opener = null;
15996
+ popup.location.href = connection.fileUrl(reply.url);
15997
+ } else {
15998
+ popup?.close();
15999
+ if (reply) {
16000
+ emit({ type: "error", message: t2("Allow popups to open this resource in a new window.") });
16001
+ }
16002
+ }
16003
+ } catch (error) {
16004
+ popup?.close();
16005
+ emit({ type: "error", requestId: message.requestId, message: error.message });
16006
+ }
16007
+ return;
16008
+ }
15898
16009
  if (message.type === "trace") {
15899
16010
  if (trace.open(message)) {
15900
16011
  return;