create-principles-disciple 1.142.0 → 1.142.2
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/console/dist/ui/api.js +6 -3
- package/console/dist/ui/utils/__tests__/token-storage.test.d.ts +1 -0
- package/console/dist/ui/utils/__tests__/token-storage.test.js +64 -0
- package/console/dist/ui/utils/token-storage.d.ts +22 -0
- package/console/dist/ui/utils/token-storage.js +47 -0
- package/console/dist/web/assets/app.js +34 -4
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +144 -0
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/artificer-l2-adapter.test.js +54 -0
- package/core/dist/runtime-v2/adapter/__tests__/artificer-l2-adapter.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/artificer-l2-adapter.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/artificer-l2-adapter.js +53 -1
- package/core/dist/runtime-v2/adapter/artificer-l2-adapter.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/scribe-intent-contract-normalization.test.d.ts +2 -0
- package/core/dist/runtime-v2/internalization/__tests__/scribe-intent-contract-normalization.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/scribe-intent-contract-normalization.test.js +78 -0
- package/core/dist/runtime-v2/internalization/__tests__/scribe-intent-contract-normalization.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/scribe-output.d.ts +13 -0
- package/core/dist/runtime-v2/internalization/scribe-output.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-output.js +32 -0
- package/core/dist/runtime-v2/internalization/scribe-output.js.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js +1 -0
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-runner.js +4 -0
- package/core/dist/runtime-v2/internalization/scribe-runner.js.map +1 -1
- package/core/dist/telemetry-event.d.ts +19 -36
- package/core/dist/telemetry-event.d.ts.map +1 -1
- package/core/dist/telemetry-event.js +256 -59
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/package.json +1 -1
- package/package.json +2 -2
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +15 -3
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +8 -0
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts +9 -0
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +47 -4
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +460 -454
- package/plugin/dist/core/signal-collector-host.d.ts +6 -0
- package/plugin/dist/core/trajectory.d.ts +8 -0
- package/plugin/dist/governance-audit.js +149 -149
- package/plugin/dist/rulehost-evidence.js +126 -122
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/package.json +2 -2
package/console/dist/ui/api.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { clearStoredToken, loadStoredToken, storeToken } from "./utils/token-storage.js";
|
|
1
2
|
import { listActiveSignalKeywords, listPendingSignalTerms, fetchKeywordStore, fetchPendingTerms, updateKeywordStore, admitPendingTerm, rejectPendingTerm, } from "./utils/signal-keywords-api.js";
|
|
2
3
|
import { validateErrorResponse, validateHeaders, validateFeedbackReport, validateFeedbackDraftsList, validateFeedbackDraftEnvelope, validateFeedbackChannels, validateFeedbackSubmitResult, validateDeleteEnvelope, validateWorkspaceEntry, validateWorkspaceList, validateRemovedEnvelope, validateSyncResult, validateConfigSummary, validateConfigCatalog, validateAgentBindingUpdate, validateDefaultRuntimeUpdate, validateRuntimeProfileMutation, validateReadinessCheck, validateFeatureFlagUpdate, validateOutputLanguage, validateGovernanceQueue, validateRecoveryResult, validateFailedTaskDetail, validateOwnerDecisionsData, validateOwnerResolutionResult, validateActivations, validateDisableActivation, validateLifecycleMetrics, validateUpdateStatus, validateUpdateHistory, validateApplyUpdateResult, validateRollbackResult, validateApprovalRecordDirect, validatePrinciplesList, validateCorePrinciples, validateApprovalsGrouped, validateEvidenceChain, validateTrajectoryData, validateIntentSummary, validateIntentDecisionList, validateIntentDecisionResult, validateIntentDecisionSummary, validateFollowUpResponse, validateIntentInitResult, validateIntentSaveResult, validateIntentRawContent, validateIntentVersions, validateOwnerGovernanceView, validateGovernanceExperienceSnapshot, validateRuleCodeOwnerReview, validateRuleCodeMutation, validateOwnerIdentityView, validateOwnerIdentityRegister, validateOwnerIdentityUnregister, } from "./utils/validators.js";
|
|
3
4
|
// ── Auth ──────────────────────────────────────────────────────────────────────
|
|
4
5
|
function getToken() {
|
|
5
|
-
|
|
6
|
+
// PRI-793: localStorage-backed (with one-time migration from the legacy
|
|
7
|
+
// sessionStorage copy) so the token survives browser restarts.
|
|
8
|
+
return loadStoredToken();
|
|
6
9
|
}
|
|
7
10
|
function setToken(token) {
|
|
8
|
-
|
|
11
|
+
storeToken(token);
|
|
9
12
|
}
|
|
10
13
|
function clearToken() {
|
|
11
|
-
|
|
14
|
+
clearStoredToken();
|
|
12
15
|
}
|
|
13
16
|
/**
|
|
14
17
|
* True when an unauthorized response should route the UI to the login route.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { clearStoredToken, loadStoredToken, storeToken } from "../token-storage.js";
|
|
3
|
+
/** Minimal in-memory Storage double (no window dependency). */
|
|
4
|
+
function fakeStorage() {
|
|
5
|
+
const map = new Map();
|
|
6
|
+
return {
|
|
7
|
+
get length() {
|
|
8
|
+
return map.size;
|
|
9
|
+
},
|
|
10
|
+
clear: () => map.clear(),
|
|
11
|
+
getItem: (k) => (map.has(k) ? map.get(k) : null),
|
|
12
|
+
key: (i) => Array.from(map.keys())[i] ?? null,
|
|
13
|
+
removeItem: (k) => void map.delete(k),
|
|
14
|
+
setItem: (k, v) => void map.set(k, v),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
describe("token-storage (PRI-793)", () => {
|
|
18
|
+
it("stores into localStorage and leaves no sessionStorage copy", () => {
|
|
19
|
+
const main = fakeStorage();
|
|
20
|
+
const legacy = fakeStorage();
|
|
21
|
+
storeToken("tok-1", main, legacy);
|
|
22
|
+
expect(main.getItem("pd_token")).toBe("tok-1");
|
|
23
|
+
expect(legacy.getItem("pd_token")).toBe(null);
|
|
24
|
+
});
|
|
25
|
+
it("loads the persisted token across 'browser restarts'", () => {
|
|
26
|
+
const main = fakeStorage();
|
|
27
|
+
const legacy = fakeStorage();
|
|
28
|
+
storeToken("tok-2", main, legacy);
|
|
29
|
+
expect(loadStoredToken(main, legacy)).toBe("tok-2");
|
|
30
|
+
});
|
|
31
|
+
it("migrates a legacy sessionStorage token once, then owns it in localStorage only", () => {
|
|
32
|
+
const main = fakeStorage();
|
|
33
|
+
const legacy = fakeStorage();
|
|
34
|
+
legacy.setItem("pd_token", "legacy-tok");
|
|
35
|
+
expect(loadStoredToken(main, legacy)).toBe("legacy-tok");
|
|
36
|
+
expect(main.getItem("pd_token")).toBe("legacy-tok");
|
|
37
|
+
expect(legacy.getItem("pd_token")).toBe(null);
|
|
38
|
+
});
|
|
39
|
+
it("returns null when nothing is stored anywhere", () => {
|
|
40
|
+
expect(loadStoredToken(fakeStorage(), fakeStorage())).toBe(null);
|
|
41
|
+
});
|
|
42
|
+
it("clear removes both storage copies so a stale token cannot resurrect", () => {
|
|
43
|
+
const main = fakeStorage();
|
|
44
|
+
const legacy = fakeStorage();
|
|
45
|
+
storeToken("tok-3", main, legacy);
|
|
46
|
+
legacy.setItem("pd_token", "stale");
|
|
47
|
+
clearStoredToken(main, legacy);
|
|
48
|
+
expect(main.getItem("pd_token")).toBe(null);
|
|
49
|
+
expect(legacy.getItem("pd_token")).toBe(null);
|
|
50
|
+
expect(loadStoredToken(main, legacy)).toBe(null);
|
|
51
|
+
});
|
|
52
|
+
it("re-login overwrites the persisted token", () => {
|
|
53
|
+
const main = fakeStorage();
|
|
54
|
+
const legacy = fakeStorage();
|
|
55
|
+
storeToken("old", main, legacy);
|
|
56
|
+
storeToken("new", main, legacy);
|
|
57
|
+
expect(loadStoredToken(main, legacy)).toBe("new");
|
|
58
|
+
});
|
|
59
|
+
it("degrades gracefully when no Storage exists (non-DOM environment)", () => {
|
|
60
|
+
expect(loadStoredToken(null, null)).toBe(null);
|
|
61
|
+
expect(() => storeToken("tok", null, null)).not.toThrow();
|
|
62
|
+
expect(() => clearStoredToken(null, null)).not.toThrow();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-side persistence for the Console login token (PRI-793).
|
|
3
|
+
*
|
|
4
|
+
* The token lives in localStorage so the Owner is not re-prompted on every
|
|
5
|
+
* browser start. sessionStorage is only a migration source: a token left
|
|
6
|
+
* there by older builds is promoted to localStorage once and then removed —
|
|
7
|
+
* localStorage is the single source of truth afterwards (P4).
|
|
8
|
+
*
|
|
9
|
+
* Clearing (logout / Settings "清除凭证") removes both keys so a stale copy
|
|
10
|
+
* can never resurrect the session.
|
|
11
|
+
*
|
|
12
|
+
* Storages are resolved from globalThis (browsers expose localStorage /
|
|
13
|
+
* sessionStorage there) and may be absent — non-DOM test environments run
|
|
14
|
+
* the same code path with null storages, where persistence degrades to
|
|
15
|
+
* "no stored token" instead of crashing. Explicit arguments override the
|
|
16
|
+
* builtins for tests.
|
|
17
|
+
*/
|
|
18
|
+
type TokenStorage = Storage | null | undefined;
|
|
19
|
+
export declare function loadStoredToken(storage?: TokenStorage, legacy?: TokenStorage): string | null;
|
|
20
|
+
export declare function storeToken(token: string, storage?: TokenStorage, legacy?: TokenStorage): void;
|
|
21
|
+
export declare function clearStoredToken(storage?: TokenStorage, legacy?: TokenStorage): void;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-side persistence for the Console login token (PRI-793).
|
|
3
|
+
*
|
|
4
|
+
* The token lives in localStorage so the Owner is not re-prompted on every
|
|
5
|
+
* browser start. sessionStorage is only a migration source: a token left
|
|
6
|
+
* there by older builds is promoted to localStorage once and then removed —
|
|
7
|
+
* localStorage is the single source of truth afterwards (P4).
|
|
8
|
+
*
|
|
9
|
+
* Clearing (logout / Settings "清除凭证") removes both keys so a stale copy
|
|
10
|
+
* can never resurrect the session.
|
|
11
|
+
*
|
|
12
|
+
* Storages are resolved from globalThis (browsers expose localStorage /
|
|
13
|
+
* sessionStorage there) and may be absent — non-DOM test environments run
|
|
14
|
+
* the same code path with null storages, where persistence degrades to
|
|
15
|
+
* "no stored token" instead of crashing. Explicit arguments override the
|
|
16
|
+
* builtins for tests.
|
|
17
|
+
*/
|
|
18
|
+
const TOKEN_KEY = "pd_token";
|
|
19
|
+
function builtin(kind) {
|
|
20
|
+
const g = globalThis;
|
|
21
|
+
return (kind === "local" ? g.localStorage : g.sessionStorage) ?? null;
|
|
22
|
+
}
|
|
23
|
+
export function loadStoredToken(storage, legacy) {
|
|
24
|
+
const main = storage ?? builtin("local");
|
|
25
|
+
const old = legacy ?? builtin("session");
|
|
26
|
+
const current = main?.getItem(TOKEN_KEY) ?? null;
|
|
27
|
+
if (current !== null)
|
|
28
|
+
return current;
|
|
29
|
+
const legacyToken = old?.getItem(TOKEN_KEY) ?? null;
|
|
30
|
+
if (legacyToken === null)
|
|
31
|
+
return null;
|
|
32
|
+
main?.setItem(TOKEN_KEY, legacyToken);
|
|
33
|
+
old?.removeItem(TOKEN_KEY);
|
|
34
|
+
return legacyToken;
|
|
35
|
+
}
|
|
36
|
+
export function storeToken(token, storage, legacy) {
|
|
37
|
+
const main = storage ?? builtin("local");
|
|
38
|
+
const old = legacy ?? builtin("session");
|
|
39
|
+
main?.setItem(TOKEN_KEY, token);
|
|
40
|
+
old?.removeItem(TOKEN_KEY);
|
|
41
|
+
}
|
|
42
|
+
export function clearStoredToken(storage, legacy) {
|
|
43
|
+
const main = storage ?? builtin("local");
|
|
44
|
+
const old = legacy ?? builtin("session");
|
|
45
|
+
main?.removeItem(TOKEN_KEY);
|
|
46
|
+
old?.removeItem(TOKEN_KEY);
|
|
47
|
+
}
|