@promptframe/creation 0.3.4 → 0.3.6
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/.agents/plugins/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +4 -2
- package/dist/cli.mjs +131 -44
- package/docs/development.md +5 -1
- package/docs/install-guidance.json +1 -1
- package/docs/installing.md +3 -3
- package/docs/releases/0.3.6.md +5 -0
- package/lib/local-upload-transfer.mjs +13 -1
- package/lib/local-upload.mjs +91 -29
- package/lib/version.mjs +1 -1
- package/package.json +1 -1
- package/skills/creation-setup/SKILL.md +2 -2
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.
|
|
11
|
+
npx --yes @promptframe/creation@0.3.6 connect --endpoint <Studio提供的API地址>
|
|
12
12
|
```
|
|
13
13
|
<!-- /creation-install-command -->
|
|
14
14
|
|
|
@@ -20,10 +20,12 @@ API 使用 Studio 实际可达 origin 和 `/api` 或 `/api/mcp`,没有内置
|
|
|
20
20
|
|
|
21
21
|
## 本机素材
|
|
22
22
|
|
|
23
|
-
平台目录提供本机上传入口时,0.3.
|
|
23
|
+
平台目录提供本机上传入口时,0.3.5桥可将用户明确选择的图片、音频、视频或文档流式直传到该上传会话授权的对象存储。桥只读取指定文件,不扫描目录、不把文件字节放进MCP消息,也不改变作品编辑权或制作确认。
|
|
24
24
|
|
|
25
25
|
文件必须在桥所在机器可读;远程WSL或SSH中的桥不会自动获得桌面路径。返回结果说明实际文件宿主、原上传ID和幂等键。中断后保留同一键查询或显式恢复;取消同一会话,不另建替代上传。上传、内容校验和素材ready分别显示,ready后可在同一Studio项目使用。
|
|
26
26
|
|
|
27
|
+
0.3.6在校验或衍生处理失败时,查询仍可成功返回,并保留有界的业务错误码;无法确认的原因使用通用错误码,不返回供应商原异常。已终结上传的提示不会建议恢复传输或无限查询。查询、恢复或取消不会重新执行已经完成的上传和衍生任务。
|
|
28
|
+
|
|
27
29
|
## 源码、包和宿主范围
|
|
28
30
|
|
|
29
31
|
[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接入)。
|
package/dist/cli.mjs
CHANGED
|
@@ -7525,7 +7525,7 @@ var fail = (code) => {
|
|
|
7525
7525
|
var positive = (value2) => Number.isSafeInteger(value2) && value2 > 0;
|
|
7526
7526
|
var forbiddenHeader = /^(?:authorization|cookie|host|connection|upgrade|proxy-.*)$/i;
|
|
7527
7527
|
var defaultBudget = { totalMs: 3e5, firstProgressMs: 3e4, idleMs: 6e4 };
|
|
7528
|
-
async function
|
|
7528
|
+
async function transferGrantedPart(file, authorization, grant, {
|
|
7529
7529
|
expectedUploadId,
|
|
7530
7530
|
expectedAssetId,
|
|
7531
7531
|
signal,
|
|
@@ -7632,6 +7632,20 @@ async function uploadGrantedPart(file, authorization, grant, {
|
|
|
7632
7632
|
});
|
|
7633
7633
|
}
|
|
7634
7634
|
}
|
|
7635
|
+
var effects = /* @__PURE__ */ new WeakMap();
|
|
7636
|
+
var readPartTransferEffect = (error4) => error4 && typeof error4 === "object" ? effects.get(error4) : void 0;
|
|
7637
|
+
async function uploadGrantedPart(file, authorization, grant, options = {}) {
|
|
7638
|
+
let dispatched = false;
|
|
7639
|
+
try {
|
|
7640
|
+
return await transferGrantedPart(file, authorization, grant, { ...options, fetch: async (...args2) => {
|
|
7641
|
+
dispatched = true;
|
|
7642
|
+
return (options.fetch ?? globalThis.fetch)(...args2);
|
|
7643
|
+
} });
|
|
7644
|
+
} catch (error4) {
|
|
7645
|
+
if (error4 && typeof error4 === "object") effects.set(error4, dispatched ? "unknown" : "not_dispatched");
|
|
7646
|
+
throw error4;
|
|
7647
|
+
}
|
|
7648
|
+
}
|
|
7635
7649
|
|
|
7636
7650
|
// lib/local-upload-state.mjs
|
|
7637
7651
|
import { constants as constants2 } from "node:fs";
|
|
@@ -7872,20 +7886,33 @@ var typeByExtension = {
|
|
|
7872
7886
|
".pdf": ["document", "application/pdf"]
|
|
7873
7887
|
};
|
|
7874
7888
|
var terminal = /* @__PURE__ */ new Set(["ready", "aborted", "expired", "rejected"]);
|
|
7889
|
+
var terminalNext = {
|
|
7890
|
+
ready: "Use this asset in the same Studio project.",
|
|
7891
|
+
derivation_failed: "This finalized upload has no remaining transfer action. Review the failure in Studio. Do not create a replacement upload automatically.",
|
|
7892
|
+
aborted: "This upload was canceled. There is no remaining transfer action. Do not create a replacement upload automatically.",
|
|
7893
|
+
expired: "This upload expired. There is no remaining transfer action. Do not create a replacement upload automatically.",
|
|
7894
|
+
rejected: "This upload was rejected. Review the rejection in Studio. There is no remaining transfer action."
|
|
7895
|
+
};
|
|
7896
|
+
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";
|
|
7875
7897
|
var sessionCheck = (session, state) => {
|
|
7876
7898
|
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");
|
|
7877
7899
|
return session;
|
|
7878
7900
|
};
|
|
7879
|
-
function
|
|
7880
|
-
|
|
7881
|
-
if (
|
|
7901
|
+
function receiptsForSession(session, parts, state) {
|
|
7902
|
+
sessionCheck(session, state);
|
|
7903
|
+
if (!Array.isArray(parts) || !Number.isSafeInteger(session.partSizeBytes) || session.partSizeBytes < 1 || session.partCount !== Math.ceil(state.file.sizeBytes / session.partSizeBytes)) fail3("authorization_invalid");
|
|
7882
7904
|
const seen = /* @__PURE__ */ new Set();
|
|
7883
|
-
for (const part of
|
|
7884
|
-
if (!Number.isSafeInteger(part.partNumber) || part.partNumber < 1 || part.partNumber > session.partCount || seen.has(part.partNumber) || typeof part.etag !== "string" || !part.etag || part.etag.length > 512 || part.sizeBytes !== Math.min(session.partSizeBytes, state.file.sizeBytes - (part.partNumber - 1) * session.partSizeBytes))
|
|
7905
|
+
for (const part of parts) {
|
|
7906
|
+
if (!Number.isSafeInteger(part.partNumber) || part.partNumber < 1 || part.partNumber > session.partCount || seen.has(part.partNumber) || typeof part.etag !== "string" || !part.etag || part.etag.length > 512 || /[\x00-\x1f\x7f]/.test(part.etag) || part.sizeBytes !== Math.min(session.partSizeBytes, state.file.sizeBytes - (part.partNumber - 1) * session.partSizeBytes))
|
|
7885
7907
|
fail3("part_receipt_unconfirmed");
|
|
7886
7908
|
seen.add(part.partNumber);
|
|
7887
7909
|
}
|
|
7888
|
-
return new Map(
|
|
7910
|
+
return new Map(parts.map((part) => [part.partNumber, part]));
|
|
7911
|
+
}
|
|
7912
|
+
function partReceipts(authorization, state) {
|
|
7913
|
+
if (authorization?.contractVersion !== wire || !Array.isArray(authorization.grants) || authorization.grants.length > 2)
|
|
7914
|
+
fail3("authorization_invalid");
|
|
7915
|
+
return receiptsForSession(authorization.session, authorization.uploadedParts, state);
|
|
7889
7916
|
}
|
|
7890
7917
|
function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch, now = Date.now } = {}) {
|
|
7891
7918
|
if (!stateRoot) fail3("recovery_state_unavailable");
|
|
@@ -7900,18 +7927,21 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
7900
7927
|
sessionId: state.sessionId,
|
|
7901
7928
|
file: { name: state.file.name, sizeBytes: state.file.sizeBytes, checksum: state.file.checksum },
|
|
7902
7929
|
fileHost: { os: platform(), machine: hostname(), location: "bridge_host" },
|
|
7903
|
-
status: job ? "transferring" : state.phase,
|
|
7930
|
+
status: job ? "transferring" : ["creating", "transferring", "completing", "cancelling"].includes(state.phase) ? "observation_required" : state.phase,
|
|
7931
|
+
phase: state.phase,
|
|
7932
|
+
transport: { activeInThisBridge: !!job },
|
|
7904
7933
|
uploadId: state.uploadId ?? null,
|
|
7905
7934
|
assetId: state.assetId ?? null,
|
|
7906
7935
|
progress: { uploadedBytes: state.parts.reduce((sum, p2) => sum + p2.sizeBytes, 0) + (job?.progress ?? 0), totalBytes: state.file.sizeBytes },
|
|
7907
7936
|
...state.jobId ? { jobId: state.jobId } : {},
|
|
7937
|
+
...state.pendingPart ? { unconfirmedPart: state.pendingPart } : {},
|
|
7908
7938
|
...state.errorCode ? { errorCode: state.errorCode } : {},
|
|
7909
7939
|
...state.result ? { result: state.result } : {},
|
|
7910
7940
|
automaticReplayAllowed: false,
|
|
7911
|
-
next: job ? "Read status using this same key." : state.phase
|
|
7941
|
+
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.")
|
|
7912
7942
|
});
|
|
7913
|
-
async function rpc(send, transfer2) {
|
|
7914
|
-
const response = await send(transfer2);
|
|
7943
|
+
async function rpc(send, transfer2, options) {
|
|
7944
|
+
const response = await send(transfer2, options);
|
|
7915
7945
|
const result = response?.result ?? response;
|
|
7916
7946
|
if (result?.isError) {
|
|
7917
7947
|
let body2;
|
|
@@ -7932,9 +7962,14 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
7932
7962
|
return body;
|
|
7933
7963
|
}
|
|
7934
7964
|
async function observe(state, send, persist) {
|
|
7935
|
-
if (!state.uploadId) return state;
|
|
7965
|
+
if (!state.uploadId) return { state, session: void 0 };
|
|
7936
7966
|
const session = sessionCheck((await rpc(send, { action: "inspect", uploadId: state.uploadId })).session, state);
|
|
7937
7967
|
state.expiresAt = session.expiresAt;
|
|
7968
|
+
state.lastObservedUploadState = session.state;
|
|
7969
|
+
if (session.state === "uploaded_unverified") {
|
|
7970
|
+
state.phase = "completion_unconfirmed";
|
|
7971
|
+
state.errorCode = "creation.local_upload.completion_requires_resume";
|
|
7972
|
+
}
|
|
7938
7973
|
if (["aborted", "expired", "rejected"].includes(session.state)) {
|
|
7939
7974
|
state.phase = session.state;
|
|
7940
7975
|
delete state.errorCode;
|
|
@@ -7950,16 +7985,53 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
7950
7985
|
}
|
|
7951
7986
|
if (result.isError) fail3("control_unconfirmed");
|
|
7952
7987
|
if (body?.success === true && body.uploadId === state.uploadId && body.assetId === state.assetId) {
|
|
7988
|
+
if (!["ready", "failed", "processing", "derivatives_pending"].includes(body.status)) fail3("control_unconfirmed");
|
|
7953
7989
|
state.phase = body.status === "ready" ? "ready" : body.status === "failed" ? "derivation_failed" : "derivatives_pending";
|
|
7954
|
-
|
|
7955
|
-
|
|
7990
|
+
const errorCode = body.status === "failed" ? safeDerivationErrorCode(body.errorCode) : void 0;
|
|
7991
|
+
state.result = {
|
|
7992
|
+
success: true,
|
|
7993
|
+
status: body.status,
|
|
7994
|
+
uploadId: state.uploadId,
|
|
7995
|
+
assetId: state.assetId,
|
|
7996
|
+
jobId: state.jobId,
|
|
7997
|
+
...errorCode ? { errorCode } : {}
|
|
7998
|
+
};
|
|
7999
|
+
if (errorCode) state.errorCode = errorCode;
|
|
8000
|
+
else delete state.errorCode;
|
|
7956
8001
|
} else if (body?.errorCode === "media_derivation.job_not_found") {
|
|
7957
8002
|
state.phase = "completion_unconfirmed";
|
|
7958
8003
|
state.errorCode = "creation.local_upload.completion_unconfirmed";
|
|
7959
8004
|
} else fail3("session_identity_unconfirmed");
|
|
7960
8005
|
}
|
|
7961
8006
|
if (persist) await persist();
|
|
7962
|
-
return state;
|
|
8007
|
+
return { state, session };
|
|
8008
|
+
}
|
|
8009
|
+
function assertOriginalDeadline(state) {
|
|
8010
|
+
if (!Number.isFinite(state.deadlineAtMs) || !Number.isFinite(Date.parse(state.expiresAt)) || Math.min(state.deadlineAtMs, Date.parse(state.expiresAt)) <= now()) fail3("transfer_deadline_expired");
|
|
8011
|
+
}
|
|
8012
|
+
async function completeOriginal(state, session, send, binding, signal, save) {
|
|
8013
|
+
await binding.assertCurrent();
|
|
8014
|
+
signal?.throwIfAborted();
|
|
8015
|
+
assertOriginalDeadline(state);
|
|
8016
|
+
const parts = receiptsForSession(session, state.parts, state);
|
|
8017
|
+
if (parts.size !== session.partCount || state.completeKey !== "complete-" + state.key) fail3("original_completion_receipts_required");
|
|
8018
|
+
state.phase = "completing";
|
|
8019
|
+
await save();
|
|
8020
|
+
const timeout = Math.max(1, Math.min(3e4, state.deadlineAtMs - now(), Date.parse(state.expiresAt) - now()));
|
|
8021
|
+
const boundedSignal = AbortSignal.any([AbortSignal.timeout(timeout), ...signal ? [signal] : []]);
|
|
8022
|
+
const completed = await rpc(send, { action: "complete", request: {
|
|
8023
|
+
contractVersion: wire,
|
|
8024
|
+
uploadId: state.uploadId,
|
|
8025
|
+
idempotencyKey: state.completeKey,
|
|
8026
|
+
parts: state.parts
|
|
8027
|
+
} }, { signal: boundedSignal, timeout });
|
|
8028
|
+
assertOriginalDeadline(state);
|
|
8029
|
+
sessionCheck(completed.session, state);
|
|
8030
|
+
if (completed.session.state !== "finalized" || completed.jobId !== `direct-upload:${state.uploadId}`) fail3("completion_unconfirmed");
|
|
8031
|
+
state.jobId = completed.jobId;
|
|
8032
|
+
state.phase = "derivatives_pending";
|
|
8033
|
+
delete state.errorCode;
|
|
8034
|
+
await save();
|
|
7963
8035
|
}
|
|
7964
8036
|
async function transfer(job, authorization, send, binding) {
|
|
7965
8037
|
const { state, file, abort, save } = job;
|
|
@@ -7977,6 +8049,10 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
7977
8049
|
if (session.state === "finalized") break;
|
|
7978
8050
|
if (!["authorized", "uploading"].includes(session.state)) fail3("session_not_transferable");
|
|
7979
8051
|
const parts = partReceipts(envelope, state);
|
|
8052
|
+
if (state.pendingPart !== void 0) {
|
|
8053
|
+
if (!parts.has(state.pendingPart)) fail3("part_effect_unconfirmed_observe_original");
|
|
8054
|
+
delete state.pendingPart;
|
|
8055
|
+
}
|
|
7980
8056
|
state.parts = [...parts.values()].sort((a, b2) => a.partNumber - b2.partNumber);
|
|
7981
8057
|
await save();
|
|
7982
8058
|
if (parts.size === session.partCount) break;
|
|
@@ -7988,17 +8064,26 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
7988
8064
|
state.phase = "transferring";
|
|
7989
8065
|
state.pendingPart = grant.partNumber;
|
|
7990
8066
|
await save();
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8067
|
+
let part;
|
|
8068
|
+
try {
|
|
8069
|
+
part = await uploadGrantedPart(file, envelope, grant, {
|
|
8070
|
+
expectedUploadId: state.uploadId,
|
|
8071
|
+
expectedAssetId: state.assetId,
|
|
8072
|
+
signal: abort.signal,
|
|
8073
|
+
deadlineAtMs: state.deadlineAtMs,
|
|
8074
|
+
fetch: fetch2,
|
|
8075
|
+
now,
|
|
8076
|
+
onProgress: (progress) => {
|
|
8077
|
+
job.progress = progress.bytesRead;
|
|
8078
|
+
}
|
|
8079
|
+
});
|
|
8080
|
+
} catch (error4) {
|
|
8081
|
+
if (readPartTransferEffect(error4) === "not_dispatched") {
|
|
8082
|
+
delete state.pendingPart;
|
|
8083
|
+
await save();
|
|
8000
8084
|
}
|
|
8001
|
-
|
|
8085
|
+
throw error4;
|
|
8086
|
+
}
|
|
8002
8087
|
state.parts.push(part);
|
|
8003
8088
|
state.parts.sort((a, b2) => a.partNumber - b2.partNumber);
|
|
8004
8089
|
job.progress = 0;
|
|
@@ -8012,19 +8097,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
8012
8097
|
await binding.assertCurrent();
|
|
8013
8098
|
abort.signal.throwIfAborted();
|
|
8014
8099
|
await file.assertUnchanged();
|
|
8015
|
-
state.
|
|
8016
|
-
await save();
|
|
8017
|
-
const completed = await rpc(send, { action: "complete", request: {
|
|
8018
|
-
contractVersion: wire,
|
|
8019
|
-
uploadId: state.uploadId,
|
|
8020
|
-
idempotencyKey: state.completeKey,
|
|
8021
|
-
parts: state.parts
|
|
8022
|
-
} });
|
|
8023
|
-
sessionCheck(completed.session, state);
|
|
8024
|
-
state.jobId = completed.jobId;
|
|
8025
|
-
state.phase = "derivatives_pending";
|
|
8026
|
-
delete state.errorCode;
|
|
8027
|
-
await save();
|
|
8100
|
+
await completeOriginal(state, envelope.session, send, binding, abort.signal, save);
|
|
8028
8101
|
}
|
|
8029
8102
|
async function callCore({ input, scope, send, binding, signal }) {
|
|
8030
8103
|
if (closing) fail3("bridge_closing");
|
|
@@ -8056,7 +8129,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
8056
8129
|
state = await persistence.read(key) ?? state;
|
|
8057
8130
|
if (input.action === "cancel") {
|
|
8058
8131
|
if (["ready", "derivatives_pending", "derivation_failed"].includes(state.phase))
|
|
8059
|
-
return view(await observe(state, send, () => persistence.write(key, state)));
|
|
8132
|
+
return view((await observe(state, send, () => persistence.write(key, state))).state);
|
|
8060
8133
|
if (!state.uploadId) fail3("create_unconfirmed_observe_original_key");
|
|
8061
8134
|
state.phase = "cancelling";
|
|
8062
8135
|
await persistence.write(key, state);
|
|
@@ -8072,7 +8145,23 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
8072
8145
|
await persistence.write(key, state);
|
|
8073
8146
|
return view(state);
|
|
8074
8147
|
}
|
|
8075
|
-
if (state && terminal.has(state.phase)) return view(await observe(state, send, () => persistence.write(key, state)));
|
|
8148
|
+
if (state && terminal.has(state.phase)) return view((await observe(state, send, () => persistence.write(key, state))).state);
|
|
8149
|
+
if (state?.uploadId) {
|
|
8150
|
+
const observed = await observe(state, send, () => persistence.write(key, state));
|
|
8151
|
+
if (terminal.has(state.phase) || state.phase === "derivatives_pending" || state.phase === "derivation_failed") return view(state);
|
|
8152
|
+
if (["uploaded_unverified", "finalized"].includes(observed.session.state)) {
|
|
8153
|
+
if (input.action !== "resume") return view(state);
|
|
8154
|
+
assertOriginalDeadline(state);
|
|
8155
|
+
if (input.filePath !== void 0) {
|
|
8156
|
+
if (typeof input.filePath !== "string" || input.filePath.length > 4096) fail3("file_selection_required");
|
|
8157
|
+
file = await openLocalUploadFile(input.filePath, { signal, deadlineAtMs: state.deadlineAtMs, now });
|
|
8158
|
+
if (JSON.stringify(state.file.fingerprint) !== JSON.stringify(file.fingerprint) || state.file.name !== file.name) fail3("file_changed");
|
|
8159
|
+
}
|
|
8160
|
+
if (input.assetKind !== void 0 && input.assetKind !== state.request.assetKind || input.mimeType !== void 0 && input.mimeType !== state.request.mimeType) fail3("file_changed");
|
|
8161
|
+
await completeOriginal(state, observed.session, send, binding, signal, () => persistence.write(key, state));
|
|
8162
|
+
return view(state);
|
|
8163
|
+
}
|
|
8164
|
+
}
|
|
8076
8165
|
if (typeof input.filePath !== "string" || input.filePath.length > 4096) fail3("file_selection_required");
|
|
8077
8166
|
const startedAtMs = state?.startedAtMs ?? now(), deadlineAtMs = state?.deadlineAtMs ?? startedAtMs + 6e5;
|
|
8078
8167
|
file = await openLocalUploadFile(input.filePath, { signal, deadlineAtMs, now });
|
|
@@ -8121,8 +8210,6 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
8121
8210
|
state.expiresAt = session.expiresAt;
|
|
8122
8211
|
await persistence.write(key, state);
|
|
8123
8212
|
} else {
|
|
8124
|
-
await observe(state, send, () => persistence.write(key, state));
|
|
8125
|
-
if (terminal.has(state.phase) || state.phase === "derivatives_pending" || state.phase === "derivation_failed") return view(state);
|
|
8126
8213
|
authorization = (await rpc(send, { action: "resume", uploadId: state.uploadId })).authorization;
|
|
8127
8214
|
}
|
|
8128
8215
|
signal?.throwIfAborted();
|
|
@@ -8130,7 +8217,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
8130
8217
|
job = { state, file, abort, progress: 0, save: () => persistence.write(key, state) };
|
|
8131
8218
|
jobs.set(key, job);
|
|
8132
8219
|
file = void 0;
|
|
8133
|
-
job.done = Promise.resolve().then(() => transfer(job, authorization, (transfer2) => send(transfer2, { signal: abort.signal }), binding)).catch(async (error4) => {
|
|
8220
|
+
job.done = Promise.resolve().then(() => transfer(job, authorization, (transfer2, options) => send(transfer2, { signal: abort.signal, ...options }), binding)).catch(async (error4) => {
|
|
8134
8221
|
state.phase = "paused";
|
|
8135
8222
|
state.errorCode = abort.signal.aborted ? "creation.local_upload.transfer_cancelled" : knownError(error4);
|
|
8136
8223
|
await job.save();
|
|
@@ -8189,7 +8276,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
8189
8276
|
}
|
|
8190
8277
|
|
|
8191
8278
|
// lib/version.mjs
|
|
8192
|
-
var CLIENT_VERSION = "0.3.
|
|
8279
|
+
var CLIENT_VERSION = "0.3.6";
|
|
8193
8280
|
var CLIENT_PROTOCOL = "creation-client/v1";
|
|
8194
8281
|
|
|
8195
8282
|
// lib/cli.mjs
|
package/docs/development.md
CHANGED
|
@@ -78,6 +78,10 @@ Claude Code 使用官方 `plugin list --json` 与 `plugin marketplace list --jso
|
|
|
78
78
|
|
|
79
79
|
本机上传由平台目录的 `creation-local-file-upload/v1` 元数据选择,桥不按工具名称维护业务名单。模型只提供用户选择的单文件路径和原请求键;控制请求只带文件名、大小、SHA与原上传身份,字节流使用原会话的短期分片授权直达对象存储。
|
|
80
80
|
|
|
81
|
-
文件哈希和分片读取持有同一个文件描述符,并核对路径/描述符身份与变更。每桥最多两项传输,单次读取64KiB;原文件/分片/授权期限共用剩余预算。私有恢复目录为凭据配置同目录下的 `local-upload-state`,目录0700/文件0600,不保存Token
|
|
81
|
+
文件哈希和分片读取持有同一个文件描述符,并核对路径/描述符身份与变更。每桥最多两项传输,单次读取64KiB;原文件/分片/授权期限共用剩余预算。私有恢复目录为凭据配置同目录下的 `local-upload-state`,目录0700/文件0600,不保存Token、签名地址或完整文件路径。恢复缺失分片时重新选择同一文件,平台已传分片为准;不确定的PUT不自动重复。平台会话仍拥有校验、采用、配额和清理权威。
|
|
82
82
|
|
|
83
83
|
桥关闭时中止并等待本地传输、控制请求和文件IO;不隐式取消平台上传。正常取消沿原上传身份提交。每次正常访问时有界回收超过上传到期24小时的本地记录,活跃本地锁受保护;对象和已被引用资产只由平台既有生命周期清理。崩溃残留锁在Linux只凭精确boot/进程birth确认已退后恢复,其它平台无法确认时明确拒绝,不按PID猜测或自动覆盖锁。
|
|
84
|
+
|
|
85
|
+
完成阶段若已处于 `uploaded_unverified`,或已finalized但最小派生尚未入队,显式resume沿原completeKey、完整parts和原upload/asset重接complete,不请求分片resume或再次PUT。可不再选择本地文件;若同时给出文件,仍核原文件身份/内容。原会话和文件期限不延长。只读status不修复队列,丢失恢复回执后先查原状态;已确认派生存在时不再complete。返回的阶段与本桥是否仍在传输分别说明,崩溃记录不冒活跃IO。
|
|
86
|
+
|
|
87
|
+
已发PUT但缺确认的分片保持原pending身份;provider当前分片列表缺它不证明未开始,恢复不会再次PUT该分片。只有原分片后来可读的完成回执,或传输模块自身记录的真实not-dispatched,才继续缺失分片。任意错误文字不构成not-dispatched;必要时只沿原会话观察或明确取消。
|
package/docs/installing.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<!-- creation-install-command -->
|
|
8
8
|
```bash
|
|
9
|
-
npx --yes @promptframe/creation@0.3.
|
|
9
|
+
npx --yes @promptframe/creation@0.3.6 connect --endpoint <Studio提供的API地址>
|
|
10
10
|
```
|
|
11
11
|
<!-- /creation-install-command -->
|
|
12
12
|
|
|
@@ -26,7 +26,7 @@ npx --yes @promptframe/creation@0.3.4 connect --endpoint <Studio提供的API地
|
|
|
26
26
|
|
|
27
27
|
<!-- creation-install-command -->
|
|
28
28
|
```bash
|
|
29
|
-
npx --yes @promptframe/creation@0.3.
|
|
29
|
+
npx --yes @promptframe/creation@0.3.6 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.
|
|
49
|
+
npx --yes @promptframe/creation@0.3.6 connect --profile work-account --endpoint <另一环境API地址>
|
|
50
50
|
```
|
|
51
51
|
<!-- /creation-install-command -->
|
|
52
52
|
|
|
@@ -10,7 +10,7 @@ const defaultBudget={totalMs:300_000,firstProgressMs:30_000,idleMs:60_000};
|
|
|
10
10
|
|
|
11
11
|
/** Consume an authenticated platform grant, never a model-supplied destination.
|
|
12
12
|
* A successful PUT is a part receipt; asset readiness belongs to the platform. */
|
|
13
|
-
|
|
13
|
+
async function transferGrantedPart(file,authorization,grant,{
|
|
14
14
|
expectedUploadId,expectedAssetId,signal,deadlineAtMs=Infinity,
|
|
15
15
|
fetch:fetchPart=globalThis.fetch,now=Date.now,onProgress=()=>{},
|
|
16
16
|
}={}){
|
|
@@ -94,3 +94,15 @@ export async function uploadGrantedPart(file,authorization,grant,{
|
|
|
94
94
|
await response?.body?.cancel().catch(()=>{});
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
|
|
98
|
+
const effects=new WeakMap();
|
|
99
|
+
export const readPartTransferEffect=error=>error&&typeof error==='object'?effects.get(error):undefined;
|
|
100
|
+
export async function uploadGrantedPart(file,authorization,grant,options={}){
|
|
101
|
+
let dispatched=false;
|
|
102
|
+
try{return await transferGrantedPart(file,authorization,grant,{...options,fetch:async(...args)=>{
|
|
103
|
+
dispatched=true;return(options.fetch??globalThis.fetch)(...args);
|
|
104
|
+
}});}catch(error){
|
|
105
|
+
if(error&&typeof error==='object')effects.set(error,dispatched?'unknown':'not_dispatched');
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
package/lib/local-upload.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {hostname,platform} from 'node:os';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import {CreationClientError} from './credentials.mjs';
|
|
5
5
|
import {openLocalUploadFile} from './local-upload-file.mjs';
|
|
6
|
-
import {uploadGrantedPart} from './local-upload-transfer.mjs';
|
|
6
|
+
import {uploadGrantedPart,readPartTransferEffect} from './local-upload-transfer.mjs';
|
|
7
7
|
import {localUploadState} from './local-upload-state.mjs';
|
|
8
8
|
|
|
9
9
|
export const LOCAL_UPLOAD_PROTOCOL='creation-local-file-upload/v1';
|
|
@@ -16,6 +16,18 @@ const typeByExtension={'.png':['image','image/png'],'.jpg':['image','image/jpeg'
|
|
|
16
16
|
'.m4a':['audio','audio/mp4'],'.flac':['audio','audio/flac'],'.mp4':['video','video/mp4'],'.mov':['video','video/quicktime'],
|
|
17
17
|
'.webm':['video','video/webm'],'.pdf':['document','application/pdf']};
|
|
18
18
|
const terminal=new Set(['ready','aborted','expired','rejected']);
|
|
19
|
+
const terminalNext={
|
|
20
|
+
ready:'Use this asset in the same Studio project.',
|
|
21
|
+
derivation_failed:'This finalized upload has no remaining transfer action. Review the failure in Studio. Do not create a replacement upload automatically.',
|
|
22
|
+
aborted:'This upload was canceled. There is no remaining transfer action. Do not create a replacement upload automatically.',
|
|
23
|
+
expired:'This upload expired. There is no remaining transfer action. Do not create a replacement upload automatically.',
|
|
24
|
+
rejected:'This upload was rejected. Review the rejection in Studio. There is no remaining transfer action.',
|
|
25
|
+
};
|
|
26
|
+
// Only the authenticated, identity-checked platform result supplies a cause.
|
|
27
|
+
// Preserve bounded machine codes, never arbitrary upstream error text.
|
|
28
|
+
const safeDerivationErrorCode=value=>typeof value==='string'&&value.length<=160
|
|
29
|
+
&&/^[a-z][a-z0-9_]*(?:\.[a-z0-9_]+){1,8}$/u.test(value)
|
|
30
|
+
?value:'creation.local_upload.derivation_failed';
|
|
19
31
|
const sessionCheck=(session,state)=>{
|
|
20
32
|
if(!session||session.uploadId!==state.uploadId||session.assetId!==state.assetId
|
|
21
33
|
||session.sizeBytes!==state.file.sizeBytes||session.expectedChecksum!==state.file.checksum
|
|
@@ -23,21 +35,25 @@ const sessionCheck=(session,state)=>{
|
|
|
23
35
|
||session.scope?.sessionId!==state.sessionId)fail('session_identity_unconfirmed');
|
|
24
36
|
return session;
|
|
25
37
|
};
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
if(
|
|
29
|
-
||!Array.isArray(authorization.grants)||authorization.grants.length>2
|
|
30
|
-
||!Number.isSafeInteger(session.partSizeBytes)||session.partSizeBytes<1
|
|
38
|
+
function receiptsForSession(session,parts,state){
|
|
39
|
+
sessionCheck(session,state);
|
|
40
|
+
if(!Array.isArray(parts)||!Number.isSafeInteger(session.partSizeBytes)||session.partSizeBytes<1
|
|
31
41
|
||session.partCount!==Math.ceil(state.file.sizeBytes/session.partSizeBytes))fail('authorization_invalid');
|
|
32
42
|
const seen=new Set();
|
|
33
|
-
for(const part of
|
|
43
|
+
for(const part of parts){
|
|
34
44
|
if(!Number.isSafeInteger(part.partNumber)||part.partNumber<1||part.partNumber>session.partCount
|
|
35
45
|
||seen.has(part.partNumber)||typeof part.etag!=='string'||!part.etag||part.etag.length>512
|
|
46
|
+
||/[\x00-\x1f\x7f]/.test(part.etag)
|
|
36
47
|
||part.sizeBytes!==Math.min(session.partSizeBytes,state.file.sizeBytes-(part.partNumber-1)*session.partSizeBytes))
|
|
37
48
|
fail('part_receipt_unconfirmed');
|
|
38
49
|
seen.add(part.partNumber);
|
|
39
50
|
}
|
|
40
|
-
return new Map(
|
|
51
|
+
return new Map(parts.map(part=>[part.partNumber,part]));
|
|
52
|
+
}
|
|
53
|
+
function partReceipts(authorization,state){
|
|
54
|
+
if(authorization?.contractVersion!==wire||!Array.isArray(authorization.grants)||authorization.grants.length>2)
|
|
55
|
+
fail('authorization_invalid');
|
|
56
|
+
return receiptsForSession(authorization.session,authorization.uploadedParts,state);
|
|
41
57
|
}
|
|
42
58
|
|
|
43
59
|
/** Process-local transport tasks for the platform's existing upload sessions.
|
|
@@ -51,16 +67,17 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
|
|
|
51
67
|
idempotencyKey:state.idempotencyKey,projectId:state.projectId,sessionId:state.sessionId,
|
|
52
68
|
file:{name:state.file.name,sizeBytes:state.file.sizeBytes,checksum:state.file.checksum},
|
|
53
69
|
fileHost:{os:platform(),machine:hostname(),location:'bridge_host'},
|
|
54
|
-
status:job?'transferring':state.phase
|
|
70
|
+
status:job?'transferring':['creating','transferring','completing','cancelling'].includes(state.phase)?'observation_required':state.phase,
|
|
71
|
+
phase:state.phase,transport:{activeInThisBridge:!!job},uploadId:state.uploadId??null,assetId:state.assetId??null,
|
|
55
72
|
progress:{uploadedBytes:state.parts.reduce((sum,p)=>sum+p.sizeBytes,0)+(job?.progress??0),totalBytes:state.file.sizeBytes},
|
|
56
|
-
...(state.jobId?{jobId:state.jobId}:{}),...(state.errorCode?{errorCode:state.errorCode}:{}),
|
|
73
|
+
...(state.jobId?{jobId:state.jobId}:{}),...(state.pendingPart?{unconfirmedPart:state.pendingPart}:{}),...(state.errorCode?{errorCode:state.errorCode}:{}),
|
|
57
74
|
...(state.result?{result:state.result}:{}),
|
|
58
75
|
automaticReplayAllowed:false,
|
|
59
|
-
next:job?'Read status using this same key.':state.phase
|
|
76
|
+
next:job?'Read status using this same key.':terminalNext[state.phase]??(
|
|
60
77
|
state.phase==='derivatives_pending'?'Read status for the original asset validation and derivatives.':
|
|
61
|
-
'Observe status or explicitly resume/cancel this same key. Do not create a replacement upload.'});
|
|
62
|
-
async function rpc(send,transfer){
|
|
63
|
-
const response=await send(transfer);
|
|
78
|
+
'Observe status or explicitly resume/cancel this same key. Do not create a replacement upload.')});
|
|
79
|
+
async function rpc(send,transfer,options){
|
|
80
|
+
const response=await send(transfer,options);
|
|
64
81
|
const result=response?.result??response;
|
|
65
82
|
if(result?.isError){
|
|
66
83
|
let body;try{body=JSON.parse(result.content?.find(block=>block.type==='text')?.text);}catch{}
|
|
@@ -73,9 +90,10 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
|
|
|
73
90
|
return body;
|
|
74
91
|
}
|
|
75
92
|
async function observe(state,send,persist){
|
|
76
|
-
if(!state.uploadId)return
|
|
93
|
+
if(!state.uploadId)return{state,session:undefined};
|
|
77
94
|
const session=sessionCheck((await rpc(send,{action:'inspect',uploadId:state.uploadId})).session,state);
|
|
78
|
-
state.expiresAt=session.expiresAt;
|
|
95
|
+
state.expiresAt=session.expiresAt;state.lastObservedUploadState=session.state;
|
|
96
|
+
if(session.state==='uploaded_unverified'){state.phase='completion_unconfirmed';state.errorCode='creation.local_upload.completion_requires_resume';}
|
|
79
97
|
if(['aborted','expired','rejected'].includes(session.state)){state.phase=session.state;delete state.errorCode;}
|
|
80
98
|
else if(session.state==='finalized'){
|
|
81
99
|
state.jobId??=`direct-upload:${state.uploadId}`;
|
|
@@ -84,14 +102,35 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
|
|
|
84
102
|
let body;try{body=result.structuredContent??JSON.parse(result.content?.find(block=>block.type==='text')?.text);}catch{fail('control_unconfirmed');}
|
|
85
103
|
if(result.isError)fail('control_unconfirmed');
|
|
86
104
|
if(body?.success===true&&body.uploadId===state.uploadId&&body.assetId===state.assetId){
|
|
105
|
+
if(!['ready','failed','processing','derivatives_pending'].includes(body.status))fail('control_unconfirmed');
|
|
87
106
|
state.phase=body.status==='ready'?'ready':body.status==='failed'?'derivation_failed':'derivatives_pending';
|
|
88
|
-
|
|
89
|
-
|
|
107
|
+
const errorCode=body.status==='failed'?safeDerivationErrorCode(body.errorCode):undefined;
|
|
108
|
+
state.result={success:true,status:body.status,uploadId:state.uploadId,assetId:state.assetId,jobId:state.jobId,
|
|
109
|
+
...(errorCode?{errorCode}:{})};
|
|
110
|
+
if(errorCode)state.errorCode=errorCode;else delete state.errorCode;
|
|
90
111
|
}else if(body?.errorCode==='media_derivation.job_not_found'){
|
|
91
112
|
state.phase='completion_unconfirmed';state.errorCode='creation.local_upload.completion_unconfirmed';
|
|
92
113
|
}else fail('session_identity_unconfirmed');
|
|
93
114
|
}
|
|
94
|
-
if(persist)await persist();return
|
|
115
|
+
if(persist)await persist();return{state,session};
|
|
116
|
+
}
|
|
117
|
+
function assertOriginalDeadline(state){
|
|
118
|
+
if(!Number.isFinite(state.deadlineAtMs)||!Number.isFinite(Date.parse(state.expiresAt))
|
|
119
|
+
||Math.min(state.deadlineAtMs,Date.parse(state.expiresAt))<=now())fail('transfer_deadline_expired');
|
|
120
|
+
}
|
|
121
|
+
async function completeOriginal(state,session,send,binding,signal,save){
|
|
122
|
+
await binding.assertCurrent();signal?.throwIfAborted();assertOriginalDeadline(state);
|
|
123
|
+
const parts=receiptsForSession(session,state.parts,state);
|
|
124
|
+
if(parts.size!==session.partCount||state.completeKey!=='complete-'+state.key)fail('original_completion_receipts_required');
|
|
125
|
+
state.phase='completing';await save();
|
|
126
|
+
const timeout=Math.max(1,Math.min(30000,state.deadlineAtMs-now(),Date.parse(state.expiresAt)-now()));
|
|
127
|
+
const boundedSignal=AbortSignal.any([AbortSignal.timeout(timeout),...(signal?[signal]:[])]);
|
|
128
|
+
const completed=await rpc(send,{action:'complete',request:{contractVersion:wire,uploadId:state.uploadId,
|
|
129
|
+
idempotencyKey:state.completeKey,parts:state.parts}},{signal:boundedSignal,timeout});
|
|
130
|
+
assertOriginalDeadline(state);
|
|
131
|
+
sessionCheck(completed.session,state);
|
|
132
|
+
if(completed.session.state!=='finalized'||completed.jobId!==`direct-upload:${state.uploadId}`)fail('completion_unconfirmed');
|
|
133
|
+
state.jobId=completed.jobId;state.phase='derivatives_pending';delete state.errorCode;await save();
|
|
95
134
|
}
|
|
96
135
|
async function transfer(job,authorization,send,binding){
|
|
97
136
|
const {state,file,abort,save}=job;
|
|
@@ -106,6 +145,10 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
|
|
|
106
145
|
if(session.state==='finalized')break;
|
|
107
146
|
if(!['authorized','uploading'].includes(session.state))fail('session_not_transferable');
|
|
108
147
|
const parts=partReceipts(envelope,state);
|
|
148
|
+
if(state.pendingPart!==undefined){
|
|
149
|
+
if(!parts.has(state.pendingPart))fail('part_effect_unconfirmed_observe_original');
|
|
150
|
+
delete state.pendingPart;
|
|
151
|
+
}
|
|
109
152
|
state.parts=[...parts.values()].sort((a,b)=>a.partNumber-b.partNumber);await save();
|
|
110
153
|
if(parts.size===session.partCount)break;
|
|
111
154
|
if(!envelope.grants.length)fail('authorization_invalid');
|
|
@@ -115,18 +158,20 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
|
|
|
115
158
|
// Persist the attempted part before PUT. An uncertain result is never
|
|
116
159
|
// automatically sent twice; an explicit resume re-observes the store.
|
|
117
160
|
state.phase='transferring';state.pendingPart=grant.partNumber;await save();
|
|
118
|
-
|
|
161
|
+
let part;
|
|
162
|
+
try{part=await uploadGrantedPart(file,envelope,grant,{expectedUploadId:state.uploadId,expectedAssetId:state.assetId,
|
|
119
163
|
signal:abort.signal,deadlineAtMs:state.deadlineAtMs,fetch,now,onProgress:progress=>{job.progress=progress.bytesRead;}});
|
|
164
|
+
}catch(error){
|
|
165
|
+
if(readPartTransferEffect(error)==='not_dispatched'){delete state.pendingPart;await save();}
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
120
168
|
state.parts.push(part);state.parts.sort((a,b)=>a.partNumber-b.partNumber);job.progress=0;delete state.pendingPart;await save();
|
|
121
169
|
}
|
|
122
170
|
await binding.assertCurrent();abort.signal.throwIfAborted();
|
|
123
171
|
envelope=(await rpc(send,{action:'resume',uploadId:state.uploadId})).authorization;
|
|
124
172
|
}
|
|
125
173
|
await binding.assertCurrent();abort.signal.throwIfAborted();await file.assertUnchanged();
|
|
126
|
-
state.
|
|
127
|
-
const completed=await rpc(send,{action:'complete',request:{contractVersion:wire,uploadId:state.uploadId,
|
|
128
|
-
idempotencyKey:state.completeKey,parts:state.parts}});
|
|
129
|
-
sessionCheck(completed.session,state);state.jobId=completed.jobId;state.phase='derivatives_pending';delete state.errorCode;await save();
|
|
174
|
+
await completeOriginal(state,envelope.session,send,binding,abort.signal,save);
|
|
130
175
|
}
|
|
131
176
|
async function callCore({input,scope,send,binding,signal}){
|
|
132
177
|
if(closing)fail('bridge_closing');
|
|
@@ -156,7 +201,7 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
|
|
|
156
201
|
state=await persistence.read(key)??state;
|
|
157
202
|
if(input.action==='cancel'){
|
|
158
203
|
if(['ready','derivatives_pending','derivation_failed'].includes(state.phase))
|
|
159
|
-
return view(await observe(state,send,()=>persistence.write(key,state)));
|
|
204
|
+
return view((await observe(state,send,()=>persistence.write(key,state))).state);
|
|
160
205
|
if(!state.uploadId)fail('create_unconfirmed_observe_original_key');
|
|
161
206
|
state.phase='cancelling';await persistence.write(key,state);
|
|
162
207
|
const result=await rpc(send,{action:'abort',request:{contractVersion:wire,uploadId:state.uploadId,
|
|
@@ -164,7 +209,26 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
|
|
|
164
209
|
sessionCheck(result.session,state);state.phase=result.session.state;delete state.errorCode;
|
|
165
210
|
await persistence.write(key,state);return view(state);
|
|
166
211
|
}
|
|
167
|
-
if(state&&terminal.has(state.phase))return view(await observe(state,send,()=>persistence.write(key,state)));
|
|
212
|
+
if(state&&terminal.has(state.phase))return view((await observe(state,send,()=>persistence.write(key,state))).state);
|
|
213
|
+
if(state?.uploadId){
|
|
214
|
+
const observed=await observe(state,send,()=>persistence.write(key,state));
|
|
215
|
+
if(terminal.has(state.phase)||state.phase==='derivatives_pending'||state.phase==='derivation_failed')return view(state);
|
|
216
|
+
if(['uploaded_unverified','finalized'].includes(observed.session.state)){
|
|
217
|
+
if(input.action!=='resume')return view(state);
|
|
218
|
+
// Explicit recovery reuses the original complete request. A read
|
|
219
|
+
// never enqueues, and a completed multipart is never resumed or PUT.
|
|
220
|
+
assertOriginalDeadline(state);
|
|
221
|
+
if(input.filePath!==undefined){
|
|
222
|
+
if(typeof input.filePath!=='string'||input.filePath.length>4096)fail('file_selection_required');
|
|
223
|
+
file=await openLocalUploadFile(input.filePath,{signal,deadlineAtMs:state.deadlineAtMs,now});
|
|
224
|
+
if(JSON.stringify(state.file.fingerprint)!==JSON.stringify(file.fingerprint)||state.file.name!==file.name)fail('file_changed');
|
|
225
|
+
}
|
|
226
|
+
if(input.assetKind!==undefined&&input.assetKind!==state.request.assetKind
|
|
227
|
+
||input.mimeType!==undefined&&input.mimeType!==state.request.mimeType)fail('file_changed');
|
|
228
|
+
await completeOriginal(state,observed.session,send,binding,signal,()=>persistence.write(key,state));
|
|
229
|
+
return view(state);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
168
232
|
if(typeof input.filePath!=='string'||input.filePath.length>4096)fail('file_selection_required');
|
|
169
233
|
const startedAtMs=state?.startedAtMs??now(),deadlineAtMs=state?.deadlineAtMs??startedAtMs+600_000;
|
|
170
234
|
file=await openLocalUploadFile(input.filePath,{signal,deadlineAtMs,now});
|
|
@@ -191,8 +255,6 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
|
|
|
191
255
|
state.uploadId=session.uploadId;state.assetId=session.assetId;sessionCheck(session,state);
|
|
192
256
|
state.expiresAt=session.expiresAt;await persistence.write(key,state);
|
|
193
257
|
}else{
|
|
194
|
-
await observe(state,send,()=>persistence.write(key,state));
|
|
195
|
-
if(terminal.has(state.phase)||state.phase==='derivatives_pending'||state.phase==='derivation_failed')return view(state);
|
|
196
258
|
authorization=(await rpc(send,{action:'resume',uploadId:state.uploadId})).authorization;
|
|
197
259
|
}
|
|
198
260
|
signal?.throwIfAborted();
|
|
@@ -200,7 +262,7 @@ export function createLocalUploadManager({stateRoot,fetch=globalThis.fetch,now=D
|
|
|
200
262
|
jobs.set(key,job);file=undefined;
|
|
201
263
|
// The accepted ID is returned before multipart work. Closing this bridge
|
|
202
264
|
// cancels and joins only this transport; the platform keeps its session.
|
|
203
|
-
job.done=Promise.resolve().then(()=>transfer(job,authorization,(transfer)=>send(transfer,{signal:abort.signal}),binding)).catch(async error=>{
|
|
265
|
+
job.done=Promise.resolve().then(()=>transfer(job,authorization,(transfer,options)=>send(transfer,{signal:abort.signal,...options}),binding)).catch(async error=>{
|
|
204
266
|
state.phase='paused';state.errorCode=abort.signal.aborted?'creation.local_upload.transfer_cancelled':knownError(error);
|
|
205
267
|
await job.save();
|
|
206
268
|
}).finally(async()=>{try{await job.file.close();}finally{try{await release();}finally{jobs.delete(key);}}});
|
package/lib/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const CLIENT_VERSION = "0.3.
|
|
1
|
+
export const CLIENT_VERSION = "0.3.6";
|
|
2
2
|
export const CLIENT_PROTOCOL = "creation-client/v1";
|
package/package.json
CHANGED
|
@@ -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.
|
|
13
|
+
在用户本机终端运行 `npx --yes @promptframe/creation@0.3.6 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.
|
|
17
|
+
Claude Code 使用 `npx --yes @promptframe/creation@0.3.6 connect --host claude-code --endpoint <Studio提供的API地址>`。桌面版远程连接 WSL 时,在该 WSL 执行;保留相同 profile 和有效凭据。
|
|
18
18
|
<!-- /creation-install-command -->
|
|
19
19
|
|
|
20
20
|
命令会复用并验证有效凭据。首次授权或明确更换已失效凭据时,由用户在 Studio 登录并在终端的不回显输入框提供 Token;不要要求用户把 Token 粘进聊天,也不要把它写进命令参数、URL或日志。网络失败不等于授权失效,不自动轮换或覆盖凭据。
|