chainlesschain 0.143.0 → 0.145.0
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/package.json +1 -1
- package/src/commands/a2a.js +196 -28
- package/src/commands/activitypub.js +157 -27
- package/src/commands/agent.js +587 -103
- package/src/commands/audit.js +206 -0
- package/src/commands/bi.js +152 -27
- package/src/commands/bm25.js +111 -27
- package/src/commands/browse.js +190 -29
- package/src/commands/ccron.js +128 -28
- package/src/commands/chat.js +207 -0
- package/src/commands/compliance.js +414 -34
- package/src/commands/compt.js +127 -29
- package/src/commands/consol.js +8 -2
- package/src/commands/cowork.js +580 -34
- package/src/commands/crosschain.js +182 -28
- package/src/commands/dao.js +182 -28
- package/src/commands/dlp.js +172 -27
- package/src/commands/economy.js +205 -50
- package/src/commands/evolution.js +203 -50
- package/src/commands/evomap.js +182 -27
- package/src/commands/fflag.js +74 -22
- package/src/commands/git.js +177 -37
- package/src/commands/hardening.js +209 -0
- package/src/commands/hmemory.js +204 -50
- package/src/commands/incentive.js +209 -0
- package/src/commands/inference.js +170 -34
- package/src/commands/itbudget.js +149 -33
- package/src/commands/kg.js +206 -0
- package/src/commands/lowcode.js +195 -38
- package/src/commands/marketplace.js +206 -0
- package/src/commands/matrix.js +179 -27
- package/src/commands/mcpscaf.js +145 -33
- package/src/commands/meminj.js +145 -33
- package/src/commands/nostr.js +178 -27
- package/src/commands/orchestrate.js +217 -0
- package/src/commands/orchgov.js +144 -33
- package/src/commands/pdfp.js +109 -27
- package/src/commands/perf.js +169 -32
- package/src/commands/perm.js +144 -33
- package/src/commands/pipeline.js +207 -52
- package/src/commands/planmode.js +141 -32
- package/src/commands/privacy.js +203 -0
- package/src/commands/promcomp.js +111 -27
- package/src/commands/recommend.js +177 -34
- package/src/commands/reputation.js +208 -0
- package/src/commands/sandbox.js +206 -0
- package/src/commands/seshhook.js +145 -33
- package/src/commands/seshsearch.js +141 -33
- package/src/commands/seshtail.js +144 -33
- package/src/commands/seshu.js +152 -33
- package/src/commands/sganal.js +123 -29
- package/src/commands/siem.js +201 -34
- package/src/commands/sla.js +212 -0
- package/src/commands/slotfill.js +146 -33
- package/src/commands/social.js +157 -32
- package/src/commands/stress.js +206 -0
- package/src/commands/svccont.js +145 -33
- package/src/commands/terraform.js +206 -0
- package/src/commands/tms.js +171 -33
- package/src/commands/topiccls.js +146 -33
- package/src/commands/uprof.js +141 -32
- package/src/commands/vcheck.js +122 -28
- package/src/commands/webfetch.js +141 -32
- package/src/commands/zkp.js +184 -28
- package/src/index.js +40 -0
- package/src/lib/a2a-protocol.js +319 -51
- package/src/lib/activitypub-bridge.js +288 -50
- package/src/lib/agent-economy.js +304 -51
- package/src/lib/app-builder.js +279 -46
- package/src/lib/audit-logger.js +321 -0
- package/src/lib/autonomous-agent.js +284 -48
- package/src/lib/bi-engine.js +283 -49
- package/src/lib/bm25-search.js +301 -49
- package/src/lib/browser-automation.js +296 -49
- package/src/lib/chat-core.js +336 -0
- package/src/lib/claude-code-bridge.js +341 -0
- package/src/lib/compliance-framework-reporter.js +305 -51
- package/src/lib/compliance-manager.js +330 -0
- package/src/lib/compression-telemetry.js +301 -49
- package/src/lib/content-recommender.js +317 -52
- package/src/lib/cowork-cron.js +298 -49
- package/src/lib/cowork-learning.js +333 -0
- package/src/lib/cowork-task-runner.js +308 -51
- package/src/lib/cowork-workflow.js +327 -0
- package/src/lib/cross-chain.js +311 -51
- package/src/lib/dao-governance.js +280 -46
- package/src/lib/dlp-engine.js +287 -49
- package/src/lib/evolution-system.js +278 -47
- package/src/lib/evomap-manager.js +280 -46
- package/src/lib/execution-backend.js +294 -48
- package/src/lib/feature-flags.js +294 -49
- package/src/lib/git-integration.js +285 -47
- package/src/lib/hardening-manager.js +341 -0
- package/src/lib/hierarchical-memory.js +284 -48
- package/src/lib/inference-network.js +308 -51
- package/src/lib/iteration-budget.js +302 -50
- package/src/lib/knowledge-graph.js +333 -0
- package/src/lib/matrix-bridge.js +281 -47
- package/src/lib/mcp-scaffold.js +318 -54
- package/src/lib/memory-injection.js +288 -49
- package/src/lib/nostr-bridge.js +286 -49
- package/src/lib/orchestrator.js +293 -48
- package/src/lib/pdf-parser.js +298 -49
- package/src/lib/perf-tuning.js +309 -50
- package/src/lib/permission-engine.js +287 -49
- package/src/lib/pipeline-orchestrator.js +289 -49
- package/src/lib/plan-mode.js +298 -51
- package/src/lib/privacy-computing.js +335 -0
- package/src/lib/reputation-optimizer.js +340 -0
- package/src/lib/sandbox-v2.js +327 -0
- package/src/lib/service-container.js +313 -52
- package/src/lib/session-consolidator.js +296 -49
- package/src/lib/session-hooks.js +312 -53
- package/src/lib/session-search.js +304 -51
- package/src/lib/session-tail.js +288 -49
- package/src/lib/session-usage.js +298 -52
- package/src/lib/siem-exporter.js +298 -51
- package/src/lib/skill-marketplace.js +345 -0
- package/src/lib/sla-manager.js +341 -0
- package/src/lib/slot-filler.js +303 -51
- package/src/lib/social-graph-analytics.js +295 -49
- package/src/lib/social-graph.js +272 -49
- package/src/lib/stress-tester.js +342 -0
- package/src/lib/sub-agent-registry.js +302 -53
- package/src/lib/task-model-selector.js +302 -50
- package/src/lib/terraform-manager.js +333 -0
- package/src/lib/todo-manager.js +281 -47
- package/src/lib/token-incentive.js +341 -0
- package/src/lib/topic-classifier.js +297 -49
- package/src/lib/user-profile.js +294 -50
- package/src/lib/version-checker.js +304 -50
- package/src/lib/web-fetch.js +292 -51
- package/src/lib/zkp-engine.js +286 -49
package/src/lib/app-builder.js
CHANGED
|
@@ -743,25 +743,53 @@ export function _resetV2State() {
|
|
|
743
743
|
_v2StatusHistory.clear();
|
|
744
744
|
}
|
|
745
745
|
|
|
746
|
-
|
|
747
746
|
// ===== V2 Surface: App Builder governance overlay (CLI v0.138.0) =====
|
|
748
747
|
export const APP_MATURITY_V2 = Object.freeze({
|
|
749
|
-
PENDING: "pending",
|
|
748
|
+
PENDING: "pending",
|
|
749
|
+
ACTIVE: "active",
|
|
750
|
+
PAUSED: "paused",
|
|
751
|
+
ARCHIVED: "archived",
|
|
750
752
|
});
|
|
751
753
|
export const APP_BUILD_LIFECYCLE_V2 = Object.freeze({
|
|
752
|
-
QUEUED: "queued",
|
|
754
|
+
QUEUED: "queued",
|
|
755
|
+
BUILDING: "building",
|
|
756
|
+
SUCCEEDED: "succeeded",
|
|
757
|
+
FAILED: "failed",
|
|
758
|
+
CANCELLED: "cancelled",
|
|
753
759
|
});
|
|
754
760
|
|
|
755
761
|
const _appTrans = new Map([
|
|
756
|
-
[
|
|
757
|
-
|
|
758
|
-
|
|
762
|
+
[
|
|
763
|
+
APP_MATURITY_V2.PENDING,
|
|
764
|
+
new Set([APP_MATURITY_V2.ACTIVE, APP_MATURITY_V2.ARCHIVED]),
|
|
765
|
+
],
|
|
766
|
+
[
|
|
767
|
+
APP_MATURITY_V2.ACTIVE,
|
|
768
|
+
new Set([APP_MATURITY_V2.PAUSED, APP_MATURITY_V2.ARCHIVED]),
|
|
769
|
+
],
|
|
770
|
+
[
|
|
771
|
+
APP_MATURITY_V2.PAUSED,
|
|
772
|
+
new Set([APP_MATURITY_V2.ACTIVE, APP_MATURITY_V2.ARCHIVED]),
|
|
773
|
+
],
|
|
759
774
|
[APP_MATURITY_V2.ARCHIVED, new Set()],
|
|
760
775
|
]);
|
|
761
776
|
const _appTerminal = new Set([APP_MATURITY_V2.ARCHIVED]);
|
|
762
777
|
const _appBuildTrans = new Map([
|
|
763
|
-
[
|
|
764
|
-
|
|
778
|
+
[
|
|
779
|
+
APP_BUILD_LIFECYCLE_V2.QUEUED,
|
|
780
|
+
new Set([
|
|
781
|
+
APP_BUILD_LIFECYCLE_V2.BUILDING,
|
|
782
|
+
APP_BUILD_LIFECYCLE_V2.CANCELLED,
|
|
783
|
+
]),
|
|
784
|
+
],
|
|
785
|
+
[
|
|
786
|
+
APP_BUILD_LIFECYCLE_V2.BUILDING,
|
|
787
|
+
new Set([
|
|
788
|
+
APP_BUILD_LIFECYCLE_V2.SUCCEEDED,
|
|
789
|
+
APP_BUILD_LIFECYCLE_V2.FAILED,
|
|
790
|
+
APP_BUILD_LIFECYCLE_V2.CANCELLED,
|
|
791
|
+
]),
|
|
792
|
+
],
|
|
765
793
|
[APP_BUILD_LIFECYCLE_V2.SUCCEEDED, new Set()],
|
|
766
794
|
[APP_BUILD_LIFECYCLE_V2.FAILED, new Set()],
|
|
767
795
|
[APP_BUILD_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
@@ -774,21 +802,45 @@ let _appMaxPendingBuildsPerApp = 20;
|
|
|
774
802
|
let _appIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
775
803
|
let _appBuildStuckMs = 10 * 60 * 1000;
|
|
776
804
|
|
|
777
|
-
function _appPos(n, lbl) {
|
|
805
|
+
function _appPos(n, lbl) {
|
|
806
|
+
const v = Math.floor(Number(n));
|
|
807
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
808
|
+
throw new Error(`${lbl} must be positive integer`);
|
|
809
|
+
return v;
|
|
810
|
+
}
|
|
778
811
|
|
|
779
|
-
export function setMaxActiveAppsPerOwnerV2(n) {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
export function
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
export function
|
|
786
|
-
|
|
812
|
+
export function setMaxActiveAppsPerOwnerV2(n) {
|
|
813
|
+
_appMaxActivePerOwner = _appPos(n, "maxActiveAppsPerOwner");
|
|
814
|
+
}
|
|
815
|
+
export function getMaxActiveAppsPerOwnerV2() {
|
|
816
|
+
return _appMaxActivePerOwner;
|
|
817
|
+
}
|
|
818
|
+
export function setMaxPendingAppBuildsPerAppV2(n) {
|
|
819
|
+
_appMaxPendingBuildsPerApp = _appPos(n, "maxPendingAppBuildsPerApp");
|
|
820
|
+
}
|
|
821
|
+
export function getMaxPendingAppBuildsPerAppV2() {
|
|
822
|
+
return _appMaxPendingBuildsPerApp;
|
|
823
|
+
}
|
|
824
|
+
export function setAppIdleMsV2(n) {
|
|
825
|
+
_appIdleMs = _appPos(n, "appIdleMs");
|
|
826
|
+
}
|
|
827
|
+
export function getAppIdleMsV2() {
|
|
828
|
+
return _appIdleMs;
|
|
829
|
+
}
|
|
830
|
+
export function setAppBuildStuckMsV2(n) {
|
|
831
|
+
_appBuildStuckMs = _appPos(n, "appBuildStuckMs");
|
|
832
|
+
}
|
|
833
|
+
export function getAppBuildStuckMsV2() {
|
|
834
|
+
return _appBuildStuckMs;
|
|
835
|
+
}
|
|
787
836
|
|
|
788
837
|
export function _resetStateAppBuilderV2() {
|
|
789
|
-
_appsV2.clear();
|
|
790
|
-
|
|
791
|
-
|
|
838
|
+
_appsV2.clear();
|
|
839
|
+
_appBuilds.clear();
|
|
840
|
+
_appMaxActivePerOwner = 10;
|
|
841
|
+
_appMaxPendingBuildsPerApp = 20;
|
|
842
|
+
_appIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
843
|
+
_appBuildStuckMs = 10 * 60 * 1000;
|
|
792
844
|
}
|
|
793
845
|
|
|
794
846
|
export function registerAppV2({ id, owner, name, metadata } = {}) {
|
|
@@ -796,28 +848,103 @@ export function registerAppV2({ id, owner, name, metadata } = {}) {
|
|
|
796
848
|
if (!owner || typeof owner !== "string") throw new Error("owner is required");
|
|
797
849
|
if (_appsV2.has(id)) throw new Error(`app ${id} already registered`);
|
|
798
850
|
const now = Date.now();
|
|
799
|
-
const a = {
|
|
851
|
+
const a = {
|
|
852
|
+
id,
|
|
853
|
+
owner,
|
|
854
|
+
name: name || id,
|
|
855
|
+
status: APP_MATURITY_V2.PENDING,
|
|
856
|
+
createdAt: now,
|
|
857
|
+
updatedAt: now,
|
|
858
|
+
activatedAt: null,
|
|
859
|
+
archivedAt: null,
|
|
860
|
+
lastTouchedAt: now,
|
|
861
|
+
metadata: { ...(metadata || {}) },
|
|
862
|
+
};
|
|
800
863
|
_appsV2.set(id, a);
|
|
801
864
|
return { ...a, metadata: { ...a.metadata } };
|
|
802
865
|
}
|
|
803
|
-
function _appCheckA(from, to) {
|
|
804
|
-
|
|
866
|
+
function _appCheckA(from, to) {
|
|
867
|
+
const a = _appTrans.get(from);
|
|
868
|
+
if (!a || !a.has(to))
|
|
869
|
+
throw new Error(`invalid app transition ${from} → ${to}`);
|
|
870
|
+
}
|
|
871
|
+
function _appCountActive(owner) {
|
|
872
|
+
let n = 0;
|
|
873
|
+
for (const a of _appsV2.values())
|
|
874
|
+
if (a.owner === owner && a.status === APP_MATURITY_V2.ACTIVE) n++;
|
|
875
|
+
return n;
|
|
876
|
+
}
|
|
805
877
|
|
|
806
878
|
export function activateAppV2(id) {
|
|
807
|
-
const a = _appsV2.get(id);
|
|
879
|
+
const a = _appsV2.get(id);
|
|
880
|
+
if (!a) throw new Error(`app ${id} not found`);
|
|
808
881
|
_appCheckA(a.status, APP_MATURITY_V2.ACTIVE);
|
|
809
882
|
const recovery = a.status === APP_MATURITY_V2.PAUSED;
|
|
810
|
-
if (!recovery) {
|
|
811
|
-
|
|
883
|
+
if (!recovery) {
|
|
884
|
+
const c = _appCountActive(a.owner);
|
|
885
|
+
if (c >= _appMaxActivePerOwner)
|
|
886
|
+
throw new Error(
|
|
887
|
+
`max active apps per owner (${_appMaxActivePerOwner}) reached for ${a.owner}`,
|
|
888
|
+
);
|
|
889
|
+
}
|
|
890
|
+
const now = Date.now();
|
|
891
|
+
a.status = APP_MATURITY_V2.ACTIVE;
|
|
892
|
+
a.updatedAt = now;
|
|
893
|
+
a.lastTouchedAt = now;
|
|
894
|
+
if (!a.activatedAt) a.activatedAt = now;
|
|
895
|
+
return { ...a, metadata: { ...a.metadata } };
|
|
896
|
+
}
|
|
897
|
+
export function pauseAppV2(id) {
|
|
898
|
+
const a = _appsV2.get(id);
|
|
899
|
+
if (!a) throw new Error(`app ${id} not found`);
|
|
900
|
+
_appCheckA(a.status, APP_MATURITY_V2.PAUSED);
|
|
901
|
+
a.status = APP_MATURITY_V2.PAUSED;
|
|
902
|
+
a.updatedAt = Date.now();
|
|
903
|
+
return { ...a, metadata: { ...a.metadata } };
|
|
904
|
+
}
|
|
905
|
+
export function archiveAppV2(id) {
|
|
906
|
+
const a = _appsV2.get(id);
|
|
907
|
+
if (!a) throw new Error(`app ${id} not found`);
|
|
908
|
+
_appCheckA(a.status, APP_MATURITY_V2.ARCHIVED);
|
|
909
|
+
const now = Date.now();
|
|
910
|
+
a.status = APP_MATURITY_V2.ARCHIVED;
|
|
911
|
+
a.updatedAt = now;
|
|
912
|
+
if (!a.archivedAt) a.archivedAt = now;
|
|
812
913
|
return { ...a, metadata: { ...a.metadata } };
|
|
813
914
|
}
|
|
814
|
-
export function
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
915
|
+
export function touchAppV2(id) {
|
|
916
|
+
const a = _appsV2.get(id);
|
|
917
|
+
if (!a) throw new Error(`app ${id} not found`);
|
|
918
|
+
if (_appTerminal.has(a.status))
|
|
919
|
+
throw new Error(`cannot touch terminal app ${id}`);
|
|
920
|
+
const now = Date.now();
|
|
921
|
+
a.lastTouchedAt = now;
|
|
922
|
+
a.updatedAt = now;
|
|
923
|
+
return { ...a, metadata: { ...a.metadata } };
|
|
924
|
+
}
|
|
925
|
+
export function getAppV2(id) {
|
|
926
|
+
const a = _appsV2.get(id);
|
|
927
|
+
if (!a) return null;
|
|
928
|
+
return { ...a, metadata: { ...a.metadata } };
|
|
929
|
+
}
|
|
930
|
+
export function listAppsV2() {
|
|
931
|
+
return [..._appsV2.values()].map((a) => ({
|
|
932
|
+
...a,
|
|
933
|
+
metadata: { ...a.metadata },
|
|
934
|
+
}));
|
|
935
|
+
}
|
|
819
936
|
|
|
820
|
-
function _appCountPendingBuilds(appId) {
|
|
937
|
+
function _appCountPendingBuilds(appId) {
|
|
938
|
+
let n = 0;
|
|
939
|
+
for (const b of _appBuilds.values())
|
|
940
|
+
if (
|
|
941
|
+
b.appId === appId &&
|
|
942
|
+
(b.status === APP_BUILD_LIFECYCLE_V2.QUEUED ||
|
|
943
|
+
b.status === APP_BUILD_LIFECYCLE_V2.BUILDING)
|
|
944
|
+
)
|
|
945
|
+
n++;
|
|
946
|
+
return n;
|
|
947
|
+
}
|
|
821
948
|
|
|
822
949
|
export function createAppBuildV2({ id, appId, target, metadata } = {}) {
|
|
823
950
|
if (!id || typeof id !== "string") throw new Error("id is required");
|
|
@@ -825,25 +952,131 @@ export function createAppBuildV2({ id, appId, target, metadata } = {}) {
|
|
|
825
952
|
if (_appBuilds.has(id)) throw new Error(`app build ${id} already exists`);
|
|
826
953
|
if (!_appsV2.has(appId)) throw new Error(`app ${appId} not found`);
|
|
827
954
|
const pending = _appCountPendingBuilds(appId);
|
|
828
|
-
if (pending >= _appMaxPendingBuildsPerApp)
|
|
955
|
+
if (pending >= _appMaxPendingBuildsPerApp)
|
|
956
|
+
throw new Error(
|
|
957
|
+
`max pending app builds per app (${_appMaxPendingBuildsPerApp}) reached for ${appId}`,
|
|
958
|
+
);
|
|
829
959
|
const now = Date.now();
|
|
830
|
-
const b = {
|
|
960
|
+
const b = {
|
|
961
|
+
id,
|
|
962
|
+
appId,
|
|
963
|
+
target: target || "web",
|
|
964
|
+
status: APP_BUILD_LIFECYCLE_V2.QUEUED,
|
|
965
|
+
createdAt: now,
|
|
966
|
+
updatedAt: now,
|
|
967
|
+
startedAt: null,
|
|
968
|
+
settledAt: null,
|
|
969
|
+
metadata: { ...(metadata || {}) },
|
|
970
|
+
};
|
|
831
971
|
_appBuilds.set(id, b);
|
|
832
972
|
return { ...b, metadata: { ...b.metadata } };
|
|
833
973
|
}
|
|
834
|
-
function _appCheckB(from, to) {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
export function
|
|
840
|
-
|
|
974
|
+
function _appCheckB(from, to) {
|
|
975
|
+
const a = _appBuildTrans.get(from);
|
|
976
|
+
if (!a || !a.has(to))
|
|
977
|
+
throw new Error(`invalid app build transition ${from} → ${to}`);
|
|
978
|
+
}
|
|
979
|
+
export function startAppBuildV2(id) {
|
|
980
|
+
const b = _appBuilds.get(id);
|
|
981
|
+
if (!b) throw new Error(`app build ${id} not found`);
|
|
982
|
+
_appCheckB(b.status, APP_BUILD_LIFECYCLE_V2.BUILDING);
|
|
983
|
+
const now = Date.now();
|
|
984
|
+
b.status = APP_BUILD_LIFECYCLE_V2.BUILDING;
|
|
985
|
+
b.updatedAt = now;
|
|
986
|
+
if (!b.startedAt) b.startedAt = now;
|
|
987
|
+
return { ...b, metadata: { ...b.metadata } };
|
|
988
|
+
}
|
|
989
|
+
export function succeedAppBuildV2(id) {
|
|
990
|
+
const b = _appBuilds.get(id);
|
|
991
|
+
if (!b) throw new Error(`app build ${id} not found`);
|
|
992
|
+
_appCheckB(b.status, APP_BUILD_LIFECYCLE_V2.SUCCEEDED);
|
|
993
|
+
const now = Date.now();
|
|
994
|
+
b.status = APP_BUILD_LIFECYCLE_V2.SUCCEEDED;
|
|
995
|
+
b.updatedAt = now;
|
|
996
|
+
if (!b.settledAt) b.settledAt = now;
|
|
997
|
+
return { ...b, metadata: { ...b.metadata } };
|
|
998
|
+
}
|
|
999
|
+
export function failAppBuildV2(id, reason) {
|
|
1000
|
+
const b = _appBuilds.get(id);
|
|
1001
|
+
if (!b) throw new Error(`app build ${id} not found`);
|
|
1002
|
+
_appCheckB(b.status, APP_BUILD_LIFECYCLE_V2.FAILED);
|
|
1003
|
+
const now = Date.now();
|
|
1004
|
+
b.status = APP_BUILD_LIFECYCLE_V2.FAILED;
|
|
1005
|
+
b.updatedAt = now;
|
|
1006
|
+
if (!b.settledAt) b.settledAt = now;
|
|
1007
|
+
if (reason) b.metadata.failReason = String(reason);
|
|
1008
|
+
return { ...b, metadata: { ...b.metadata } };
|
|
1009
|
+
}
|
|
1010
|
+
export function cancelAppBuildV2(id, reason) {
|
|
1011
|
+
const b = _appBuilds.get(id);
|
|
1012
|
+
if (!b) throw new Error(`app build ${id} not found`);
|
|
1013
|
+
_appCheckB(b.status, APP_BUILD_LIFECYCLE_V2.CANCELLED);
|
|
1014
|
+
const now = Date.now();
|
|
1015
|
+
b.status = APP_BUILD_LIFECYCLE_V2.CANCELLED;
|
|
1016
|
+
b.updatedAt = now;
|
|
1017
|
+
if (!b.settledAt) b.settledAt = now;
|
|
1018
|
+
if (reason) b.metadata.cancelReason = String(reason);
|
|
1019
|
+
return { ...b, metadata: { ...b.metadata } };
|
|
1020
|
+
}
|
|
1021
|
+
export function getAppBuildV2(id) {
|
|
1022
|
+
const b = _appBuilds.get(id);
|
|
1023
|
+
if (!b) return null;
|
|
1024
|
+
return { ...b, metadata: { ...b.metadata } };
|
|
1025
|
+
}
|
|
1026
|
+
export function listAppBuildsV2() {
|
|
1027
|
+
return [..._appBuilds.values()].map((b) => ({
|
|
1028
|
+
...b,
|
|
1029
|
+
metadata: { ...b.metadata },
|
|
1030
|
+
}));
|
|
1031
|
+
}
|
|
841
1032
|
|
|
842
|
-
export function autoPauseIdleAppsV2({ now } = {}) {
|
|
843
|
-
|
|
1033
|
+
export function autoPauseIdleAppsV2({ now } = {}) {
|
|
1034
|
+
const t = now ?? Date.now();
|
|
1035
|
+
const flipped = [];
|
|
1036
|
+
for (const a of _appsV2.values())
|
|
1037
|
+
if (
|
|
1038
|
+
a.status === APP_MATURITY_V2.ACTIVE &&
|
|
1039
|
+
t - a.lastTouchedAt >= _appIdleMs
|
|
1040
|
+
) {
|
|
1041
|
+
a.status = APP_MATURITY_V2.PAUSED;
|
|
1042
|
+
a.updatedAt = t;
|
|
1043
|
+
flipped.push(a.id);
|
|
1044
|
+
}
|
|
1045
|
+
return { flipped, count: flipped.length };
|
|
1046
|
+
}
|
|
1047
|
+
export function autoFailStuckAppBuildsV2({ now } = {}) {
|
|
1048
|
+
const t = now ?? Date.now();
|
|
1049
|
+
const flipped = [];
|
|
1050
|
+
for (const b of _appBuilds.values())
|
|
1051
|
+
if (
|
|
1052
|
+
b.status === APP_BUILD_LIFECYCLE_V2.BUILDING &&
|
|
1053
|
+
b.startedAt != null &&
|
|
1054
|
+
t - b.startedAt >= _appBuildStuckMs
|
|
1055
|
+
) {
|
|
1056
|
+
b.status = APP_BUILD_LIFECYCLE_V2.FAILED;
|
|
1057
|
+
b.updatedAt = t;
|
|
1058
|
+
if (!b.settledAt) b.settledAt = t;
|
|
1059
|
+
b.metadata.failReason = "auto-fail-stuck";
|
|
1060
|
+
flipped.push(b.id);
|
|
1061
|
+
}
|
|
1062
|
+
return { flipped, count: flipped.length };
|
|
1063
|
+
}
|
|
844
1064
|
|
|
845
1065
|
export function getAppBuilderGovStatsV2() {
|
|
846
|
-
const appsByStatus = {};
|
|
847
|
-
|
|
848
|
-
|
|
1066
|
+
const appsByStatus = {};
|
|
1067
|
+
for (const s of Object.values(APP_MATURITY_V2)) appsByStatus[s] = 0;
|
|
1068
|
+
for (const a of _appsV2.values()) appsByStatus[a.status]++;
|
|
1069
|
+
const buildsByStatus = {};
|
|
1070
|
+
for (const s of Object.values(APP_BUILD_LIFECYCLE_V2)) buildsByStatus[s] = 0;
|
|
1071
|
+
for (const b of _appBuilds.values()) buildsByStatus[b.status]++;
|
|
1072
|
+
return {
|
|
1073
|
+
totalAppsV2: _appsV2.size,
|
|
1074
|
+
totalAppBuildsV2: _appBuilds.size,
|
|
1075
|
+
maxActiveAppsPerOwner: _appMaxActivePerOwner,
|
|
1076
|
+
maxPendingAppBuildsPerApp: _appMaxPendingBuildsPerApp,
|
|
1077
|
+
appIdleMs: _appIdleMs,
|
|
1078
|
+
appBuildStuckMs: _appBuildStuckMs,
|
|
1079
|
+
appsByStatus,
|
|
1080
|
+
buildsByStatus,
|
|
1081
|
+
};
|
|
849
1082
|
}
|