@promptframe/creation 0.3.5 → 0.3.7

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.
@@ -9,7 +9,7 @@
9
9
  "source": {
10
10
  "source": "npm",
11
11
  "package": "@promptframe/creation",
12
- "version": "0.3.5",
12
+ "version": "0.3.7",
13
13
  "registry": "https://registry.npmjs.org/"
14
14
  },
15
15
  "policy": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptframe-creation",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "通过 PromptFrame 的共用工具、作品和任务创作视频。",
5
5
  "author": {
6
6
  "name": "PromptFrame"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptframe-creation",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "使用自己的推理,通过 PromptFrame 的共用工具、作品和任务创作视频。",
5
5
  "author": {
6
6
  "name": "PromptFrame"
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  <!-- creation-install-command -->
10
10
  ```bash
11
- npx --yes @promptframe/creation@0.3.5 connect --endpoint <Studio提供的API地址>
11
+ npx --yes @promptframe/creation@0.3.7 connect --endpoint <Studio提供的API地址>
12
12
  ```
13
13
  <!-- /creation-install-command -->
14
14
 
@@ -24,6 +24,10 @@ API 使用 Studio 实际可达 origin 和 `/api` 或 `/api/mcp`,没有内置
24
24
 
25
25
  文件必须在桥所在机器可读;远程WSL或SSH中的桥不会自动获得桌面路径。返回结果说明实际文件宿主、原上传ID和幂等键。中断后保留同一键查询或显式恢复;取消同一会话,不另建替代上传。上传、内容校验和素材ready分别显示,ready后可在同一Studio项目使用。
26
26
 
27
+ 0.3.6在校验或衍生处理失败时,查询仍可成功返回,并保留有界的业务错误码;无法确认的原因使用通用错误码,不返回供应商原异常。已终结上传的提示不会建议恢复传输或无限查询。查询、恢复或取消不会重新执行已经完成的上传和衍生任务。
28
+
29
+ 0.3.7 可在创建回执缺少上传 ID 时,凭原请求键和相同文件身份只读查询原会话。明确准入拒绝且查询无会话时给出终结原因;未知回执继续观察原 key,不重新创建、上传或误报文件读取超时。需要平台支持 `inspect_create`;不支持时保留未知状态,不降低保护。
30
+
27
31
  ## 源码、包和宿主范围
28
32
 
29
33
  [0.3.2](docs/releases/0.3.2.md)改善本地目录插件升级的版本识别。[0.3.1](docs/releases/0.3.1.md)修复 Claude 会话身份更新;[0.3.0](docs/releases/0.3.0.md)增加 Claude Code 接入、平台动态工具发现、标准内容与版本化指引,以及新会话的兼容版本选择。已有0.2.x插件保持其安装来源;升级和新会话加载见[安装说明](docs/installing.md#claude-code接入)。
@@ -53,11 +57,11 @@ npm test
53
57
 
54
58
  外部创作 Agent 可以复用平台中的组件,也可以按需开发新组件,例如机制动态图解、对比视图和可参数化图表。先从 MCP 当前工具目录发现组件检索与 schema 读取能力,选择已可用的组件并按 schema 填充 props,使用平台返回的 `componentRef`。CLI 的 `discovery` 用于查看端点能力,`component list` 用于查看项目声明;它们不等于组件市场搜索。
55
59
 
56
- 需要新组件时,按需阅读独立的 [组件作者仓库与入门说明](https://github.com/ty-teams/promptframe-component-authoring#readme)、[组件创作 Skill](https://github.com/ty-teams/promptframe-component-authoring/blob/main/skills/component-authoring/SKILL.md) 和 [Authoring Guide](https://github.com/ty-teams/promptframe-component-authoring/blob/main/AUTHORING.md)。公开工具包为:
60
+ 需要新组件时,从当前项目入门的 `navigation.componentAuthoring` 取得组件创作 Skill、工具链 README、Authoring Guide 和 CLI 说明。四项链接绑定该平台实际采用的公开发行源码,随平台正常采用或回滚一起变化。已安装 CLI 使用自己的随包文档及发行链接;平台支持状态继续以实时目录和 schema 为准。导航元数据暂缺不影响公开基线读取,可使用已有 CLI 的文档。公开工具包为:
57
61
 
58
62
  | 工具包 | 用途 |
59
63
  | --- | --- |
60
- | [`@promptframe/cli`](https://www.npmjs.com/package/@promptframe/cli) | `promptframe` 命令:检查、预览、打包、上传和查询平台构建状态;[CLI 使用说明](https://github.com/ty-teams/promptframe-component-authoring/blob/main/packages/cli/README.md) |
64
+ | [`@promptframe/cli`](https://www.npmjs.com/package/@promptframe/cli) | `promptframe` 命令:检查、预览、打包、上传和查询平台构建状态;使用已安装发行的随包说明或项目入门给出的版本导航 |
61
65
  | [`create-promptframe-component`](https://www.npmjs.com/package/create-promptframe-component) | 创建组件项目与本地预览入口 |
62
66
  | [`@promptframe/component-kit`](https://www.npmjs.com/package/@promptframe/component-kit) | 组件布局、时序和预览等开发辅助能力 |
63
67
  | [`@promptframe/contracts`](https://www.npmjs.com/package/@promptframe/contracts) | 平台公开组件合同与标准 |
package/dist/cli.mjs CHANGED
@@ -7870,6 +7870,7 @@ var fail3 = (code) => {
7870
7870
  throw new CreationClientError("creation.local_upload." + code);
7871
7871
  };
7872
7872
  var knownError = (error4) => error4 instanceof CreationClientError && /^creation\.[a-z0-9_.:-]{1,180}$/.test(error4.message) ? error4.message : "creation.local_upload.control_unconfirmed";
7873
+ var createRefusal = (code) => /^creation\.direct_object_upload\.(?:size_limit_exceeded|pending_bytes_quota_exceeded|concurrent_multipart_quota_exceeded|daily_bytes_quota_exceeded|durable_storage_quota_exceeded|capacity_unavailable|admission_facts_unavailable)$/.test(code);
7873
7874
  var typeByExtension = {
7874
7875
  ".png": ["image", "image/png"],
7875
7876
  ".jpg": ["image", "image/jpeg"],
@@ -7885,7 +7886,17 @@ var typeByExtension = {
7885
7886
  ".webm": ["video", "video/webm"],
7886
7887
  ".pdf": ["document", "application/pdf"]
7887
7888
  };
7888
- var terminal = /* @__PURE__ */ new Set(["ready", "aborted", "expired", "rejected"]);
7889
+ var terminal = /* @__PURE__ */ new Set(["ready", "aborted", "expired", "rejected", "create_rejected"]);
7890
+ var terminalNext = {
7891
+ ready: "Use this asset in the same Studio project.",
7892
+ derivation_failed: "This finalized upload has no remaining transfer action. Review the failure in Studio. Do not create a replacement upload automatically.",
7893
+ aborted: "This upload was canceled. There is no remaining transfer action. Do not create a replacement upload automatically.",
7894
+ expired: "This upload expired. There is no remaining transfer action. Do not create a replacement upload automatically.",
7895
+ rejected: "This upload was rejected. Review the rejection in Studio. There is no remaining transfer action.",
7896
+ create_rejected: "The platform declined this create request. Review its cause; if a new upload is still needed, explicitly use a new key. No automatic replacement or retransmission is allowed.",
7897
+ creation_unconfirmed: "Creation is unconfirmed. Observe this same original key; do not recreate, PUT, or attribute it to a local file timeout."
7898
+ };
7899
+ var safeDerivationErrorCode = (value2) => typeof value2 === "string" && value2.length <= 160 && /^[a-z][a-z0-9_]*(?:\.[a-z0-9_]+){1,8}$/u.test(value2) ? value2 : "creation.local_upload.derivation_failed";
7889
7900
  var sessionCheck = (session, state) => {
7890
7901
  if (!session || session.uploadId !== state.uploadId || session.assetId !== state.assetId || session.sizeBytes !== state.file.sizeBytes || session.expectedChecksum !== state.file.checksum || session.originalName !== state.file.name || session.scope?.projectId !== state.projectId || session.scope?.sessionId !== state.sessionId) fail3("session_identity_unconfirmed");
7891
7902
  return session;
@@ -7929,8 +7940,9 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
7929
7940
  ...state.pendingPart ? { unconfirmedPart: state.pendingPart } : {},
7930
7941
  ...state.errorCode ? { errorCode: state.errorCode } : {},
7931
7942
  ...state.result ? { result: state.result } : {},
7943
+ ...state.createObservation ? { creation: { outcome: state.createDisposition ?? "unconfirmed", ...state.createObservation } } : {},
7932
7944
  automaticReplayAllowed: false,
7933
- next: job ? "Read status using this same key." : state.phase === "ready" ? "Use this asset in the same Studio project." : state.phase === "derivatives_pending" ? "Read status for the original asset validation and derivatives." : "Observe status or explicitly resume/cancel this same key. Do not create a replacement upload."
7945
+ next: job ? "Read status using this same key." : terminalNext[state.phase] ?? (state.phase === "derivatives_pending" ? "Read status for the original asset validation and derivatives." : "Observe status or explicitly resume/cancel this same key. Do not create a replacement upload.")
7934
7946
  });
7935
7947
  async function rpc(send, transfer2, options) {
7936
7948
  const response = await send(transfer2, options);
@@ -7954,7 +7966,28 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
7954
7966
  return body;
7955
7967
  }
7956
7968
  async function observe(state, send, persist) {
7957
- if (!state.uploadId) return { state, session: void 0 };
7969
+ if (!state.uploadId) {
7970
+ const observed = await rpc(send, { action: "inspect_create", request: state.request });
7971
+ if (observed.idempotencyKey !== state.request.idempotencyKey || typeof observed.found !== "boolean" || !Number.isFinite(Date.parse(observed.observedAt ?? ""))) fail3("session_identity_unconfirmed");
7972
+ if (!observed.found) {
7973
+ if (observed.session !== void 0) fail3("session_identity_unconfirmed");
7974
+ state.createObservation = { found: false, observedAt: observed.observedAt };
7975
+ const refused = state.createDisposition === "rejected" && createRefusal(state.createErrorCode ?? "");
7976
+ state.phase = refused ? "create_rejected" : "creation_unconfirmed";
7977
+ state.errorCode = refused ? state.createErrorCode : "creation.local_upload.create_unconfirmed_observe_original_key";
7978
+ if (persist) await persist();
7979
+ return { state, session: void 0 };
7980
+ }
7981
+ const session2 = observed.session;
7982
+ if (!session2 || typeof session2.uploadId !== "string" || typeof session2.assetId !== "string") fail3("session_identity_unconfirmed");
7983
+ sessionCheck(session2, { ...state, uploadId: session2.uploadId, assetId: session2.assetId });
7984
+ state.uploadId = session2.uploadId;
7985
+ state.assetId = session2.assetId;
7986
+ state.expiresAt = session2.expiresAt;
7987
+ state.createDisposition = "accepted";
7988
+ delete state.createErrorCode;
7989
+ delete state.createObservation;
7990
+ }
7958
7991
  const session = sessionCheck((await rpc(send, { action: "inspect", uploadId: state.uploadId })).session, state);
7959
7992
  state.expiresAt = session.expiresAt;
7960
7993
  state.lastObservedUploadState = session.state;
@@ -7977,9 +8010,19 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
7977
8010
  }
7978
8011
  if (result.isError) fail3("control_unconfirmed");
7979
8012
  if (body?.success === true && body.uploadId === state.uploadId && body.assetId === state.assetId) {
8013
+ if (!["ready", "failed", "processing", "derivatives_pending"].includes(body.status)) fail3("control_unconfirmed");
7980
8014
  state.phase = body.status === "ready" ? "ready" : body.status === "failed" ? "derivation_failed" : "derivatives_pending";
7981
- state.result = { success: true, status: body.status, uploadId: state.uploadId, assetId: state.assetId, jobId: state.jobId };
7982
- delete state.errorCode;
8015
+ const errorCode = body.status === "failed" ? safeDerivationErrorCode(body.errorCode) : void 0;
8016
+ state.result = {
8017
+ success: true,
8018
+ status: body.status,
8019
+ uploadId: state.uploadId,
8020
+ assetId: state.assetId,
8021
+ jobId: state.jobId,
8022
+ ...errorCode ? { errorCode } : {}
8023
+ };
8024
+ if (errorCode) state.errorCode = errorCode;
8025
+ else delete state.errorCode;
7983
8026
  } else if (body?.errorCode === "media_derivation.job_not_found") {
7984
8027
  state.phase = "completion_unconfirmed";
7985
8028
  state.errorCode = "creation.local_upload.completion_unconfirmed";
@@ -8109,6 +8152,10 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8109
8152
  let file;
8110
8153
  try {
8111
8154
  state = await persistence.read(key) ?? state;
8155
+ if (state && !state.uploadId) {
8156
+ await observe(state, send, () => persistence.write(key, state));
8157
+ if (!state.uploadId || terminal.has(state.phase) || state.phase === "derivatives_pending" || state.phase === "derivation_failed") return view(state);
8158
+ }
8112
8159
  if (input.action === "cancel") {
8113
8160
  if (["ready", "derivatives_pending", "derivation_failed"].includes(state.phase))
8114
8161
  return view((await observe(state, send, () => persistence.write(key, state))).state);
@@ -8144,6 +8191,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8144
8191
  return view(state);
8145
8192
  }
8146
8193
  }
8194
+ if (state) assertOriginalDeadline(state);
8147
8195
  if (typeof input.filePath !== "string" || input.filePath.length > 4096) fail3("file_selection_required");
8148
8196
  const startedAtMs = state?.startedAtMs ?? now(), deadlineAtMs = state?.deadlineAtMs ?? startedAtMs + 6e5;
8149
8197
  file = await openLocalUploadFile(input.filePath, { signal, deadlineAtMs, now });
@@ -8182,7 +8230,15 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8182
8230
  await binding.assertCurrent();
8183
8231
  let authorization;
8184
8232
  if (!state.uploadId) {
8185
- const created = await rpc(send, { action: "create", request: state.request });
8233
+ let created;
8234
+ try {
8235
+ created = await rpc(send, { action: "create", request: state.request });
8236
+ } catch (error4) {
8237
+ const code = knownError(error4);
8238
+ state.createDisposition = createRefusal(code) ? "rejected" : "unconfirmed";
8239
+ if (createRefusal(code)) state.createErrorCode = code;
8240
+ throw error4;
8241
+ }
8186
8242
  authorization = created.authorization;
8187
8243
  const session = authorization?.session;
8188
8244
  if (!session || typeof session.uploadId !== "string" || typeof session.assetId !== "string") fail3("authorization_invalid");
@@ -8219,7 +8275,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8219
8275
  return view(state, job);
8220
8276
  } catch (error4) {
8221
8277
  if (state) {
8222
- state.phase = "paused";
8278
+ state.phase = state.createDisposition === "rejected" && !state.uploadId ? "create_rejected" : "paused";
8223
8279
  state.errorCode = knownError(error4);
8224
8280
  await persistence.write(key, state);
8225
8281
  }
@@ -8258,7 +8314,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8258
8314
  }
8259
8315
 
8260
8316
  // lib/version.mjs
8261
- var CLIENT_VERSION = "0.3.5";
8317
+ var CLIENT_VERSION = "0.3.7";
8262
8318
  var CLIENT_PROTOCOL = "creation-client/v1";
8263
8319
 
8264
8320
  // lib/cli.mjs
@@ -76,6 +76,8 @@ Claude Code 使用官方 `plugin list --json` 与 `plugin marketplace list --jso
76
76
 
77
77
  ## 本机文件传输
78
78
 
79
+ 无上传 ID 的已尝试请求先调用平台 `inspect_create`,提交原完整请求以核对同一幂等键、项目、Session 与文件身份。该入口只读,不生成新授权或签名。明确准入拒绝和未知回执分开;只读未找到不能单独证明请求从未执行。恢复、取消或同 key 重试均不得盲目再次 create;已找到的原会话仍按原期限和原分片/完成回执接续。
80
+
79
81
  本机上传由平台目录的 `creation-local-file-upload/v1` 元数据选择,桥不按工具名称维护业务名单。模型只提供用户选择的单文件路径和原请求键;控制请求只带文件名、大小、SHA与原上传身份,字节流使用原会话的短期分片授权直达对象存储。
80
82
 
81
83
  文件哈希和分片读取持有同一个文件描述符,并核对路径/描述符身份与变更。每桥最多两项传输,单次读取64KiB;原文件/分片/授权期限共用剩余预算。私有恢复目录为凭据配置同目录下的 `local-upload-state`,目录0700/文件0600,不保存Token、签名地址或完整文件路径。恢复缺失分片时重新选择同一文件,平台已传分片为准;不确定的PUT不自动重复。平台会话仍拥有校验、采用、配额和清理权威。
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": "creation-install-guidance/v1",
3
3
  "package": "@promptframe/creation",
4
- "version": "0.3.5",
4
+ "version": "0.3.7",
5
5
  "hosts": [
6
6
  {
7
7
  "kind": "codex",
@@ -6,7 +6,7 @@
6
6
 
7
7
  <!-- creation-install-command -->
8
8
  ```bash
9
- npx --yes @promptframe/creation@0.3.5 connect --endpoint <Studio提供的API地址>
9
+ npx --yes @promptframe/creation@0.3.7 connect --endpoint <Studio提供的API地址>
10
10
  ```
11
11
  <!-- /creation-install-command -->
12
12
 
@@ -26,7 +26,7 @@ npx --yes @promptframe/creation@0.3.5 connect --endpoint <Studio提供的API地
26
26
 
27
27
  <!-- creation-install-command -->
28
28
  ```bash
29
- npx --yes @promptframe/creation@0.3.5 connect --host claude-code --endpoint <Studio提供的API地址>
29
+ npx --yes @promptframe/creation@0.3.7 connect --host claude-code --endpoint <Studio提供的API地址>
30
30
  ```
31
31
  <!-- /creation-install-command -->
32
32
 
@@ -46,7 +46,7 @@ CLI 优先使用 PATH 中的 Claude;桌面版远程连接 WSL 时,也识别
46
46
 
47
47
  <!-- creation-install-command -->
48
48
  ```bash
49
- npx --yes @promptframe/creation@0.3.5 connect --profile work-account --endpoint <另一环境API地址>
49
+ npx --yes @promptframe/creation@0.3.7 connect --profile work-account --endpoint <另一环境API地址>
50
50
  ```
51
51
  <!-- /creation-install-command -->
52
52
 
@@ -0,0 +1,5 @@
1
+ # 0.3.6
2
+
3
+ 本机上传查询保留平台返回的安全业务错误码。上传校验或衍生处理失败时,查询本身仍返回成功;失败状态与原因分列。无效或不安全的异常文本使用通用错误码,已终结上传不再提示恢复、取消或无限查询。
4
+
5
+ 状态查询及对终态原键的恢复或取消仅观察原上传和素材,不会重新上传、complete或入队。原上传身份、期限、权限与分片恢复合同不变。此补丁无需平台数据库变更,已安装的活动桥继续原运行版本;正常升级后的新会话才加载新包。
@@ -0,0 +1,7 @@
1
+ # 0.3.7
2
+
3
+ 本机上传创建回执丢失时,使用原请求键和文件身份只读查找已受理会话,不重新创建或重传。
4
+
5
+ 明确准入拒绝并确认无会话时,显示原原因和显式新请求指引;未知回执只观察原 key。无 ID 的旧请求不会因为本机文件预算已到期而误报读取超时。平台不支持该查询时保留未知状态。
6
+
7
+ 已受理会话的权限、期限、分片回执和完成恢复规则不变。升级不更换 Token 或热换活动桥,新会话的实际加载分别确认。
@@ -11,11 +11,28 @@ const wire='direct-object-upload.v2',digest=value=>createHash('sha256').update(J
11
11
  const fail=code=>{throw new CreationClientError('creation.local_upload.'+code);};
12
12
  const knownError=error=>error instanceof CreationClientError&&/^creation\.[a-z0-9_.:-]{1,180}$/.test(error.message)
13
13
  ?error.message:'creation.local_upload.control_unconfirmed';
14
+ // These typed admission refusals precede the platform session INSERT. An
15
+ // ambiguous transport or a scope/idempotency failure is never such a receipt.
16
+ const createRefusal=code=>/^creation\.direct_object_upload\.(?:size_limit_exceeded|pending_bytes_quota_exceeded|concurrent_multipart_quota_exceeded|daily_bytes_quota_exceeded|durable_storage_quota_exceeded|capacity_unavailable|admission_facts_unavailable)$/.test(code);
14
17
  const typeByExtension={'.png':['image','image/png'],'.jpg':['image','image/jpeg'],'.jpeg':['image','image/jpeg'],
15
18
  '.webp':['image','image/webp'],'.gif':['image','image/gif'],'.wav':['audio','audio/wav'],'.mp3':['audio','audio/mpeg'],
16
19
  '.m4a':['audio','audio/mp4'],'.flac':['audio','audio/flac'],'.mp4':['video','video/mp4'],'.mov':['video','video/quicktime'],
17
20
  '.webm':['video','video/webm'],'.pdf':['document','application/pdf']};
18
- const terminal=new Set(['ready','aborted','expired','rejected']);
21
+ const terminal=new Set(['ready','aborted','expired','rejected','create_rejected']);
22
+ const terminalNext={
23
+ ready:'Use this asset in the same Studio project.',
24
+ derivation_failed:'This finalized upload has no remaining transfer action. Review the failure in Studio. Do not create a replacement upload automatically.',
25
+ aborted:'This upload was canceled. There is no remaining transfer action. Do not create a replacement upload automatically.',
26
+ expired:'This upload expired. There is no remaining transfer action. Do not create a replacement upload automatically.',
27
+ rejected:'This upload was rejected. Review the rejection in Studio. There is no remaining transfer action.',
28
+ create_rejected:'The platform declined this create request. Review its cause; if a new upload is still needed, explicitly use a new key. No automatic replacement or retransmission is allowed.',
29
+ creation_unconfirmed:'Creation is unconfirmed. Observe this same original key; do not recreate, PUT, or attribute it to a local file timeout.',
30
+ };
31
+ // Only the authenticated, identity-checked platform result supplies a cause.
32
+ // Preserve bounded machine codes, never arbitrary upstream error text.
33
+ const safeDerivationErrorCode=value=>typeof value==='string'&&value.length<=160
34
+ &&/^[a-z][a-z0-9_]*(?:\.[a-z0-9_]+){1,8}$/u.test(value)
35
+ ?value:'creation.local_upload.derivation_failed';
19
36
  const sessionCheck=(session,state)=>{
20
37
  if(!session||session.uploadId!==state.uploadId||session.assetId!==state.assetId
21
38
  ||session.sizeBytes!==state.file.sizeBytes||session.expectedChecksum!==state.file.checksum
@@ -60,10 +77,11 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
60
77
  progress:{uploadedBytes:state.parts.reduce((sum,p)=>sum+p.sizeBytes,0)+(job?.progress??0),totalBytes:state.file.sizeBytes},
61
78
  ...(state.jobId?{jobId:state.jobId}:{}),...(state.pendingPart?{unconfirmedPart:state.pendingPart}:{}),...(state.errorCode?{errorCode:state.errorCode}:{}),
62
79
  ...(state.result?{result:state.result}:{}),
80
+ ...(state.createObservation?{creation:{outcome:state.createDisposition??'unconfirmed',...state.createObservation}}:{}),
63
81
  automaticReplayAllowed:false,
64
- next:job?'Read status using this same key.':state.phase==='ready'?'Use this asset in the same Studio project.':
82
+ next:job?'Read status using this same key.':terminalNext[state.phase]??(
65
83
  state.phase==='derivatives_pending'?'Read status for the original asset validation and derivatives.':
66
- 'Observe status or explicitly resume/cancel this same key. Do not create a replacement upload.'});
84
+ 'Observe status or explicitly resume/cancel this same key. Do not create a replacement upload.')});
67
85
  async function rpc(send,transfer,options){
68
86
  const response=await send(transfer,options);
69
87
  const result=response?.result??response;
@@ -78,7 +96,24 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
78
96
  return body;
79
97
  }
80
98
  async function observe(state,send,persist){
81
- if(!state.uploadId)return{state,session:undefined};
99
+ if(!state.uploadId){
100
+ const observed=await rpc(send,{action:'inspect_create',request:state.request});
101
+ if(observed.idempotencyKey!==state.request.idempotencyKey||typeof observed.found!=='boolean'
102
+ ||!Number.isFinite(Date.parse(observed.observedAt??'')))fail('session_identity_unconfirmed');
103
+ if(!observed.found){
104
+ if(observed.session!==undefined)fail('session_identity_unconfirmed');
105
+ state.createObservation={found:false,observedAt:observed.observedAt};
106
+ const refused=state.createDisposition==='rejected'&&createRefusal(state.createErrorCode??'');
107
+ state.phase=refused?'create_rejected':'creation_unconfirmed';
108
+ state.errorCode=refused?state.createErrorCode:'creation.local_upload.create_unconfirmed_observe_original_key';
109
+ if(persist)await persist();return{state,session:undefined};
110
+ }
111
+ const session=observed.session;
112
+ if(!session||typeof session.uploadId!=='string'||typeof session.assetId!=='string')fail('session_identity_unconfirmed');
113
+ sessionCheck(session,{...state,uploadId:session.uploadId,assetId:session.assetId});
114
+ state.uploadId=session.uploadId;state.assetId=session.assetId;state.expiresAt=session.expiresAt;
115
+ state.createDisposition='accepted';delete state.createErrorCode;delete state.createObservation;
116
+ }
82
117
  const session=sessionCheck((await rpc(send,{action:'inspect',uploadId:state.uploadId})).session,state);
83
118
  state.expiresAt=session.expiresAt;state.lastObservedUploadState=session.state;
84
119
  if(session.state==='uploaded_unverified'){state.phase='completion_unconfirmed';state.errorCode='creation.local_upload.completion_requires_resume';}
@@ -90,9 +125,12 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
90
125
  let body;try{body=result.structuredContent??JSON.parse(result.content?.find(block=>block.type==='text')?.text);}catch{fail('control_unconfirmed');}
91
126
  if(result.isError)fail('control_unconfirmed');
92
127
  if(body?.success===true&&body.uploadId===state.uploadId&&body.assetId===state.assetId){
128
+ if(!['ready','failed','processing','derivatives_pending'].includes(body.status))fail('control_unconfirmed');
93
129
  state.phase=body.status==='ready'?'ready':body.status==='failed'?'derivation_failed':'derivatives_pending';
94
- state.result={success:true,status:body.status,uploadId:state.uploadId,assetId:state.assetId,jobId:state.jobId};
95
- delete state.errorCode;
130
+ const errorCode=body.status==='failed'?safeDerivationErrorCode(body.errorCode):undefined;
131
+ state.result={success:true,status:body.status,uploadId:state.uploadId,assetId:state.assetId,jobId:state.jobId,
132
+ ...(errorCode?{errorCode}:{})};
133
+ if(errorCode)state.errorCode=errorCode;else delete state.errorCode;
96
134
  }else if(body?.errorCode==='media_derivation.job_not_found'){
97
135
  state.phase='completion_unconfirmed';state.errorCode='creation.local_upload.completion_unconfirmed';
98
136
  }else fail('session_identity_unconfirmed');
@@ -184,6 +222,12 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
184
222
  let file;
185
223
  try{
186
224
  state=await persistence.read(key)??state;
225
+ // Never open/hash a file or repeat create for an already attempted key
226
+ // with a missing receipt. A normal lookup may recover its original ID.
227
+ if(state&&!state.uploadId){
228
+ await observe(state,send,()=>persistence.write(key,state));
229
+ if(!state.uploadId||terminal.has(state.phase)||state.phase==='derivatives_pending'||state.phase==='derivation_failed')return view(state);
230
+ }
187
231
  if(input.action==='cancel'){
188
232
  if(['ready','derivatives_pending','derivation_failed'].includes(state.phase))
189
233
  return view((await observe(state,send,()=>persistence.write(key,state))).state);
@@ -214,6 +258,7 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
214
258
  return view(state);
215
259
  }
216
260
  }
261
+ if(state)assertOriginalDeadline(state);
217
262
  if(typeof input.filePath!=='string'||input.filePath.length>4096)fail('file_selection_required');
218
263
  const startedAtMs=state?.startedAtMs??now(),deadlineAtMs=state?.deadlineAtMs??startedAtMs+600_000;
219
264
  file=await openLocalUploadFile(input.filePath,{signal,deadlineAtMs,now});
@@ -234,7 +279,14 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
234
279
  }
235
280
  await binding.assertCurrent();let authorization;
236
281
  if(!state.uploadId){
237
- const created=await rpc(send,{action:'create',request:state.request});authorization=created.authorization;
282
+ let created;
283
+ try{created=await rpc(send,{action:'create',request:state.request});}
284
+ catch(error){
285
+ const code=knownError(error);state.createDisposition=createRefusal(code)?'rejected':'unconfirmed';
286
+ if(createRefusal(code))state.createErrorCode=code;
287
+ throw error;
288
+ }
289
+ authorization=created.authorization;
238
290
  const session=authorization?.session;
239
291
  if(!session||typeof session.uploadId!=='string'||typeof session.assetId!=='string')fail('authorization_invalid');
240
292
  state.uploadId=session.uploadId;state.assetId=session.assetId;sessionCheck(session,state);
@@ -252,7 +304,7 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
252
304
  await job.save();
253
305
  }).finally(async()=>{try{await job.file.close();}finally{try{await release();}finally{jobs.delete(key);}}});
254
306
  job.done.catch(()=>{});return view(state,job);
255
- }catch(error){if(state){state.phase='paused';state.errorCode=knownError(error);await persistence.write(key,state);}throw error;}
307
+ }catch(error){if(state){state.phase=state.createDisposition==='rejected'&&!state.uploadId?'create_rejected':'paused';state.errorCode=knownError(error);await persistence.write(key,state);}throw error;}
256
308
  finally{if(!jobs.has(key)){await file?.close();await release();}}
257
309
  }
258
310
  return{call(options){
package/lib/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const CLIENT_VERSION = "0.3.5";
1
+ export const CLIENT_VERSION = "0.3.7";
2
2
  export const CLIENT_PROTOCOL = "creation-client/v1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptframe/creation",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "private": false,
5
5
  "description": "PromptFrame video creation Skill, Codex plugin and MCP client bridge.",
6
6
  "repository": {
@@ -10,11 +10,11 @@ description: 安装、连接或升级 PromptFrame Creation,复用平台创作
10
10
  先确认使用 Codex 还是 Claude Code。Claude 接入使用 `connect --host claude-code`,两种宿主可共用同一 profile 凭据,插件登记分别核实。使用 Studio 对当前环境提供的固定版本;旧版入口不会因平台更新自动改变。Claude 桌面版远程连接 WSL 时,在同一 WSL 安装;没有终端命令时可通过 `--claude-bin <实际可执行文件>` 指定桌面版提供的入口,不固定桌面构建文件名。
11
11
 
12
12
  <!-- creation-install-command -->
13
- 在用户本机终端运行 `npx --yes @promptframe/creation@0.3.5 connect --endpoint <Studio提供的API地址>`。需要隔离另一个环境或账号时显式加 `--profile <用户选择的名称>`;正在运行的桥不会切换。此命令管理用户级版本和 Codex 插件,不向当前项目安装依赖。优先使用 Studio 当前提供的固定推荐版本;每次重新进入此入口比较已安装版本,不后台追踪 latest,也不把旧聊天里的命令当最新版本。已安装更新版不默认降级。
13
+ 在用户本机终端运行 `npx --yes @promptframe/creation@0.3.7 connect --endpoint <Studio提供的API地址>`。需要隔离另一个环境或账号时显式加 `--profile <用户选择的名称>`;正在运行的桥不会切换。此命令管理用户级版本和 Codex 插件,不向当前项目安装依赖。优先使用 Studio 当前提供的固定推荐版本;每次重新进入此入口比较已安装版本,不后台追踪 latest,也不把旧聊天里的命令当最新版本。已安装更新版不默认降级。
14
14
  <!-- /creation-install-command -->
15
15
 
16
16
  <!-- creation-install-command -->
17
- Claude Code 使用 `npx --yes @promptframe/creation@0.3.5 connect --host claude-code --endpoint <Studio提供的API地址>`。桌面版远程连接 WSL 时,在该 WSL 执行;保留相同 profile 和有效凭据。
17
+ Claude Code 使用 `npx --yes @promptframe/creation@0.3.7 connect --host claude-code --endpoint <Studio提供的API地址>`。桌面版远程连接 WSL 时,在该 WSL 执行;保留相同 profile 和有效凭据。
18
18
  <!-- /creation-install-command -->
19
19
 
20
20
  命令会复用并验证有效凭据。首次授权或明确更换已失效凭据时,由用户在 Studio 登录并在终端的不回显输入框提供 Token;不要要求用户把 Token 粘进聊天,也不要把它写进命令参数、URL或日志。网络失败不等于授权失效,不自动轮换或覆盖凭据。
@@ -33,4 +33,4 @@ description: 在 PromptFrame 中规划、制作和接续视频,复用平台作
33
33
 
34
34
  ## 需要自定义组件时
35
35
 
36
- 先在平台目录检索现成组件并读取 schema,使用受管 `componentRef`。确需新组件时,按[组件创作 Skill](https://github.com/ty-teams/promptframe-component-authoring/blob/main/skills/component-authoring/SKILL.md)、[工具链 README](https://github.com/ty-teams/promptframe-component-authoring#readme)与[Authoring Guide](https://github.com/ty-teams/promptframe-component-authoring/blob/main/AUTHORING.md)在独立作者项目开发。平台构建与授权就绪后再接回作品;本地文件、npm 包名和上传受理不是可用组件身份。组件上传凭据与创作 Token 用途不同。
36
+ 先在平台目录检索现成组件并读取 schema,使用受管 `componentRef`。确需新组件时,使用项目入门返回的 `navigation.componentAuthoring`,按该平台已采用发行的组件 Skill、工具链 README、Authoring Guide 与 CLI 说明在独立作者项目开发。已安装 CLI 使用自己的随包文档及发行链接;选项与支持状态仍核当前平台 schema。导航元数据暂缺时可继续读取公开基线,使用已有 CLI 的文档。平台构建与授权就绪后再接回作品;本地文件、npm 包名和上传受理不是可用组件身份。组件上传凭据与创作 Token 用途不同。