dsh-plugin-opc 0.1.34 → 0.1.36
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/lib/client.js +526 -28
- package/lib/index.js +87 -76
- package/package.json +1 -1
- package/runtime/app_delivery/SKILL.md +21 -26
- package/runtime/app_delivery/references/contract.md +2 -1
- package/runtime/app_delivery/scripts/delivery.py +8 -1
- package/runtime/app_delivery_admin.py +3 -1
- package/runtime/app_delivery_auth.py +23 -12
- package/runtime/worker.py +15 -6
package/lib/index.js
CHANGED
|
@@ -2478,6 +2478,7 @@ function checkPublishReceipt(job, receipt) {
|
|
|
2478
2478
|
if (receipt.app_tar_sha256 && receipt.app_tar_sha256 !== job.hashes?.["app.tar"] || receipt.skill_zip_sha256 && receipt.skill_zip_sha256 !== job.hashes?.["skill.zip"]) {
|
|
2479
2479
|
throw new Error("\u53D1\u5E03\u56DE\u6267\u5236\u54C1\u6458\u8981\u4E0D\u4E00\u81F4");
|
|
2480
2480
|
}
|
|
2481
|
+
if (Object.hasOwn(receipt, "published_version") && (!Number.isSafeInteger(receipt.published_version) || receipt.published_version < 0 || receipt.status === "running" && receipt.published_version !== receipt.version)) throw new Error("\u53D1\u5E03\u56DE\u6267\u6B63\u5F0F\u7248\u672C\u65E0\u6548");
|
|
2481
2482
|
if (["accepted", "building", "running", "failed"].includes(receipt.status) && (!Number.isSafeInteger(receipt.version) || receipt.version < 1)) throw new Error("\u53D1\u5E03\u56DE\u6267\u7F3A\u5C11\u6709\u6548\u7248\u672C");
|
|
2482
2483
|
}
|
|
2483
2484
|
function verificationCredentialFields(contract) {
|
|
@@ -2657,6 +2658,7 @@ var AppDelivery = class {
|
|
|
2657
2658
|
busy = /* @__PURE__ */ new Set();
|
|
2658
2659
|
analyses = /* @__PURE__ */ new Map();
|
|
2659
2660
|
adminReplies = /* @__PURE__ */ new Map();
|
|
2661
|
+
preparedProposals = /* @__PURE__ */ new Map();
|
|
2660
2662
|
analyze;
|
|
2661
2663
|
getOptions() {
|
|
2662
2664
|
return { ...this.options };
|
|
@@ -2766,6 +2768,22 @@ ${combinedLog}` : combinedLog).slice(-24e3);
|
|
|
2766
2768
|
});
|
|
2767
2769
|
}
|
|
2768
2770
|
}
|
|
2771
|
+
async applyPublishReceipt(scopeDir, root, job, receipt) {
|
|
2772
|
+
checkPublishReceipt(job, receipt);
|
|
2773
|
+
if (!["accepted", "building", "running", "failed"].includes(receipt.status)) return false;
|
|
2774
|
+
job.published = true;
|
|
2775
|
+
job.version = Object.hasOwn(receipt, "published_version") ? receipt.published_version || void 0 : receipt.version;
|
|
2776
|
+
if (receipt.status === "failed") {
|
|
2777
|
+
this.recordFailureState(job, receipt.error_message || "\u90E8\u7F72\u5931\u8D25", receipt.build_log?.slice(-8e3), job.version);
|
|
2778
|
+
} else {
|
|
2779
|
+
job.status = "building";
|
|
2780
|
+
job.error = void 0;
|
|
2781
|
+
if (job.revision && job.version) {
|
|
2782
|
+
await this.archivePublishedVersion(scopeDir, job, join3(root, job.revision, "bundle"));
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
return true;
|
|
2786
|
+
}
|
|
2769
2787
|
async demoteOtherJobsForSlug(scopeDir, slug, activeJobId) {
|
|
2770
2788
|
for (const parent of await this.directories(scopeDir)) {
|
|
2771
2789
|
const entries = await readdir2(parent).catch(() => []);
|
|
@@ -2809,25 +2827,13 @@ ${combinedLog}` : combinedLog).slice(-24e3);
|
|
|
2809
2827
|
if (!this.busy.has(id) && latestJob.job.status === job.status && latestJob.job.requestId === job.requestId) {
|
|
2810
2828
|
job = latestJob.job;
|
|
2811
2829
|
try {
|
|
2812
|
-
if (job.status === "unknown"
|
|
2830
|
+
if (job.requestId && (job.status === "unknown" || !job.version)) {
|
|
2813
2831
|
const receipt = await this.platform(`/${job.slug}/requests/${job.requestId}`, expected);
|
|
2814
|
-
|
|
2815
|
-
if (["accepted", "building", "running", "failed"].includes(receipt.status) && !this.busy.has(id)) {
|
|
2832
|
+
if ((job.status === "unknown" || ["running", "failed"].includes(receipt.status)) && !this.busy.has(id)) {
|
|
2816
2833
|
await this.exclusive(id, async () => {
|
|
2817
2834
|
job = (await this.open(scope.directory, id)).job;
|
|
2818
|
-
if (job.status !==
|
|
2819
|
-
job.
|
|
2820
|
-
job.version = receipt.version;
|
|
2821
|
-
if (receipt.status === "failed") {
|
|
2822
|
-
this.recordFailureState(job, receipt.error_message || "\u90E8\u7F72\u5931\u8D25", receipt.build_log?.slice(-8e3), job.version);
|
|
2823
|
-
} else {
|
|
2824
|
-
job.status = "building";
|
|
2825
|
-
job.error = void 0;
|
|
2826
|
-
if (job.revision && job.version) {
|
|
2827
|
-
await this.archivePublishedVersion(scope.directory, job, join3(root, job.revision, "bundle"));
|
|
2828
|
-
}
|
|
2829
|
-
}
|
|
2830
|
-
await this.save(root, job);
|
|
2835
|
+
if (job.status !== latestJob.job.status || job.requestId !== latestJob.job.requestId || job.version !== latestJob.job.version) return;
|
|
2836
|
+
if (await this.applyPublishReceipt(scope.directory, root, job, receipt)) await this.save(root, job);
|
|
2831
2837
|
});
|
|
2832
2838
|
}
|
|
2833
2839
|
}
|
|
@@ -3073,7 +3079,7 @@ ${combinedLog}` : combinedLog).slice(-24e3);
|
|
|
3073
3079
|
if (!targetDesc && typeof existing.description === "string") {
|
|
3074
3080
|
targetDesc = existing.description;
|
|
3075
3081
|
}
|
|
3076
|
-
defaultVersionNote =
|
|
3082
|
+
defaultVersionNote = "\u5E94\u7528\u5347\u7EA7";
|
|
3077
3083
|
} else {
|
|
3078
3084
|
const reserved = await this.checkSlug(input.slug, expected);
|
|
3079
3085
|
if (!reserved.available) throw new Error("\u5E94\u7528\u6807\u8BC6\u5DF2\u88AB\u4F7F\u7528\uFF0C\u8BF7\u6362\u4E00\u4E2A\u6807\u8BC6\uFF1B\u82E5\u9700\u5347\u7EA7\u5DF2\u6709\u5E94\u7528\u8BF7\u9009\u62E9\u5347\u7EA7");
|
|
@@ -3301,6 +3307,10 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
3301
3307
|
try {
|
|
3302
3308
|
await this.save(root, job);
|
|
3303
3309
|
} finally {
|
|
3310
|
+
const unused = this.preparedProposals.get(id);
|
|
3311
|
+
this.preparedProposals.delete(id);
|
|
3312
|
+
if (unused) await rm2(join3(root, unused.revision), { recursive: true, force: true }).catch(() => {
|
|
3313
|
+
});
|
|
3304
3314
|
if (job.status !== "review" || !job.proposal?.adminAccountPending) this.adminReplies.delete(id);
|
|
3305
3315
|
this.analyses.delete(id);
|
|
3306
3316
|
this.busy.delete(id);
|
|
@@ -3314,6 +3324,20 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
3314
3324
|
if (job.status !== "analyzing" && job.status !== "review") throw new Error("\u5F53\u524D\u5E94\u7528\u51C6\u5907\u9636\u6BB5\u65E0\u6CD5\u63A5\u6536\u56DE\u590D");
|
|
3315
3325
|
const account = job.proposal?.contract?.admin_account;
|
|
3316
3326
|
const adminReply = job.proposal?.adminAccountPending && account ? readAdminReply(account, text3) : void 0;
|
|
3327
|
+
const proposalWithAccount = adminReply && job.proposal ? { ...job.proposal, adminAccountPending: false } : void 0;
|
|
3328
|
+
if (job.status === "review" && adminReply && proposalWithAccount && !analysisQuestions(proposalWithAccount).length) {
|
|
3329
|
+
const next2 = {
|
|
3330
|
+
...job,
|
|
3331
|
+
proposal: proposalWithAccount,
|
|
3332
|
+
analysisFailure: void 0,
|
|
3333
|
+
events: [...job.events, "\u5DF2\u6536\u5230\u7BA1\u7406\u5458\u8D26\u5BC6\uFF0C\u7EE7\u7EED\u751F\u6210\u4EA4\u4ED8\u5305"]
|
|
3334
|
+
};
|
|
3335
|
+
signal.throwIfAborted();
|
|
3336
|
+
await this.save(root, { ...next2, proposal: job.proposal });
|
|
3337
|
+
this.adminReplies.set(job.id, adminReply);
|
|
3338
|
+
Object.assign(job, next2);
|
|
3339
|
+
return "";
|
|
3340
|
+
}
|
|
3317
3341
|
const reply = adminReply ? "\u7528\u6237\u5DF2\u7ECF\u5728\u5F53\u524D\u5BF9\u8BDD\u63D0\u4F9B\u7BA1\u7406\u5458\u8D26\u53F7\u548C\u5BC6\u7801\u3002\u4FDD\u7559\u4E0A\u4E00\u7248 admin_account \u8BA4\u8BC1\u65B9\u6848\u4E0E\u5B9E\u9645\u5B58\u50A8\u4F4D\u7F6E\u5E76\u91CD\u65B0\u63D0\u4EA4\uFF0COPC \u4F1A\u628A\u8D26\u5BC6\u5199\u5165\u5E94\u7528\u548C\u6280\u80FD\u3002" : await worker({ action: "redact_feedback", root, text: text3.slice(0, 2e4) }, signal);
|
|
3318
3342
|
signal.throwIfAborted();
|
|
3319
3343
|
const next = {
|
|
@@ -3454,7 +3478,7 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
3454
3478
|
feedback: job.feedbackHistory ?? ""
|
|
3455
3479
|
} }, scope.signal);
|
|
3456
3480
|
}
|
|
3457
|
-
async submit(job, root, proposal, signal) {
|
|
3481
|
+
async submit(job, root, proposal, signal, options) {
|
|
3458
3482
|
if (proposal.contract?.slug !== job.slug || proposal.contract?.base_url !== job.url) throw new Error("\u5E94\u7528\u6807\u8BC6\u6216\u5730\u5740\u4E0E\u5BFC\u5165\u65F6\u4E0D\u4E00\u81F4");
|
|
3459
3483
|
if (job.status !== "analyzing") throw new Error("\u672C\u8F6E\u5DF2\u63D0\u4EA4\u65B9\u6848");
|
|
3460
3484
|
if (!Array.isArray(proposal.unresolved) || proposal.contract.unresolved !== void 0 && !Array.isArray(proposal.contract.unresolved)) {
|
|
@@ -3482,11 +3506,15 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
3482
3506
|
}
|
|
3483
3507
|
if (!job.portAuto && actualPort !== expectedPort) throw new Error(`${field} \u586B\u4E86 ${actualPort}\uFF0C\u4E0E\u5DF2\u9501\u5B9A\u7684\u5BB9\u5668\u7AEF\u53E3 ${expectedPort} \u4E0D\u4E00\u81F4\u3002\u6A21\u578B\u4E0D\u80FD\u9759\u9ED8\u6539\u53D8\u7528\u6237\u9009\u62E9\u7684\u5BB9\u5668\u7AEF\u53E3`);
|
|
3484
3508
|
}
|
|
3509
|
+
const allowUnresolved = hasQuestions || adminAccountPending;
|
|
3510
|
+
const preparedRevision = options?.dockerfileOnly && !allowUnresolved ? randomUUID4().replaceAll("-", "") : void 0;
|
|
3485
3511
|
const validated = await worker({
|
|
3486
|
-
action: "validate",
|
|
3512
|
+
action: preparedRevision ? "bundle" : "validate",
|
|
3513
|
+
revision: preparedRevision,
|
|
3487
3514
|
root,
|
|
3488
3515
|
proposal,
|
|
3489
|
-
allow_unresolved:
|
|
3516
|
+
allow_unresolved: allowUnresolved,
|
|
3517
|
+
dockerfile_only: options?.dockerfileOnly === true,
|
|
3490
3518
|
reuse_source_admin: !job.upgrade && !job.published && !adminReply && !canReusePrevious,
|
|
3491
3519
|
admin_reply: adminReply,
|
|
3492
3520
|
previous_skill_markdown: canReusePrevious ? job.skillMarkdown : void 0,
|
|
@@ -3496,7 +3524,14 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
3496
3524
|
revision_count: job.revisionCount ?? 1,
|
|
3497
3525
|
feedback: job.feedbackHistory ?? "",
|
|
3498
3526
|
expected_port: job.portAuto ? null : job.port ?? 8080
|
|
3499
|
-
}, signal)
|
|
3527
|
+
}, signal).catch(async (error) => {
|
|
3528
|
+
if (preparedRevision) await rm2(join3(root, preparedRevision), { recursive: true, force: true }).catch(() => {
|
|
3529
|
+
});
|
|
3530
|
+
throw error;
|
|
3531
|
+
});
|
|
3532
|
+
if (preparedRevision) {
|
|
3533
|
+
this.preparedProposals.set(job.id, { revision: preparedRevision, proposalHash: fingerprint(validated.proposal), result: validated });
|
|
3534
|
+
}
|
|
3500
3535
|
signal.throwIfAborted();
|
|
3501
3536
|
if (job.status !== "analyzing") throw new Error("\u672C\u8F6E\u5DF2\u63D0\u4EA4\u65B9\u6848");
|
|
3502
3537
|
job.proposal = validated?.proposal ?? proposal;
|
|
@@ -3535,8 +3570,10 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
3535
3570
|
job.events.push("\u6B63\u5728\u751F\u6210\u5E76\u68C0\u67E5\u4EA4\u4ED8\u5305");
|
|
3536
3571
|
await this.save(root, job);
|
|
3537
3572
|
try {
|
|
3538
|
-
const
|
|
3539
|
-
const
|
|
3573
|
+
const prepared = this.preparedProposals.get(job.id);
|
|
3574
|
+
const reusable = prepared && prepared.proposalHash === fingerprint(job.proposal) ? prepared : void 0;
|
|
3575
|
+
const revision = reusable?.revision ?? randomUUID4().replaceAll("-", "");
|
|
3576
|
+
const result = reusable?.result ?? await worker({
|
|
3540
3577
|
action: "bundle",
|
|
3541
3578
|
root,
|
|
3542
3579
|
revision,
|
|
@@ -3552,6 +3589,7 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
3552
3589
|
}, signal);
|
|
3553
3590
|
signal.throwIfAborted();
|
|
3554
3591
|
assertCurrent();
|
|
3592
|
+
if (reusable) this.preparedProposals.delete(job.id);
|
|
3555
3593
|
job.revision = revision;
|
|
3556
3594
|
job.hashes = result.summary.files;
|
|
3557
3595
|
job.proposal = result.proposal ?? job.proposal;
|
|
@@ -3749,14 +3787,9 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
3749
3787
|
this.core.emit("skills-changed");
|
|
3750
3788
|
try {
|
|
3751
3789
|
const result = await this.platform("/publish", expected, { form });
|
|
3752
|
-
checkPublishReceipt(job, result);
|
|
3753
3790
|
if (result.app_url !== job.url) throw new Error("\u5E73\u53F0\u8FD4\u56DE\u5730\u5740\u4E0E\u786E\u8BA4\u5730\u5740\u4E0D\u540C");
|
|
3754
|
-
|
|
3755
|
-
job.
|
|
3756
|
-
if (result.status === "failed") this.recordFailureState(job, result.error_message || "\u90E8\u7F72\u5931\u8D25", result.build_log?.slice(-8e3), job.version);
|
|
3757
|
-
else job.status = "building";
|
|
3758
|
-
await this.archivePublishedVersion(scope.directory, job, folder);
|
|
3759
|
-
job.events.push(`\u5DF2\u4E0A\u4F20\u7ECF\u8FC7\u786E\u8BA4\u7684\u540C\u4E00\u4EA4\u4ED8\u5305 (v${job.version})\uFF0C\u7B49\u5F85\u670D\u52A1\u5668\u6784\u5EFA\u4E0E\u4E1A\u52A1\u9A8C\u8BC1`);
|
|
3791
|
+
if (!await this.applyPublishReceipt(scope.directory, root, job, result)) throw new Error("\u5E73\u53F0\u5C1A\u672A\u786E\u8BA4\u53D1\u5E03\u8BF7\u6C42");
|
|
3792
|
+
job.events.push("\u5DF2\u4E0A\u4F20\u7ECF\u8FC7\u786E\u8BA4\u7684\u540C\u4E00\u4EA4\u4ED8\u5305\uFF0C\u7B49\u5F85\u670D\u52A1\u5668\u6784\u5EFA\u4E0E\u4E1A\u52A1\u9A8C\u8BC1");
|
|
3760
3793
|
} catch (error) {
|
|
3761
3794
|
if (error instanceof AppRequestError && [400, 401, 403, 404, 409, 413, 422].includes(error.status)) {
|
|
3762
3795
|
job.status = "ready";
|
|
@@ -3765,21 +3798,9 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
3765
3798
|
let reconciled = false;
|
|
3766
3799
|
try {
|
|
3767
3800
|
const reqState = await this.platform(`/${job.slug}/requests/${requestId}`, expected);
|
|
3768
|
-
|
|
3769
|
-
if (reqState.status
|
|
3770
|
-
job.published = true;
|
|
3771
|
-
job.version = reqState.version;
|
|
3772
|
-
this.recordFailureState(job, reqState.error_message || "\u90E8\u7F72\u5931\u8D25", reqState.build_log?.slice(-8e3), reqState.version);
|
|
3773
|
-
reconciled = true;
|
|
3774
|
-
} else if (["accepted", "building", "running"].includes(reqState.status)) {
|
|
3775
|
-
if (reqState.app_url && reqState.app_url !== job.url) throw new Error("\u5E73\u53F0\u8FD4\u56DE\u5730\u5740\u4E0E\u786E\u8BA4\u5730\u5740\u4E0D\u540C");
|
|
3776
|
-
job.published = true;
|
|
3777
|
-
job.version = reqState.version ?? 1;
|
|
3778
|
-
job.status = "building";
|
|
3779
|
-
job.error = void 0;
|
|
3780
|
-
await this.archivePublishedVersion(scope.directory, job, folder);
|
|
3801
|
+
reconciled = await this.applyPublishReceipt(scope.directory, root, job, reqState);
|
|
3802
|
+
if (reconciled && reqState.status !== "failed") {
|
|
3781
3803
|
job.events.push("\u4E0A\u4F20\u8FDE\u63A5\u4E2D\u65AD\u540E\u5DF2\u901A\u8FC7\u5E42\u7B49\u8BF7\u6C42\u53F7\u6838\u5B9E\u5E73\u53F0\u63A5\u6536\u72B6\u6001");
|
|
3782
|
-
reconciled = true;
|
|
3783
3804
|
}
|
|
3784
3805
|
} catch {
|
|
3785
3806
|
}
|
|
@@ -3807,23 +3828,12 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
3807
3828
|
return view2;
|
|
3808
3829
|
}
|
|
3809
3830
|
if (!["building", "unknown", "awaiting_page_verification", "verified", "failed", "publishing", "verifying"].includes(job.status) || !job.hashes || !job.proposal) throw new Error("\u5E94\u7528\u5C1A\u672A\u53D1\u5E03");
|
|
3810
|
-
if (job.status === "unknown" || job.status === "publishing") {
|
|
3831
|
+
if (job.status === "unknown" || job.status === "publishing" || job.status === "building" && !job.version && job.requestId) {
|
|
3811
3832
|
if (!job.requestId) throw new Error("\u7F3A\u5C11\u4E0A\u6B21\u53D1\u5E03\u8BF7\u6C42\u53F7\uFF0C\u65E0\u6CD5\u6838\u5BF9\u7ED3\u679C");
|
|
3812
3833
|
const receipt = await this.platform(`/${job.slug}/requests/${job.requestId}`, expected);
|
|
3813
|
-
|
|
3814
|
-
if (receipt.status === "failed") {
|
|
3815
|
-
job.version = receipt.version;
|
|
3816
|
-
job.published = true;
|
|
3817
|
-
this.recordFailureState(job, receipt.error_message || "\u90E8\u7F72\u5931\u8D25", receipt.build_log?.slice(-8e3), job.version);
|
|
3818
|
-
await this.save(root, job);
|
|
3819
|
-
return this.public(job, root);
|
|
3820
|
-
}
|
|
3821
|
-
if (!["accepted", "building", "running"].includes(receipt.status)) return this.public(job, root);
|
|
3822
|
-
job.published = true;
|
|
3823
|
-
job.version = receipt.version;
|
|
3824
|
-
job.status = "building";
|
|
3825
|
-
if (job.revision) await this.archivePublishedVersion(scope.directory, job, join3(root, job.revision, "bundle"));
|
|
3834
|
+
if (!await this.applyPublishReceipt(scope.directory, root, job, receipt)) return this.public(job, root);
|
|
3826
3835
|
await this.save(root, job);
|
|
3836
|
+
if (receipt.status === "failed" || !job.version) return this.public(job, root);
|
|
3827
3837
|
}
|
|
3828
3838
|
const contract = job.proposal.contract;
|
|
3829
3839
|
const supplied = {};
|
|
@@ -4418,7 +4428,7 @@ function proposalParameters(port, portLocked = true) {
|
|
|
4418
4428
|
impact: text2,
|
|
4419
4429
|
recommendation: text2
|
|
4420
4430
|
} } },
|
|
4421
|
-
unresolved: { ...strings, description: "\
|
|
4431
|
+
unresolved: { ...strings, description: "\u4EC5\u586B\u5199\u5FC5\u987B\u7531\u7528\u6237\u5904\u7406\u7684\u90E8\u7F72\u963B\u585E\u3002\u9274\u6743\u963B\u585E\u9879\u4E0E contract.auth_blockers \u7684 question \u4FDD\u6301\u4E00\u81F4\u3002\u7BA1\u7406\u5458\u8D26\u5BC6\u4F7F\u7528 admin_account\u3002" },
|
|
4422
4432
|
changes: { ...objects, items: { ...object2, properties: {
|
|
4423
4433
|
id: text2,
|
|
4424
4434
|
path: text2,
|
|
@@ -4443,7 +4453,7 @@ function proposalParameters(port, portLocked = true) {
|
|
|
4443
4453
|
}
|
|
4444
4454
|
} },
|
|
4445
4455
|
build_context: { ...strings, required: true },
|
|
4446
|
-
health: { ...object2,
|
|
4456
|
+
health: { ...object2, description: "\u53EF\u9009\u3002\u4EC5\u7528\u4E8E\u6807\u8BC6\u6E90\u7801\u5DF2\u6709\u7684\u5065\u5EB7\u5165\u53E3\uFF0C\u4E1A\u52A1\u9A8C\u8BC1\u4E0D\u5F97\u4F7F\u7528\u8BE5\u5165\u53E3\u3002\u6CA1\u6709\u5219\u7701\u7565\u3002", properties: { path: text2, status: { type: "integer" }, json_contains: object2 } },
|
|
4447
4457
|
configs: { ...objects, description: '\u4EC5\u586B\u5199\u6E90\u7801\u771F\u5B9E\u5B58\u5728\u7684\u914D\u7F6E\u952E\uFF08\u53C2\u8003 inventory.source_configuration\uFF09\uFF1Bdefault \u5FC5\u987B\u4E3A\u7A7A\u5B57\u7B26\u4E32 ""\uFF1Bsource \u4EC5\u652F\u6301 YAML/JSON/TOML/.env/properties \u6587\u4EF6\uFF0C\u4E0D\u652F\u6301\u4EE3\u7801\u6587\u4EF6\uFF1B\u4E0D\u8981\u5C06 *.example/*.sample/*.template \u793A\u4F8B\u6587\u4EF6\u91CC\u7684 PORT \u6216\u5360\u4F4D\u5BC6\u94A5\u4F5C\u4E3A\u771F\u5B9E\u8FD0\u884C\u503C\u7ED1\u5B9A\uFF1B\u5982\u5E94\u7528\u5B58\u5728\u4EE3\u7801\u515C\u5E95\u9ED8\u8BA4\u503C\uFF08\u4EC5\u975E\u654F\u611F\uFF09\uFF0C\u53EF\u5199\u5165 app_default \u4F9B\u7B2C 3 \u6B65\u53C2\u8003\u5C55\u793A', items: { ...object2, properties: {
|
|
4448
4458
|
key: text2,
|
|
4449
4459
|
default: text2,
|
|
@@ -4465,7 +4475,7 @@ function proposalParameters(port, portLocked = true) {
|
|
|
4465
4475
|
login_method: str,
|
|
4466
4476
|
token_json_path: str
|
|
4467
4477
|
} },
|
|
4468
|
-
auth_profiles: { ...object2, description: '\u6309 ID \u4FDD\u5B58\u767B\u5F55\u65B9\u5F0F\u3002\u4F8B\uFF1A{"account":{"login_url":"/api/session","login_method":"POST","username_env":"APP_USER","password_env":"APP_PASSWORD"}}\u3002profile ID \u53EA\u51FA\u73B0\u4E00\u5C42\uFF0C\u63A5\u53E3\u901A\u8FC7 auth.profile \u5F15\u7528\u3002' },
|
|
4478
|
+
auth_profiles: { ...object2, description: '\u6309 ID \u4FDD\u5B58\u767B\u5F55\u65B9\u5F0F\u3002\u4F8B\uFF1A{"account":{"login_url":"/api/session","login_method":"POST","username_env":"APP_USER","password_env":"APP_PASSWORD"}}\u3002profile ID \u53EA\u51FA\u73B0\u4E00\u5C42\uFF0C\u63A5\u53E3\u901A\u8FC7 auth.profile \u5F15\u7528\u3002\u975E\u6807\u51C6\u767B\u5F55\u5B57\u6BB5\u7528 login_body_template\uFF0C\u4EC5\u5141\u8BB8\u8D26\u53F7\u548C\u5BC6\u7801\u5360\u4F4D\u7B26\u3002' },
|
|
4469
4479
|
admin_account: { ...object2, description: "\u6309\u5E94\u7528\u6E90\u7801\u8BC1\u636E\u9009\u62E9 existing \u6216 create\u3002\u4EC5\u63CF\u8FF0\u8D26\u53F7\u6765\u6E90\u6216\u5199\u5165\u4F4D\u7F6E\uFF0C\u4E0D\u63D0\u4EA4\u5B9E\u9645\u8D26\u5BC6\u3002", properties: {
|
|
4470
4480
|
mode: { ...text2, enum: ["existing", "create"] },
|
|
4471
4481
|
profile: text2,
|
|
@@ -4473,12 +4483,12 @@ function proposalParameters(port, portLocked = true) {
|
|
|
4473
4483
|
source: { ...object2, description: "\u4E3A\u5DF2\u6709\u53EF\u590D\u7528\u8D26\u5BC6\u63D0\u4F9B {username,password} \u5F15\u7528\uFF1A\u7ED3\u6784\u5316\u914D\u7F6E {path,keys}\u3001\u6E90\u7801 {path,line,name} \u6216 SQLite \u660E\u6587\u5B57\u6BB5 {path,table,column,where}\u3002\u6E90\u7801 name \u586B\u5B57\u6BB5\u540D\uFF08\u5982 username\u3001passwordHash\uFF09\uFF0Cline \u586B\u5B9A\u4E49\u8BE5\u5B57\u6BB5\u7684\u884C\u53F7\uFF0C\u7981\u6B62\u586B\u771F\u5B9E\u5BC6\u7801\u3002\u53EA\u6709\u6E90\u7801\u548C\u771F\u5B9E\u914D\u7F6E\u5747\u7F3A\u5C11\u53EF\u590D\u7528\u8D26\u5BC6\u65F6\u624D\u7701\u7565 source\u3002" },
|
|
4474
4484
|
storage: { ...object2, description: "\u9996\u6B21\u5EFA\u53F7\u4EC5\u5728\u4EA4\u4ED8\u526F\u672C\u4E2D\u5199\u5165\u5E94\u7528\u771F\u6B63\u8BFB\u53D6\u7684 SQLite \u6216 JSON/YAML \u6587\u4EF6\uFF0C\u5177\u4F53\u7ED3\u6784\u89C1 references/contract.md\u3002" }
|
|
4475
4485
|
} },
|
|
4476
|
-
auth_rules: { ...objects, description:
|
|
4486
|
+
auth_rules: { ...objects, description: "\u5171\u7528\u9274\u6743\u5199\u4E00\u6761 prefix \u89C4\u5219\uFF1B\u516C\u5F00\u767B\u5F55\u7B49\u4F8B\u5916\u7528 path \u548C method\u3002\u767B\u5F55\u65B9\u5F0F\u5199\u5728\u53D7\u4FDD\u62A4\u89C4\u5219\u7684 auth.profile\uFF0C\u4E0D\u80FD\u53EA\u5199\u5728\u516C\u5F00\u767B\u5F55\u63A5\u53E3\u4E0A\u3002evidence \u5728\u89C4\u5219\u9876\u5C42\u3002", items: { ...object2, properties: {
|
|
4477
4487
|
target: { ...text2, enum: ["api", "page"] },
|
|
4478
4488
|
path: str,
|
|
4479
4489
|
prefix: str,
|
|
4480
4490
|
method: str,
|
|
4481
|
-
auth: { ...object2, required: true, properties: { type: { ...text2, enum: ["none", "header", "bearer"] } } },
|
|
4491
|
+
auth: { ...object2, required: true, properties: { type: { ...text2, enum: ["none", "header", "bearer"] }, profile: str, header: str, env: str } },
|
|
4482
4492
|
evidence: { ...strings, required: true, description: '\u8BFB\u53D6\u5DE5\u5177\u8FD4\u56DE\u7684\u6E90\u7801\u4F4D\u7F6E\u6570\u7EC4\uFF0C\u4F8B\u5982 ["server.mjs:42"]' }
|
|
4483
4493
|
} } },
|
|
4484
4494
|
auth_blockers: { ...objects, description: "\u53EA\u586B\u786E\u5B9E\u963B\u585E\u6539\u9020\u7684\u5916\u90E8\u6388\u6743\u6216\u89D2\u8272\u51B3\u5B9A\uFF1B\u7BA1\u7406\u5458\u767B\u5F55\u901A\u8FC7 admin_account \u5904\u7406", items: { ...object2, properties: {
|
|
@@ -4499,15 +4509,15 @@ function proposalParameters(port, portLocked = true) {
|
|
|
4499
4509
|
responses: { ...object2, required: true },
|
|
4500
4510
|
auth: { ...routeAuth, required: true },
|
|
4501
4511
|
effect: { ...text2, enum: ["read", "write", "destructive", "external"] },
|
|
4502
|
-
confirmation_required: { ...bool, required: true }
|
|
4512
|
+
confirmation_required: { ...bool, required: true, description: "effect \u4E3A write\u3001destructive \u6216 external \u65F6\u5FC5\u987B\u4E3A true" }
|
|
4503
4513
|
} } },
|
|
4504
4514
|
pages: {
|
|
4505
4515
|
...objects,
|
|
4506
4516
|
description: "\u626B\u63CF\u7ED3\u679C\u7531\u63D2\u4EF6\u5408\u5E76\uFF0C\u53EF\u4EE5\u4F20 [] \u6216\u53EA\u8865\u5145\u9700\u8981\u5B9A\u5236\u7684\u9875\u9762",
|
|
4507
4517
|
items: { ...object2, properties: { auth: routeAuth } }
|
|
4508
4518
|
},
|
|
4509
|
-
verification: object2,
|
|
4510
|
-
unresolved: { ...strings, description: "\
|
|
4519
|
+
verification: { ...object2, description: "\u4E00\u4E2A\u53EF\u6838\u5B9E\u54CD\u5E94\u5B57\u6BB5\u7684\u4EE3\u8868\u6027\u53EA\u8BFB\u4E1A\u52A1\u7528\u4F8B\u5373\u53EF\u3002\u6709\u53D7\u4FDD\u62A4\u7684\u53EA\u8BFB\u4E1A\u52A1\u63A5\u53E3\u65F6\u9009\u5176\u4E2D\u4E00\u4E2A\u3002\u7EAF\u9875\u9762\u5E94\u7528\u586B\u5199\u6D4F\u89C8\u5668\u7528\u4F8B\u3002" },
|
|
4520
|
+
unresolved: { ...strings, description: "\u4EC5\u4FDD\u7559\u963B\u585E\u90E8\u7F72\u4E14\u9700\u7528\u6237\u51B3\u5B9A\u7684\u95EE\u9898\u3002\u53EF\u9009\u96C6\u6210\u914D\u7F6E\u3001\u6539\u5BC6\u5EFA\u8BAE\u3001\u90E8\u7F72\u540E\u624D\u80FD\u786E\u8BA4\u7684\u4E8B\u9879\u653E\u5728\u6458\u8981\u3002\u9274\u6743\u963B\u585E\u9879\u4F7F\u7528 auth_blockers\uFF0C\u7BA1\u7406\u5458\u8D26\u5BC6\u4F7F\u7528 admin_account\u3002" }
|
|
4511
4521
|
} },
|
|
4512
4522
|
decisions: { ...objects, items: { ...object2, properties: {
|
|
4513
4523
|
id: text2,
|
|
@@ -4515,7 +4525,6 @@ function proposalParameters(port, portLocked = true) {
|
|
|
4515
4525
|
impact: text2,
|
|
4516
4526
|
options: { ...strings, required: true }
|
|
4517
4527
|
} } },
|
|
4518
|
-
four_step_report: object2,
|
|
4519
4528
|
proposal: { ...str, description: "\u65E7\u7248\u5B8C\u6574\u63D0\u6848 JSON \u5B57\u7B26\u4E32\uFF0C\u4EC5\u5728\u6CA1\u6709\u7ED3\u6784\u5316\u53C2\u6570\u65F6\u4F7F\u7528" }
|
|
4520
4529
|
};
|
|
4521
4530
|
}
|
|
@@ -4523,7 +4532,7 @@ function proposalParameters(port, portLocked = true) {
|
|
|
4523
4532
|
// src/host/app-agent.ts
|
|
4524
4533
|
var ANALYSIS_TIMEOUT_MS = 15 * 6e4;
|
|
4525
4534
|
var REPLY_TIMEOUT_MS = 30 * 6e4;
|
|
4526
|
-
var MAX_VALIDATION_ERRORS =
|
|
4535
|
+
var MAX_VALIDATION_ERRORS = 3;
|
|
4527
4536
|
function loadBundledSkillText(relativePath) {
|
|
4528
4537
|
const fromSrc = fileURLToPath2(new URL(`../../runtime/app_delivery/${relativePath}`, import.meta.url));
|
|
4529
4538
|
const fromLib = fileURLToPath2(new URL(`../runtime/app_delivery/${relativePath}`, import.meta.url));
|
|
@@ -4614,7 +4623,7 @@ function attachAppAgent(ctx, delivery) {
|
|
|
4614
4623
|
const instructions = `${skill}
|
|
4615
4624
|
${portInstructions}${repairInstructions}`;
|
|
4616
4625
|
const prevPlan = compactPreviousPlan(job.proposal);
|
|
4617
|
-
const taskInstruction = "\u6309\
|
|
4626
|
+
const taskInstruction = "\u6309\u4E09\u6B65\u5B8C\u6210\u672C\u6B21\u5E94\u7528\u6539\u9020\u3002" + (isRepair ? "\u5148\u7528\u5931\u8D25\u5236\u54C1\u6838\u5B9E\u6839\u56E0\u3002" : prevPlan && feedback.trim() ? "\u7ED3\u5408\u7528\u6237\u8865\u5145\u590D\u6838\u4E0A\u4E00\u7248\u65B9\u6848\u3002" : "");
|
|
4618
4627
|
const timeout = new AbortController();
|
|
4619
4628
|
const abort = AbortSignal.any([signal, timeout.signal]);
|
|
4620
4629
|
let deadline;
|
|
@@ -4660,7 +4669,7 @@ ${portInstructions}${repairInstructions}`;
|
|
|
4660
4669
|
rejectedProposals.clear();
|
|
4661
4670
|
repeatedProposal = false;
|
|
4662
4671
|
replyCount++;
|
|
4663
|
-
messages.push({ ...message, content: [{ type: "text", text: safeText }] });
|
|
4672
|
+
if (safeText) messages.push({ ...message, content: [{ type: "text", text: safeText }] });
|
|
4664
4673
|
wakeReply?.();
|
|
4665
4674
|
}
|
|
4666
4675
|
return messages.length ? { ...decision, messages } : { kind: "reject" };
|
|
@@ -4705,7 +4714,7 @@ ${portInstructions}${repairInstructions}`;
|
|
|
4705
4714
|
}));
|
|
4706
4715
|
child.tools.register(defineTool2({
|
|
4707
4716
|
name: "opc_delivery_propose_file",
|
|
4708
|
-
description: "\u6682\u5B58\u6839\u76EE\u5F55 Dockerfile \
|
|
4717
|
+
description: "\u6682\u5B58\u6839\u76EE\u5F55 Dockerfile \u7684\u5FC5\u8981\u6539\u52A8\u3002\u5E94\u7528\u6E90\u7801\u548C\u914D\u7F6E\u7531\u7528\u6237\u7EF4\u62A4\u3002\u6682\u5B58\u6587\u4EF6\u5728 opc_delivery_submit \u7684 changes \u4E2D\u6309 id \u548C path \u5F15\u7528\u3002",
|
|
4709
4718
|
parameters: {
|
|
4710
4719
|
id: { type: "string", required: true },
|
|
4711
4720
|
path: { type: "string", required: true },
|
|
@@ -4719,7 +4728,7 @@ ${portInstructions}${repairInstructions}`;
|
|
|
4719
4728
|
if (job.status !== "analyzing") throw new Error("\u672C\u8F6E\u5DF2\u63D0\u4EA4\u65B9\u6848");
|
|
4720
4729
|
job.events.push(formatToolStep("propose_file", args.path));
|
|
4721
4730
|
delivery.core.emit("change");
|
|
4722
|
-
const res = await worker({ action: "propose_file", root, ...args }, abort);
|
|
4731
|
+
const res = await worker({ action: "propose_file", root, ...args, dockerfile_only: true }, abort);
|
|
4723
4732
|
return JSON.stringify(res);
|
|
4724
4733
|
}
|
|
4725
4734
|
}));
|
|
@@ -4741,10 +4750,11 @@ ${portInstructions}${repairInstructions}`;
|
|
|
4741
4750
|
if (candidate && typeof candidate.contract === "object" && candidate.contract !== null) {
|
|
4742
4751
|
candidate.contract = { ...candidate.contract, slug: job.slug, base_url: job.url };
|
|
4743
4752
|
}
|
|
4744
|
-
await delivery.submit(job, root, candidate, abort);
|
|
4753
|
+
await delivery.submit(job, root, candidate, abort, { dockerfileOnly: true });
|
|
4745
4754
|
} catch (error) {
|
|
4746
4755
|
const message = error instanceof Error ? error.message : String(error);
|
|
4747
4756
|
const detail = await worker({ action: "redact_feedback", root, text: message.slice(0, 2e3) }, abort);
|
|
4757
|
+
const duplicateError = validationErrors.includes(detail);
|
|
4748
4758
|
validationErrors.push(detail);
|
|
4749
4759
|
job.analysisFailure = detail;
|
|
4750
4760
|
if (candidate) {
|
|
@@ -4762,14 +4772,14 @@ ${portInstructions}${repairInstructions}`;
|
|
|
4762
4772
|
}
|
|
4763
4773
|
rejectedProposals.add(rej);
|
|
4764
4774
|
}
|
|
4765
|
-
job.events.push(`\u63D0\u6848\u6821\u9A8C\u672A\u901A\u8FC7\uFF1A${detail}`);
|
|
4775
|
+
if (!duplicateError) job.events.push(`\u63D0\u6848\u6821\u9A8C\u672A\u901A\u8FC7\uFF1A${detail}`);
|
|
4766
4776
|
delivery.core.emit("change");
|
|
4767
4777
|
if (validationErrors.length === MAX_VALIDATION_ERRORS) cancel();
|
|
4768
4778
|
throw new Error(detail);
|
|
4769
4779
|
}
|
|
4770
4780
|
const questions = analysisQuestions(job.proposal);
|
|
4771
4781
|
return questions.length ? `\u65B9\u6848\u5DF2\u4FDD\u5B58\uFF0C\u7B49\u5F85\u7528\u6237\u56DE\u590D\u3002\u8BF7\u5728\u5F53\u524D\u5BF9\u8BDD\u4E2D\u5217\u51FA\u5F85\u786E\u8BA4\u7684\u95EE\u9898\u4E0E\u53EF\u9009\u65B9\u6848\uFF0C\u518D\u7ED3\u675F\u672C\u8F6E\uFF1A
|
|
4772
|
-
${questions.join("\n")}` : "\
|
|
4782
|
+
${questions.join("\n")}` : "\u65B9\u6848\u901A\u8FC7\u3002\u53EA\u7528\u51E0\u53E5\u8BDD\u8BF4\u660E\u7AEF\u53E3\u3001\u5FC5\u8981\u6539\u9020\u548C\u6280\u80FD\u8303\u56F4\uFF0C\u7136\u540E\u7ED3\u675F\u672C\u8F6E\u3002OPC \u5C06\u81EA\u52A8\u751F\u6210\u4EA4\u4ED8\u5305\u3002";
|
|
4773
4783
|
}
|
|
4774
4784
|
}));
|
|
4775
4785
|
}
|
|
@@ -4917,6 +4927,7 @@ ${questions.join("\n")}` : "\u5B8C\u6574\u65B9\u6848\u5DF2\u901A\u8FC7\u6821\u9A
|
|
|
4917
4927
|
signal.throwIfAborted();
|
|
4918
4928
|
if (abort.aborted && replyCount === repliesBeforeTurn) return;
|
|
4919
4929
|
abort.throwIfAborted();
|
|
4930
|
+
if (job.status === "review" && !analysisQuestions(job.proposal).length) return;
|
|
4920
4931
|
setDeadline(ANALYSIS_TIMEOUT_MS);
|
|
4921
4932
|
} else {
|
|
4922
4933
|
abort.throwIfAborted();
|
|
@@ -4957,7 +4968,7 @@ ${questions.join("\n")}` : "\u5B8C\u6574\u65B9\u6848\u5DF2\u901A\u8FC7\u6821\u9A
|
|
|
4957
4968
|
}
|
|
4958
4969
|
job.events.push(invalidOutput ? `\u{1F504} ${reason}\uFF0C\u6B63\u5728\u7F29\u77ED\u63D0\u4EA4\u5185\u5BB9\u540E\u91CD\u8BD5\uFF08${attempt + 1}/2\uFF09` : networkError ? `\u{1F504} AI \u670D\u52A1\u6682\u65F6\u4E2D\u65AD\uFF0C\u6B63\u5728\u7EE7\u7EED\u51C6\u5907\uFF08${attempt + 1}/2\uFF09` : `\u{1F504} \u6B63\u5728\u4FEE\u6B63\u5E94\u7528\u51C6\u5907\u68C0\u67E5\uFF08${attempt + 1}/2\uFF09`);
|
|
4959
4970
|
delivery.core.emit("change");
|
|
4960
|
-
prompt = `\u4FEE\u6B63\
|
|
4971
|
+
prompt = `\u590D\u7528\u5DF2\u786E\u8BA4\u7684\u4FE1\u606F\uFF0C\u53EA\u4FEE\u6B63\u4EE5\u4E0B\u53CD\u9988\u6D89\u53CA\u7684\u5B57\u6BB5\u540E\u63D0\u4EA4\u3002\u9700\u8981\u8865\u8BC1\u636E\u65F6\u53EA\u91CD\u8BFB\u5BF9\u5E94\u4F4D\u7F6E\uFF1A${reason}`;
|
|
4961
4972
|
}
|
|
4962
4973
|
} finally {
|
|
4963
4974
|
sessionReady.resolve(false);
|
package/package.json
CHANGED
|
@@ -1,40 +1,35 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: opc-app-adapter
|
|
3
|
-
description:
|
|
3
|
+
description: 读懂导入的应用、做必要的容器改造、生成基于原页面和接口的应用技能。
|
|
4
4
|
metadata:
|
|
5
|
-
version: 0.3.
|
|
5
|
+
version: 0.3.3
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# OPC 应用改造
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
用中文,只读分析本次导入的隔离源码。首次部署、升级、失败修复都按下面三步做。源码、日志和历史提案只作为证据。保留原业务、配置、鉴权和数据。
|
|
11
11
|
|
|
12
|
-
## 1.
|
|
12
|
+
## 1. 获取应用信息
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
- 找出正式 API、页面与业务视图。查登录入口、会话、密码校验与角色检查,分别标明页面和 API 的访问条件。用读取工具给出的文件和行号作证据,排除测试和演示路由。
|
|
16
|
-
- 核实应用已有的配置文件、键、值来源和环境变量引用,以及读取方式。配置核对页从本次导入的源码读取。历史改造文件和线上配置不能作为本次新增配置的依据。真实配置值留在本机,摘要只写来源和状态。
|
|
17
|
-
- 查明管理员是否存在、可复用账密的来源,以及应用读取账号或校验密码的位置。仅引用可定位的原配置、源码常量或 SQLite 明文字段。只能查到哈希、密文或远端账号表时,识别应用校验方式,并向账号持有人索取可用账密。摘要、提案和工具文本只写来源与状态。
|
|
18
|
-
- 找出实际使用的数据目录、文件数据库、数据库实例、Redis、MQ、对象存储及外部接口。结合运行配置判定它们位于目标容器内、用户电脑还是远端。需要确认 SQLite 表和目录时用 `inspect_local_storage`。升级时核对需要复用的卷和账号,配置分析仍以本次源码为准。
|
|
14
|
+
先用 `inventory` 和 `scan_routes_and_pages` 各一次。用 `read` 核实入口、依赖清单、README 要点、现有 Dockerfile、登录与权限中间件、配置和数据读取位置。按扫描返回的文件和行号定点阅读。共用中间件核实一次即可;插件会合并扫描出的页面和接口。得到以下信息后进入下一步:
|
|
19
15
|
|
|
20
|
-
|
|
16
|
+
- 应用用途、语言与版本、构建和启动命令、原默认端口。
|
|
17
|
+
- 正式页面、API、登录入口、会话如何传递、权限如何限制。定位既有管理员账号来源,仅记录文件位置和可复用状态。账密由本机从可信引用读取,摘要与提案内不出现秘密。
|
|
18
|
+
- 原配置、文件数据目录、SQLite、数据库实例、Redis、MQ 和外部接口。区分应用容器内、用户电脑和远端服务。需要辨认 SQLite 时用 `inspect_local_storage`。
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
- 沿用原配置文件和值。契约 `configs` 仅引用原应用可证实的键和来源,`default` 留空;`*.example` / `*.sample` / `*.template` 等示例文件仅作参考模板,不要绑定与 `runtime.port` 冲突的 `PORT` 或占位密钥,源码兜底的非敏感默认值可写入 `app_default`。禁止自行增加或替换环境变量、配置文件、模板、包装脚本、管理员初始化脚本、说明文件或依赖。确需补充时写入待确认事项,等用户在应用源工程处理后重新导入。
|
|
24
|
-
- SQLite、JSON、上传等本地文件使用持久化卷,SQLite 挂载整个数据目录(含 WAL/SHM),使用工具的快照。升级复用原卷。库表变化优先只增不删,涉及删除、改名或影响回滚时列为待确认事项。
|
|
25
|
-
- 远端数据库先沿用原连接,在部署后验证可达性。若源码连的是用户电脑上的数据库实例,暂停并请用户联系运维申请同引擎的企业数据库,由运维迁移后更新连接,再继续部署。真正与应用运行在同一容器内的依赖可以保留 loopback。
|
|
26
|
-
- 用户电脑上的 Redis、MQ 等按用途判断是否要迁数据。纯缓存可重建,持久状态、队列积压或需要保留的业务数据须先核对迁移。用平台资源元数据确认可用服务;由用户决定目标并更新应用原配置。需要迁数据的,说明数据范围、目标与验收条件,等授权迁移完成再继续。只有宿主提供并实际执行了受支持的迁移工具,才能报告已迁移。
|
|
27
|
-
- 已证实目标服务器无法调用的外部接口要暂停。写清配置位置、受影响的业务和验证方法,给用户一段可交给本地 AI 的修改说明,或说明需重新部署哪个依赖。对可达性未知的远端连接标记待验证。
|
|
28
|
-
- 原值沿用 `read` 返回的 `{path,keys}` 引用。管理员账密用 `admin_account`。已有管理员用 `existing`;无可用密码时省略 `source`,由插件提示在左侧会话提供现有账密。确认首次部署且管理员存储为空才用 `create`,声明应用真正读取的 JSON/YAML 或 SQLite 位置和原有密码格式。插件在打包前把用户提供的账密写入交付副本。升级沿用已有账号。
|
|
20
|
+
## 2. 做部署所需的改造
|
|
29
21
|
|
|
30
|
-
|
|
22
|
+
- Dockerfile 能用就沿用,缺失时按语言和版本查 `template`。只提交根目录 Dockerfile 的改动。端口沿用应用实际默认值,无默认值时使用任务给出的 OPC 默认端口。容器内监听 `0.0.0.0`,优先沿用应用已有的启动参数或配置。必须改源码才能运行时,指出文件、行号和原因,请用户在源工程处理。探测沿用应用入口。
|
|
23
|
+
- 保留现有业务功能所需依赖。构建超时时查日志和依赖安装步骤,避免通过删除依赖来换取构建通过。
|
|
24
|
+
- 原配置原样使用。契约只引用源码已有配置,`default` 留空,非敏感源码兜底值可写入 `app_default`。示例文件只供参考。保留应用原有文件结构,不创建配置、环境变量、健康接口或包装脚本。
|
|
25
|
+
- SQLite、JSON、上传等本地业务数据挂载实际使用的目录,SQLite 连同 WAL/SHM 一起保留;使用工具快照,升级复用卷。远端服务沿用原连接,部署时核实可达性。同容器依赖可以用回环地址。
|
|
26
|
+
- 确认依赖在用户电脑且部署后无法连接时,说明配置位置和受影响功能,请用户安排可达的对应服务。数据库需要迁移时先由运维完成迁移并更新应用原连接。Redis、MQ 有业务状态时保留数据,纯缓存可重建。只使用实际可用的平台资源,替换连接或迁移数据须由用户确认。
|
|
27
|
+
- 管理员来源用 `admin_account`。已有账号用 `existing`,有可用的源码或配置引用时复用。确实缺少可登录账密时省略 `source`,由插件在会话里收集。只有首次部署且已确认账号存储为空时才用 `create`,按原应用的数据位置和密码格式写入交付副本。升级沿用已有账号。
|
|
28
|
+
- 只有用户必须处理才能继续的事项才填 `unresolved`。可选企微等集成、建议改密码、上线后才能验证的连通性写进摘要。修复失败部署时先读失败制品和日志,只处理实际根因。上一轮构建尚未结束时,沿用原交付包,等平台释放构建后再部署。
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
- 受保护页面走应用原登录流程。受保护接口按实际认证传 Cookie、Bearer 或应用要求的请求头。自动换取会话时按实际登录地址、方法、请求字段和响应声明;浏览器登录、跳转或其他调用器不支持的流程要明确说明依赖。打包器把已确认的管理员账密写进生成技能的 `SKILL.md`,其他 Token 和密钥走运行时凭据引用。写入、删除和外部操作仍须用户确认。
|
|
34
|
-
- 提交可真实验证的只读业务用例,覆盖用到的鉴权身份。涉及页面时记录实际操作与预期,纯页面应用由用户验收。用同一认证方式验证发布后的应用,分别记录部署、API 和页面结果。
|
|
30
|
+
## 3. 生成技能并提交
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
- 待确认项处理完且提案通过后,由插件生成交付包。用户可在第 3 步核对或按需调整运行时环境变量、差异、应用技能与持久化挂载,再主动确认发布。分析结果只说明实际准备和校验到的阶段。
|
|
32
|
+
- 复用第一步已有的接口、页面和鉴权信息。`apis`、`pages` 只补扫描遗漏或需修正的条目。共用鉴权写一条 `auth_rules`,在受保护规则中填写 `auth.profile`;公开登录入口用精确路径和方法声明。应用使用 Cookie、Bearer 或自定义头时按源码填写,页面按原登录流程走。
|
|
33
|
+
- 选择一个可以核实响应的只读业务用例。有受保护的只读接口时,用其中一个验证实际登录流程;纯页面应用填写实际操作和预期。保留原有角色限制,所有非只读接口填写 `confirmation_required: true`。
|
|
34
|
+
- 用 `opc_delivery_propose_file` 暂存必要文件,再用 `opc_delivery_submit` 提交摘要、改动、契约和真实阻塞项。字段拿不准只查 `contract.md` 对应段落。校验有反馈时只改点名的字段,缺证据只重读对应位置。
|
|
35
|
+
- 方案通过就简要说明实际端口、改了什么、技能覆盖哪些功能,结束分析。插件生成交付包和技能,用户在向导核对后决定发布。
|
|
@@ -52,6 +52,7 @@ Work 自动技术准备记录 `kind: ai-technical`、`scope: deployment-adaptati
|
|
|
52
52
|
- 每个 API 必须含 purpose、源码 evidence、实际 parameters/request_body/responses、auth、effect。request_body 为 null 或包含 required、description、schema 的对象;完整 schema 与错误说明应保留,工具不声称完整实现 JSON Schema 验证。API 错误可能包含 HTTP 200 下的业务错误码,业务流程必须明确成功判断,不把 HTTP 成功等同业务成功。
|
|
53
53
|
- auth.type 为 none、bearer 或 header;非 none 必须声明 env 环境变量名或引用 auth_profiles 中的 profile,header 还要提供 header。原始账号密码不要填入契约,由打包器写进生成应用技能的 `SKILL.md`。其他密钥和令牌沿用运行时引用。
|
|
54
54
|
- 直接在 API 或页面上声明认证时,用 `auth.evidence` 引用登录、会话或权限代码。共用中间件的证据写在 `auth_rules[].evidence`。每条证据使用读取工具返回的相对路径与实际行号,修改过的文件以拟交付版本为准。
|
|
55
|
+
- 共用鉴权写一条前缀规则,例如 `{"target":"api","prefix":"/api/","auth":{"type":"header","header":"Cookie","profile":"account"},"evidence":["server.mjs:42"]}`。公开登录入口用精确的 `path`、`method` 和 `auth.type: none` 声明例外。
|
|
55
56
|
- 账号密码换会话可用 `auth_profiles.account = {"login_url":"/api/session","login_method":"POST","username_env":"APP_USER","password_env":"APP_PASSWORD"}`。调用器向同源地址发送 JSON。非默认字段用 `login_body_template`,例如 `{"email":"${username}","secret":"${password}"}`。登录返回 `Set-Cookie` 时,受保护 API 声明 `{"type":"header","header":"Cookie","profile":"account"}`。返回 Token 时按实际响应声明 `token_json_path` 及接口要求的 Bearer 或请求头。凭据引用用于业务验证,无需加入容器配置。表单、重定向和 SSO 流程需要浏览器或专用调用方式。
|
|
56
57
|
- `admin_account` 声明 `profile`、`mode` 和 `evidence`。`profile` 对应原应用的登录接口,`login_method` 填 `POST` 等 HTTP 动词。管理员接口及验证用例要使用这一个 profile。
|
|
57
58
|
- `mode: existing` 复用已有管理员。确认有可用明文时,填写 `source: {"username":{"path":"admin.json","keys":["username"]},"password":{"path":"admin.json","keys":["password"]}}`。明确的源码字符串常量可用 `{path,line,name}`,SQLite 明文字段可用 `{path,table,column,where}` 引用。`where` 是用于唯一标识记录的字段与值。只能定位到哈希、密文或远端账号记录时,省略 `source`,OPC 会在 AI 改造会话提示按 `账号:…` 和 `密码:…` 两行回复已有可登录的账密。
|
|
@@ -59,7 +60,7 @@ Work 自动技术准备记录 `kind: ai-technical`、`scope: deployment-adaptati
|
|
|
59
60
|
- 非只读 effect 必须 confirmation_required:true。不能仅按 HTTP 方法判断,POST 搜索也可以明确标为 read;GET 也可能需要确认。
|
|
60
61
|
- pages 每项含 path、purpose、evidence、actions;无页面就填空数组,浏览器操作需要调用方提供浏览器工具。
|
|
61
62
|
- 0.2.0 内置调用器只处理普通 HTTP/JSON 与标量 path/query/header 参数;参数名必须唯一。multipart 上传、二进制下载、流式/WebSocket、同名不同位置的参数及复杂数组参数编码需单独脚本并验证;先报告限制,请用户决定是否扩展,不能默默丢弃 API 或宣称已可调用。
|
|
62
|
-
- verification.cases 是已核实无副作用的业务探针,包含 operation、params、可选 body、预期 status
|
|
63
|
+
- verification.cases 是已核实无副作用的业务探针,包含 operation、params、可选 body、预期 status 和非空 json_contains。一个代表性用例即可。有受保护的只读业务接口时选其中一个验证实际鉴权,保留各接口原有角色限制。已有健康入口可用可选 health.path 标识。测试数据只能来自明确的测试环境,不擅自生成真实业务记录。
|
|
63
64
|
- json_contains 对象按字段递归匹配;非空期望数组逐项匹配实际数组中的记录,顺序可不同;空期望只匹配空数组。空结果、不同条数或错误类型不能通过。多行顺序不稳定时先用获准条件过滤唯一测试记录,或提供专用验证。
|
|
64
65
|
- verification.browser_cases 是页面操作验证计划,例如 `[{"page":"/orders","steps":["输入查询条件","执行只读搜索"],"expected":"显示符合条件的真实订单"}]`。page 必须在 pages 中;该计划不是执行证据。没有 API 探针时必须填写浏览器计划。
|
|
65
66
|
|
|
@@ -328,7 +328,7 @@ EMBEDDED_CREDENTIAL_FIELDS = {
|
|
|
328
328
|
"username", "admin_username", "password", "admin_password",
|
|
329
329
|
"default_username", "default_password", "default_token",
|
|
330
330
|
"auth_token", "token", "api_key", "cookie", "default_credential",
|
|
331
|
-
"login_body",
|
|
331
|
+
"login_body",
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
|
|
@@ -338,6 +338,13 @@ def validate_credential_references(contract):
|
|
|
338
338
|
for profile in [contract.get("auth_profile", {})] + list(profiles.values()):
|
|
339
339
|
require(isinstance(profile, dict), "credential profile must be an object")
|
|
340
340
|
require(not any(profile.get(key) for key in EMBEDDED_CREDENTIAL_FIELDS), "Use runtime credential references, not embedded credentials")
|
|
341
|
+
if "login_body_template" in profile:
|
|
342
|
+
template = profile["login_body_template"]
|
|
343
|
+
require(isinstance(template, dict) and bool(template)
|
|
344
|
+
and all(isinstance(key, str) and key and isinstance(value, str)
|
|
345
|
+
and value in {"${username}", "${password}"} for key, value in template.items())
|
|
346
|
+
and set(template.values()) == {"${username}", "${password}"},
|
|
347
|
+
"login_body_template must map fields to username and password placeholders only")
|
|
341
348
|
for key in ("username_env", "password_env", "token_env"):
|
|
342
349
|
if key in profile:
|
|
343
350
|
require(isinstance(profile[key], str) and ENV_NAME.fullmatch(profile[key]), "Credential reference must be an environment variable name")
|
|
@@ -131,7 +131,9 @@ def validate_account_plan(source, contract, reuse_source_admin=False):
|
|
|
131
131
|
and profile["username_env"] != profile["password_env"]),
|
|
132
132
|
"管理员账密必须绑定已有登录方式。请在 auth_profiles 的对应对象内直接声明 login_url、username_env、password_env。")
|
|
133
133
|
routes = [*contract.get("apis", []), *contract.get("pages", [])]
|
|
134
|
-
d.require(any(item.get("auth", {}).get("profile") ==
|
|
134
|
+
d.require(any(item.get("auth", {}).get("profile") == profile_id
|
|
135
|
+
and item["auth"].get("type") in {"header", "bearer"} for item in routes),
|
|
136
|
+
f"没有受保护的接口或页面引用登录方式 {profile_id}。请在真实鉴权路由的 auth 或匹配的 auth_rules[].auth 中填写 profile;公开登录入口不计。")
|
|
135
137
|
if plan.get("mode") == "existing":
|
|
136
138
|
d.require("storage" not in plan, "使用已有管理员时不修改账号存储")
|
|
137
139
|
if "source" in plan:
|
|
@@ -60,7 +60,19 @@ def resolve_authentication(contract):
|
|
|
60
60
|
if any(rank(r) == rank(best) and r.get('auth') != best.get('auth') for r in ranked[1:]):
|
|
61
61
|
errors.append('存在互相冲突的认证规则:' + item['path'])
|
|
62
62
|
continue
|
|
63
|
-
|
|
63
|
+
auth = copy.deepcopy(best['auth'])
|
|
64
|
+
explicit = item.get('auth') or {}
|
|
65
|
+
# A shared guard describes the transport. Keep a route's explicit
|
|
66
|
+
# login reference when that guard uses the same transport and has
|
|
67
|
+
# not selected credentials of its own.
|
|
68
|
+
if (best.get('prefix') and auth['type'] in {'header', 'bearer'}
|
|
69
|
+
and explicit.get('type') == auth['type']
|
|
70
|
+
and str(explicit.get('header', '')).lower() == str(auth.get('header', '')).lower()):
|
|
71
|
+
if not (auth.get('profile') or auth.get('env')):
|
|
72
|
+
auth.update({key: explicit[key] for key in ('profile', 'env') if explicit.get(key)})
|
|
73
|
+
if 'roles' in explicit and 'roles' not in auth:
|
|
74
|
+
auth['roles'] = explicit['roles']
|
|
75
|
+
item['auth'] = {**auth, 'evidence': best['evidence']}
|
|
64
76
|
auth = item.get('auth', {'type': 'unknown'})
|
|
65
77
|
if auth.get('type') == 'unknown':
|
|
66
78
|
evidence = item.get('evidence')
|
|
@@ -184,16 +196,15 @@ def validate_auth_questions(proposal):
|
|
|
184
196
|
|
|
185
197
|
|
|
186
198
|
def validate_auth_probe_coverage(contract):
|
|
187
|
-
"""
|
|
199
|
+
"""Exercise a protected business read when the application has one."""
|
|
188
200
|
if not contract.get('auth_rules') and not contract.get('auth_profiles'):
|
|
189
201
|
return # Existing packaged skills keep their original verification contract.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
operations = {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
raise ValueError('认证验证计划不完整:每种认证身份/权限范围需要只读业务用例;不能用公开健康接口代替。请自动补齐验证计划。')
|
|
202
|
+
health_path = (contract.get('health') or {}).get('path')
|
|
203
|
+
protected_reads = [api for api in contract.get('apis', [])
|
|
204
|
+
if api.get('auth', {}).get('type') in {'header', 'bearer'}
|
|
205
|
+
and api.get('effect') == 'read' and api.get('path') != health_path]
|
|
206
|
+
operations = {case.get('operation') for case in contract.get('verification', {}).get('cases', [])
|
|
207
|
+
if case.get('json_contains')}
|
|
208
|
+
if protected_reads and not any(api['id'] in operations for api in protected_reads):
|
|
209
|
+
examples = '、'.join(f"{api['id']}({api['method']} {api['path']})" for api in protected_reads[:3])
|
|
210
|
+
raise ValueError(f'请在 verification.cases 中选择一个受保护的只读业务接口,填写可核实的响应字段。可选:{examples}。')
|