omc-core 0.5.0 → 0.5.1

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.
Files changed (134) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +13 -13
  3. package/dist/application-discovery.js +0 -0
  4. package/dist/approval-frame-readability.js +0 -0
  5. package/dist/approval-protocol.js +8 -8
  6. package/dist/autonomous-delivery-demonstration-host.js +0 -0
  7. package/dist/autonomous-delivery-demonstration.js +0 -0
  8. package/dist/b1-dead-runner-contract.js +0 -0
  9. package/dist/b2-extension-contract.js +0 -0
  10. package/dist/backend-extension-release.js +0 -0
  11. package/dist/bizsheet-html-elements.js +0 -0
  12. package/dist/bizsheet-online-js.js +0 -0
  13. package/dist/bootstrap-lifecycle.js +19 -19
  14. package/dist/bootstrap-plan-registry.js +11 -11
  15. package/dist/business-rule-integration.js +0 -0
  16. package/dist/businessrule-contract.js +0 -0
  17. package/dist/capability-catalog.js +19 -19
  18. package/dist/capability-shape.js +0 -0
  19. package/dist/change-workflow.js +7 -7
  20. package/dist/childtable-field-contract.js +0 -0
  21. package/dist/childtable-live-runner-contract.js +0 -0
  22. package/dist/childtable-sheet201-contract.js +0 -0
  23. package/dist/cloudpivot-86-rule-integration-knowledge-pack.js +0 -0
  24. package/dist/cloudpivot-adapter.js +0 -0
  25. package/dist/cloudpivot-auth.js +112 -32
  26. package/dist/cloudpivot-business-object-acceptance.js +0 -0
  27. package/dist/cloudpivot-capability-builders.js +0 -0
  28. package/dist/cloudpivot-fingerprints.js +0 -0
  29. package/dist/cloudpivot-frontend-knowledge-pack.js +0 -0
  30. package/dist/cloudpivot-low-code.js +0 -0
  31. package/dist/cloudpivot-native-configuration.js +0 -0
  32. package/dist/cloudpivot-native-lifecycle-contract.js +0 -0
  33. package/dist/cloudpivot-online-js.js +0 -0
  34. package/dist/cloudpivot-operation-seam.js +0 -0
  35. package/dist/compatibility-assessment.js +0 -0
  36. package/dist/config-only-runtime-validation-host.js +0 -0
  37. package/dist/config-only-runtime-validation.js +0 -0
  38. package/dist/configuration-handoff.js +0 -0
  39. package/dist/configuration-intent.js +0 -0
  40. package/dist/controlled-executor.js +0 -0
  41. package/dist/cpharness-backend.js +0 -0
  42. package/dist/cpharness-contracts.js +0 -0
  43. package/dist/cpharness-extension-package-builder.js +0 -0
  44. package/dist/dbsweep.js +0 -0
  45. package/dist/delivery-child-agent.js +0 -0
  46. package/dist/delivery-graph.js +9 -9
  47. package/dist/dsh-history.js +0 -0
  48. package/dist/dsh-rpc.js +0 -0
  49. package/dist/dsh-run.js +0 -0
  50. package/dist/end-to-end-virtual-delivery.js +0 -0
  51. package/dist/environment-release-freeze.js +6 -6
  52. package/dist/families/address-attachment.js +0 -0
  53. package/dist/families/date-time.js +0 -0
  54. package/dist/families/dictionary-enum.js +0 -0
  55. package/dist/families/numeric-logical.js +0 -0
  56. package/dist/families/people-department.js +0 -0
  57. package/dist/families/registry.js +0 -0
  58. package/dist/families/relevance.js +0 -0
  59. package/dist/families/text-extension.js +0 -0
  60. package/dist/families/types.js +0 -0
  61. package/dist/field-live-host-tools.js +0 -0
  62. package/dist/field-probe-runner-contract.js +0 -0
  63. package/dist/field-probe-schema.js +0 -0
  64. package/dist/form-scaffold-contract.js +0 -0
  65. package/dist/formal-capability-discovery.js +0 -0
  66. package/dist/formula-controls-contract.js +0 -0
  67. package/dist/formula-field-contract.js +0 -0
  68. package/dist/formula-live-runner-contract.js +0 -0
  69. package/dist/full-capability-test-harness.js +0 -0
  70. package/dist/host-operations.js +0 -0
  71. package/dist/host-package-registry.js +38 -22
  72. package/dist/index.js +0 -0
  73. package/dist/json-column.js +0 -0
  74. package/dist/knowledge-pack-builder.js +0 -0
  75. package/dist/knowledge-pack-runtime.js +0 -0
  76. package/dist/launcher-package-adapter.js +0 -0
  77. package/dist/list-view-wire.js +0 -0
  78. package/dist/local-online-js-draft.js +0 -0
  79. package/dist/m2-data-entry-contract.js +0 -0
  80. package/dist/master-plan-approval.js +443 -0
  81. package/dist/omc-planning.js +0 -0
  82. package/dist/omc-review.js +0 -0
  83. package/dist/omc-validation.js +0 -0
  84. package/dist/online-js-governance-contract.js +0 -0
  85. package/dist/online-js-package-adapter.js +0 -0
  86. package/dist/online-js-promotion.js +0 -0
  87. package/dist/ordinary-synthesis-router.js +0 -0
  88. package/dist/orphan-cleanup.js +0 -0
  89. package/dist/output-declaration-e2e-scenario.js +0 -0
  90. package/dist/permission-product-crud-capabilities.js +0 -0
  91. package/dist/project-output-declaration-intent.js +0 -0
  92. package/dist/refusal.js +0 -0
  93. package/dist/relation-shape.js +0 -0
  94. package/dist/release-knowledge-pack-adapter.js +0 -0
  95. package/dist/representative-acceptance-direct-rpc.js +0 -0
  96. package/dist/runtime-acceptance.js +0 -0
  97. package/dist/s28-s29-static-contract.js +0 -0
  98. package/dist/s29-workflow-greenfield-contract.js +0 -0
  99. package/dist/s32-restful-contract.js +0 -0
  100. package/dist/scout-accelerator.js +0 -0
  101. package/dist/synthesis-delivery-request.js +0 -0
  102. package/dist/ticket02-direct-rpc.js +0 -0
  103. package/dist/ticket02-evidence.js +0 -0
  104. package/dist/ticket02-implementation-delegation.js +0 -0
  105. package/dist/ticket02-model-route.js +0 -0
  106. package/dist/ticket02-native-adapter.js +0 -0
  107. package/dist/ticket02-session-reporting.js +0 -0
  108. package/dist/ticket02-workflow-validation.js +0 -0
  109. package/dist/ticket03-background-delegation.js +0 -0
  110. package/dist/ticket03-form-adapter.js +0 -0
  111. package/dist/ticket03-native-adapter.js +0 -0
  112. package/dist/ticket03-native-dsh.js +0 -0
  113. package/dist/ticket04-background-task-details.js +0 -0
  114. package/dist/ticket04-local-delivery.js +0 -0
  115. package/dist/ticket05-backend-extension-contract.js +0 -0
  116. package/dist/ticket05-parallel-worktrees.js +0 -0
  117. package/dist/ticket06-mixed-read-only-delivery.js +0 -0
  118. package/dist/ticket07-environments-approvals-delivery.js +0 -0
  119. package/dist/ticket08-local-vertical-slice.js +0 -0
  120. package/dist/ticket08-mixed-requirement-acceptance.js +0 -0
  121. package/dist/ticket08-native-contract-host.js +0 -0
  122. package/dist/ticket08-native-contract.js +0 -0
  123. package/dist/ticket08-test-model-mutation.js +901 -0
  124. package/dist/ticket09-test-field-mutation.js +1026 -0
  125. package/dist/ticket10-test-field-publish.js +886 -0
  126. package/dist/ticket11-test-form-draft.js +1014 -0
  127. package/dist/ticket12-test-form-publish.js +917 -0
  128. package/dist/ticket13-full-ladder.js +0 -0
  129. package/dist/ticket20-test-data-rule.js +780 -0
  130. package/dist/two-stage-change-package.js +0 -0
  131. package/dist/wire-facts.js +0 -0
  132. package/dist/workflow-rule-integration-adapters.js +0 -0
  133. package/dist/zip.js +0 -0
  134. package/package.json +49 -49
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Oh-My-CpAgent contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Oh-My-CpAgent contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # omc-core
2
-
3
- OMC(Oh-My-CpAgent)配置能力族的共享内核:能力契约、治理原语(审批协议、受控执行器、
4
- 写租约)、CloudPivot wire 解码器,以及字段/模型/表单的契约阶梯。
5
-
6
- 硬性保证:
7
-
8
- - **零 DSH 依赖。** `omc-core` 从不 import `@deepseek-ai/dsh-*`。由
9
- `scripts/check-zero-dsh.mjs` 强制(已接入 CI;违反即为红色)。
10
- - **宿主无关**:没有宿主插件、没有 profile shell、没有安装 shell——那些属于宿主包
11
- (`oh-my-cpagents` 根包、DSH 层)。
12
-
13
- 本包是 `omc-cli` 的共享运行时依赖,也会与 `omc-cli` 使用相同版本发布到 GitLab npm Package Registry。使用方通常直接安装 `omc-cli`,npm 会自动解析 `omc-core`。
1
+ # omc-core
2
+
3
+ OMC(Oh-My-CpAgent)配置能力族的共享内核:能力契约、治理原语(审批协议、受控执行器、
4
+ 写租约)、CloudPivot wire 解码器,以及字段/模型/表单的契约阶梯。
5
+
6
+ 硬性保证:
7
+
8
+ - **零 DSH 依赖。** `omc-core` 从不 import `@deepseek-ai/dsh-*`。由
9
+ `scripts/check-zero-dsh.mjs` 强制(已接入 CI;违反即为红色)。
10
+ - **宿主无关**:没有宿主插件、没有 profile shell、没有安装 shell——那些属于宿主包
11
+ (`oh-my-cpagents` 根包、DSH 层)。
12
+
13
+ 本包是 `omc-cli` 的共享运行时依赖,也会与 `omc-cli` 使用相同版本发布到 GitLab npm Package Registry。使用方通常直接安装 `omc-cli`,npm 会自动解析 `omc-core`。
File without changes
File without changes
@@ -11,11 +11,11 @@ export class ApprovalProtocol {
11
11
  if (this.key.length !== 32)
12
12
  throw new Error("Approval protocol integrity key must be exactly 32 bytes.");
13
13
  this.db = new DatabaseSync(databasePath);
14
- this.db.exec(`CREATE TABLE IF NOT EXISTS approval_protocol (
15
- transaction_id TEXT PRIMARY KEY, kind TEXT NOT NULL, opaque_id TEXT NOT NULL,
16
- expected_json TEXT NOT NULL, intent_hash TEXT NOT NULL, status TEXT NOT NULL,
17
- completed_boundaries_json TEXT NOT NULL, record_hash TEXT NOT NULL, integrity_mac TEXT NOT NULL,
18
- UNIQUE(kind, opaque_id)
14
+ this.db.exec(`CREATE TABLE IF NOT EXISTS approval_protocol (
15
+ transaction_id TEXT PRIMARY KEY, kind TEXT NOT NULL, opaque_id TEXT NOT NULL,
16
+ expected_json TEXT NOT NULL, intent_hash TEXT NOT NULL, status TEXT NOT NULL,
17
+ completed_boundaries_json TEXT NOT NULL, record_hash TEXT NOT NULL, integrity_mac TEXT NOT NULL,
18
+ UNIQUE(kind, opaque_id)
19
19
  )`);
20
20
  for (const column of ["prompt_issued INTEGER NOT NULL DEFAULT 0", "approval_outcome TEXT"]) {
21
21
  try {
@@ -48,8 +48,8 @@ export class ApprovalProtocol {
48
48
  const next = { ...current, promptIssued: true };
49
49
  const recordHash = sha256(next);
50
50
  const mac = hmac(recordHash, this.key);
51
- const result = this.db.prepare(`UPDATE approval_protocol
52
- SET prompt_issued = 1, record_hash = ?, integrity_mac = ?
51
+ const result = this.db.prepare(`UPDATE approval_protocol
52
+ SET prompt_issued = 1, record_hash = ?, integrity_mac = ?
53
53
  WHERE transaction_id = ? AND kind = ? AND opaque_id = ? AND intent_hash = ? AND prompt_issued = 0`)
54
54
  .run(recordHash, mac, current.transactionId, current.kind, current.opaqueId, current.intentHash);
55
55
  if (Number(result.changes) !== 1) {
@@ -120,7 +120,7 @@ export class ApprovalProtocol {
120
120
  save(value) {
121
121
  const recordHash = sha256(value);
122
122
  const mac = hmac(recordHash, this.key);
123
- this.db.prepare(`INSERT INTO approval_protocol (transaction_id, kind, opaque_id, expected_json, intent_hash, status, completed_boundaries_json, prompt_issued, approval_outcome, record_hash, integrity_mac)
123
+ this.db.prepare(`INSERT INTO approval_protocol (transaction_id, kind, opaque_id, expected_json, intent_hash, status, completed_boundaries_json, prompt_issued, approval_outcome, record_hash, integrity_mac)
124
124
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(transaction_id) DO UPDATE SET status = excluded.status, completed_boundaries_json = excluded.completed_boundaries_json, prompt_issued = excluded.prompt_issued, approval_outcome = excluded.approval_outcome, record_hash = excluded.record_hash, integrity_mac = excluded.integrity_mac`)
125
125
  .run(value.transactionId, value.kind, value.opaqueId, canonical(value.expected), value.intentHash, value.status, canonical(value.completedBoundaries), value.promptIssued ? 1 : 0, value.approvalOutcome ?? null, recordHash, mac);
126
126
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -22,18 +22,18 @@ export class BootstrapLifecycleHost {
22
22
  this.executionClaimHook = options.executionClaimHook;
23
23
  mkdirSync(dirname(databasePath), { recursive: true });
24
24
  this.db = new DatabaseSync(databasePath);
25
- this.db.exec(`CREATE TABLE IF NOT EXISTS bootstrap_lifecycle (
26
- lifecycle_id TEXT PRIMARY KEY,
27
- plan_json TEXT NOT NULL,
28
- plan_hash TEXT NOT NULL,
29
- package_json TEXT,
30
- package_hash TEXT,
31
- namespace_json TEXT NOT NULL,
32
- state TEXT NOT NULL,
33
- execution_approval_id TEXT,
34
- consumed_execution_approval_ids_json TEXT NOT NULL DEFAULT '[]',
35
- record_hash TEXT NOT NULL,
36
- integrity_mac TEXT NOT NULL
25
+ this.db.exec(`CREATE TABLE IF NOT EXISTS bootstrap_lifecycle (
26
+ lifecycle_id TEXT PRIMARY KEY,
27
+ plan_json TEXT NOT NULL,
28
+ plan_hash TEXT NOT NULL,
29
+ package_json TEXT,
30
+ package_hash TEXT,
31
+ namespace_json TEXT NOT NULL,
32
+ state TEXT NOT NULL,
33
+ execution_approval_id TEXT,
34
+ consumed_execution_approval_ids_json TEXT NOT NULL DEFAULT '[]',
35
+ record_hash TEXT NOT NULL,
36
+ integrity_mac TEXT NOT NULL
37
37
  )`);
38
38
  for (const column of ["execution_approval_id TEXT", "execution_intent_token TEXT", "consumed_execution_approval_ids_json TEXT NOT NULL DEFAULT '[]'", "integrity_mac TEXT NOT NULL DEFAULT ''"]) {
39
39
  try {
@@ -41,13 +41,13 @@ export class BootstrapLifecycleHost {
41
41
  }
42
42
  catch { /* already present */ }
43
43
  }
44
- this.db.exec(`CREATE TABLE IF NOT EXISTS bootstrap_lifecycle_event (
45
- sequence INTEGER PRIMARY KEY AUTOINCREMENT,
46
- lifecycle_id TEXT NOT NULL,
47
- type TEXT NOT NULL,
48
- plan_hash TEXT NOT NULL,
49
- package_hash TEXT,
50
- payload_json TEXT NOT NULL
44
+ this.db.exec(`CREATE TABLE IF NOT EXISTS bootstrap_lifecycle_event (
45
+ sequence INTEGER PRIMARY KEY AUTOINCREMENT,
46
+ lifecycle_id TEXT NOT NULL,
47
+ type TEXT NOT NULL,
48
+ plan_hash TEXT NOT NULL,
49
+ package_hash TEXT,
50
+ payload_json TEXT NOT NULL
51
51
  )`);
52
52
  this.recoverExecutingRecords();
53
53
  }
@@ -13,17 +13,17 @@ export class BootstrapPlanRegistry {
13
13
  this.integrityKey = loadIntegrityKey(databasePath, options.integrityKey);
14
14
  mkdirSync(dirname(databasePath), { recursive: true });
15
15
  this.db = new DatabaseSync(databasePath);
16
- this.db.exec(`CREATE TABLE IF NOT EXISTS bootstrap_plan_registry (
17
- plan_approval_id TEXT PRIMARY KEY,
18
- plan_hash TEXT NOT NULL,
19
- serialized_plan TEXT NOT NULL,
20
- binding_json TEXT NOT NULL,
21
- approval_status TEXT NOT NULL,
22
- namespace_json TEXT NOT NULL,
23
- created_at TEXT NOT NULL,
24
- finalized_at TEXT,
25
- record_hash TEXT NOT NULL,
26
- integrity_mac TEXT NOT NULL
16
+ this.db.exec(`CREATE TABLE IF NOT EXISTS bootstrap_plan_registry (
17
+ plan_approval_id TEXT PRIMARY KEY,
18
+ plan_hash TEXT NOT NULL,
19
+ serialized_plan TEXT NOT NULL,
20
+ binding_json TEXT NOT NULL,
21
+ approval_status TEXT NOT NULL,
22
+ namespace_json TEXT NOT NULL,
23
+ created_at TEXT NOT NULL,
24
+ finalized_at TEXT,
25
+ record_hash TEXT NOT NULL,
26
+ integrity_mac TEXT NOT NULL
27
27
  )`);
28
28
  }
29
29
  register(input) {
File without changes
File without changes
@@ -11,25 +11,25 @@ export class CapabilityCatalog {
11
11
  constructor(databasePath) {
12
12
  mkdirSync(pathDirname(databasePath), { recursive: true });
13
13
  this.db = new DatabaseSync(databasePath);
14
- this.db.exec(`CREATE TABLE IF NOT EXISTS capability (
15
- id TEXT PRIMARY KEY,
16
- name TEXT NOT NULL,
17
- kind TEXT NOT NULL,
18
- permissions_json TEXT NOT NULL,
19
- lifecycle_json TEXT NOT NULL,
20
- freeze_json TEXT NOT NULL,
21
- operation_contract_hashes_json TEXT NOT NULL DEFAULT '[]',
22
- status TEXT NOT NULL,
23
- promotion_status TEXT NOT NULL
24
- );
25
- CREATE TABLE IF NOT EXISTS capability_evidence (
26
- id TEXT PRIMARY KEY,
27
- capability_id TEXT NOT NULL,
28
- kind TEXT NOT NULL,
29
- artifact_id TEXT NOT NULL,
30
- sha256 TEXT NOT NULL,
31
- recorded_at TEXT NOT NULL,
32
- UNIQUE(capability_id, kind)
14
+ this.db.exec(`CREATE TABLE IF NOT EXISTS capability (
15
+ id TEXT PRIMARY KEY,
16
+ name TEXT NOT NULL,
17
+ kind TEXT NOT NULL,
18
+ permissions_json TEXT NOT NULL,
19
+ lifecycle_json TEXT NOT NULL,
20
+ freeze_json TEXT NOT NULL,
21
+ operation_contract_hashes_json TEXT NOT NULL DEFAULT '[]',
22
+ status TEXT NOT NULL,
23
+ promotion_status TEXT NOT NULL
24
+ );
25
+ CREATE TABLE IF NOT EXISTS capability_evidence (
26
+ id TEXT PRIMARY KEY,
27
+ capability_id TEXT NOT NULL,
28
+ kind TEXT NOT NULL,
29
+ artifact_id TEXT NOT NULL,
30
+ sha256 TEXT NOT NULL,
31
+ recorded_at TEXT NOT NULL,
32
+ UNIQUE(capability_id, kind)
33
33
  )`);
34
34
  try {
35
35
  this.db.exec("ALTER TABLE capability ADD COLUMN operation_contract_hashes_json TEXT NOT NULL DEFAULT '[]'");
File without changes
@@ -10,13 +10,13 @@ export class ChangeLedger {
10
10
  mkdirSync(artifactRoot, { recursive: true });
11
11
  this.db = new DatabaseSync(databasePath);
12
12
  this.artifactRoot = resolve(artifactRoot);
13
- this.db.exec(`CREATE TABLE IF NOT EXISTS change_event (
14
- sequence INTEGER PRIMARY KEY AUTOINCREMENT,
15
- change_id TEXT NOT NULL,
16
- at TEXT NOT NULL,
17
- type TEXT NOT NULL,
18
- binding_json TEXT NOT NULL,
19
- payload_json TEXT NOT NULL
13
+ this.db.exec(`CREATE TABLE IF NOT EXISTS change_event (
14
+ sequence INTEGER PRIMARY KEY AUTOINCREMENT,
15
+ change_id TEXT NOT NULL,
16
+ at TEXT NOT NULL,
17
+ type TEXT NOT NULL,
18
+ binding_json TEXT NOT NULL,
19
+ payload_json TEXT NOT NULL
20
20
  )`);
21
21
  }
22
22
  create(binding) {
File without changes
File without changes
File without changes
File without changes
@@ -8,6 +8,16 @@ export class CloudPivotAuthenticator {
8
8
  }
9
9
  /** Resolved auth endpoint family (`/user` on 8.6, `/api` on 8.2-era), probed once. */
10
10
  authPrefix;
11
+ /**
12
+ * Why the OAuth client secret was not supplied (absent/unreadable `client`
13
+ * blob). Diagnostic only — surfaced by doctor so a cosmetic shape difference
14
+ * never reads as "environment unreachable".
15
+ */
16
+ clientConfigNote;
17
+ /** Non-fatal login caveats, e.g. `client` blob unreadable but login succeeded. */
18
+ loginNotes() {
19
+ return this.clientConfigNote ? [this.clientConfigNote] : [];
20
+ }
11
21
  /**
12
22
  * CloudPivot moved the auth face from `/api/*` (8.2-era) to `/user/*` (8.6).
13
23
  * Rather than pin a version number, probe for a working `getKey` and remember
@@ -40,7 +50,16 @@ export class CloudPivotAuthenticator {
40
50
  async login(input) {
41
51
  const system = input.systemConfig ?? await this.read("/api/public/system/config", "GET");
42
52
  const enterpriseId = requiredString(system, ["corpId", "corp_id"]);
43
- const clientSecret = input.clientSecret ?? optionalString(system, ["client_secret", "clientSecret", "secret"]) ?? resolveClientSecret(requiredString(system, ["client"]));
53
+ // Optional by design: an unreadable/absent `client` blob must not block the
54
+ // login. Track why it is absent so doctor can say so without failing.
55
+ const clientSecret = input.clientSecret
56
+ ?? optionalString(system, ["client_secret", "clientSecret", "secret"])
57
+ ?? parseClientSecret(system.client);
58
+ this.clientConfigNote = clientSecret === undefined
59
+ ? (system.client === undefined || system.client === null
60
+ ? "system/config 未提供 client 字段,已按无密钥客户端登录"
61
+ : "system/config 的 client 字段无法解析,已按无密钥客户端登录")
62
+ : undefined;
44
63
  const authBase = await this.resolveAuthPrefix();
45
64
  const key = await this.read(`${authBase}/public/getKey`, "GET");
46
65
  const publicKey = requiredString(key, ["key", "publicKey"]);
@@ -71,7 +90,7 @@ export class CloudPivotAuthenticator {
71
90
  code,
72
91
  url: origin + authBase,
73
92
  client_id: "api",
74
- client_secret: clientSecret,
93
+ ...(clientSecret !== undefined ? { client_secret: clientSecret } : {}),
75
94
  redirect_uri: `${origin}/oauth`,
76
95
  });
77
96
  const token = requiredString(tokenResult, ["access_token", "token", "T"]);
@@ -312,52 +331,113 @@ function aesEcbDecryptBase64(ciphertext, key) {
312
331
  return Buffer.concat([decipher.update(Buffer.from(ciphertext, "base64")), decipher.final()]).toString("utf8");
313
332
  }
314
333
  /**
315
- * The `client` field of `/api/public/system/config` has appeared in three
316
- * shapes across versions/deployments: encrypted JSON (8.6 default, AES with the
317
- * static controller key), PLAINTEXT JSON (some 8.2-era builds — `{"client_id":
318
- * "api","client_secret":"…"}`), and occasionally the bare secret. Try each, so
319
- * login works regardless of which shape a deployment serves.
334
+ * The `client` field of `/api/public/system/config` carries the OAuth client
335
+ * config, and its shape drifts across deployments:
336
+ *
337
+ * - 8.6: AES/ECB ciphertext (static controller key) of `{"client_id":…,"client_secret":…}`
338
+ * - 8.2-era: PLAINTEXT JSON of the same object
339
+ * - 8.1 boxes seen in the field: base64 of that JSON, a JSON string that is
340
+ * itself base64, camelCase keys, an EMPTY secret (public client), or the
341
+ * field missing altogether
342
+ *
343
+ * A shape we cannot read must NOT fail the login: `client_secret` is optional
344
+ * at the token endpoint on every 8.x box we have seen, and cp-model logs in
345
+ * without it. Refusing to log in because the blob was unreadable turns a
346
+ * cosmetic difference into "env-unreachable" (live report, 8.1 上海电建).
347
+ *
348
+ * Prints keys through `JSON.parse` at each layer so escaped JSON strings
349
+ * (`"{\"client_secret\":\"…\"}"`) resolve too.
320
350
  */
321
- function resolveClientSecret(value) {
322
- // 1) PLAINTEXT JSON (some 8.2-era builds).
323
- const plain = tryClientSecretJson(value);
324
- if (plain)
325
- return plain;
326
- // 2) Encrypted JSON — static controller key (8.6) then the 8.2 response key.
327
- // Tried BEFORE the bare-secret fallback, because base64 ciphertext with no
328
- // `+/=` chars would otherwise satisfy the bare-secret pattern.
351
+ export function parseClientSecret(raw) {
352
+ if (typeof raw !== "string") {
353
+ // Some deployments return the object directly.
354
+ return clientSecretOfObject(raw);
355
+ }
356
+ const value = raw.trim();
357
+ if (!value)
358
+ return undefined;
359
+ // 1) JSON (plaintext, or a JSON-encoded string of JSON).
360
+ const fromJson = clientSecretOfJson(value);
361
+ if (fromJson !== undefined)
362
+ return fromJson;
363
+ // 2) AES/ECB — static controller key (8.6) then the 8.2 response key.
329
364
  for (const key of [Buffer.from("bpm369!@#Authine", "utf8"), responseAesKey()]) {
330
365
  try {
331
366
  const decrypted = aesEcbDecryptBase64(value, key);
332
- const secret = tryClientSecretJson(decrypted) ?? tryClientSecretJson(decrypted.replace(/^"|"$/g, ""));
333
- if (secret)
367
+ const secret = clientSecretOfJson(decrypted);
368
+ if (secret !== undefined)
334
369
  return secret;
335
370
  }
336
371
  catch {
337
372
  /* try the next key */
338
373
  }
339
374
  }
340
- // 3) A bare secret string.
341
- const bare = value.trim();
342
- if (/^[A-Za-z0-9_-]{8,}$/.test(bare) && !bare.startsWith("{"))
343
- return bare;
344
- throw new CloudPivotAuthenticationError("CloudPivot OAuth client configuration could not be read (plaintext or encrypted).");
345
- }
346
- /** Parses `{"client_secret": "…"}`; returns undefined when it is not such JSON. */
347
- function tryClientSecretJson(value) {
348
- const text = value.trim();
349
- if (!text.startsWith("{"))
350
- return undefined;
375
+ // 3) base64 of JSON (no encryption layer).
351
376
  try {
352
- const parsed = JSON.parse(text);
353
- if (typeof parsed.client_secret === "string" && parsed.client_secret)
354
- return parsed.client_secret;
377
+ const decoded = Buffer.from(value, "base64").toString("utf8");
378
+ const secret = clientSecretOfJson(decoded);
379
+ if (secret !== undefined)
380
+ return secret;
355
381
  }
356
382
  catch {
357
- /* not JSON */
383
+ /* not base64 */
384
+ }
385
+ // 4) A bare secret string.
386
+ return /^[A-Za-z0-9_-]{8,}$/.test(value) && !value.startsWith("{") ? value : undefined;
387
+ }
388
+ /**
389
+ * The secret from a JSON blob, unwrapping nested/quoted forms; undefined if
390
+ * absent or unparseable. A JSON-encoded string (`"{\"client_secret\":…}"`) is
391
+ * decoded by `JSON.parse`, not by stripping quotes — the inner payload keeps
392
+ * its backslashes otherwise and never parses.
393
+ */
394
+ function clientSecretOfJson(value) {
395
+ let text = value.trim();
396
+ for (let depth = 0; depth < 3; depth += 1) {
397
+ if (!text)
398
+ return undefined;
399
+ if (text.startsWith('"')) {
400
+ let inner;
401
+ try {
402
+ inner = JSON.parse(text);
403
+ }
404
+ catch {
405
+ return undefined;
406
+ }
407
+ if (typeof inner !== "string")
408
+ return undefined;
409
+ text = inner.trim();
410
+ continue;
411
+ }
412
+ if (!text.startsWith("{"))
413
+ return undefined;
414
+ let parsed;
415
+ try {
416
+ parsed = JSON.parse(text);
417
+ }
418
+ catch {
419
+ return undefined;
420
+ }
421
+ if (typeof parsed === "string") {
422
+ text = parsed.trim();
423
+ continue;
424
+ }
425
+ return clientSecretOfObject(parsed);
358
426
  }
359
427
  return undefined;
360
428
  }
429
+ /** Reads `client_secret` / `clientSecret` / `secret` (top level or nested under `client`). */
430
+ function clientSecretOfObject(value) {
431
+ if (!isRecord(value))
432
+ return undefined;
433
+ for (const key of ["client_secret", "clientSecret", "secret"]) {
434
+ const secret = value[key];
435
+ if (typeof secret === "string" && secret.trim())
436
+ return secret.trim();
437
+ }
438
+ const nested = value.client;
439
+ return nested !== value && nested !== undefined ? clientSecretOfObject(nested) : undefined;
440
+ }
361
441
  /**
362
442
  * Ticket 92 — the bizservice METHOD configJson encryption boundary, symmetric
363
443
  * to decryptClientSecret and using the same static controller key.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/dbsweep.js CHANGED
File without changes
File without changes
@@ -109,15 +109,15 @@ export class DeliveryLedger {
109
109
  constructor(databasePath) {
110
110
  mkdirSync(dirname(databasePath), { recursive: true });
111
111
  this.db = new DatabaseSync(databasePath);
112
- this.db.exec(`CREATE TABLE IF NOT EXISTS delivery_event (
113
- sequence INTEGER PRIMARY KEY AUTOINCREMENT,
114
- delivery_id TEXT NOT NULL,
115
- at TEXT NOT NULL,
116
- type TEXT NOT NULL,
117
- binding_json TEXT NOT NULL,
118
- payload_json TEXT NOT NULL
119
- ,event_hash TEXT NOT NULL DEFAULT ''
120
- ,previous_hash TEXT NOT NULL DEFAULT ''
112
+ this.db.exec(`CREATE TABLE IF NOT EXISTS delivery_event (
113
+ sequence INTEGER PRIMARY KEY AUTOINCREMENT,
114
+ delivery_id TEXT NOT NULL,
115
+ at TEXT NOT NULL,
116
+ type TEXT NOT NULL,
117
+ binding_json TEXT NOT NULL,
118
+ payload_json TEXT NOT NULL
119
+ ,event_hash TEXT NOT NULL DEFAULT ''
120
+ ,previous_hash TEXT NOT NULL DEFAULT ''
121
121
  )`);
122
122
  for (const column of ["event_hash TEXT NOT NULL DEFAULT ''", "previous_hash TEXT NOT NULL DEFAULT ''"]) {
123
123
  try {
File without changes
package/dist/dsh-rpc.js CHANGED
File without changes
package/dist/dsh-run.js CHANGED
File without changes
File without changes
@@ -12,12 +12,12 @@ export class EnvironmentReleaseLedger {
12
12
  constructor(databasePath) {
13
13
  mkdirSync(dirname(databasePath), { recursive: true });
14
14
  this.db = new DatabaseSync(databasePath);
15
- this.db.exec(`CREATE TABLE IF NOT EXISTS release_event (
16
- sequence INTEGER PRIMARY KEY AUTOINCREMENT,
17
- release_id TEXT NOT NULL,
18
- at TEXT NOT NULL,
19
- type TEXT NOT NULL,
20
- payload_json TEXT NOT NULL
15
+ this.db.exec(`CREATE TABLE IF NOT EXISTS release_event (
16
+ sequence INTEGER PRIMARY KEY AUTOINCREMENT,
17
+ release_id TEXT NOT NULL,
18
+ at TEXT NOT NULL,
19
+ type TEXT NOT NULL,
20
+ payload_json TEXT NOT NULL
21
21
  )`);
22
22
  }
23
23
  open(input) {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes