workspai 0.47.0 → 0.48.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.
Files changed (90) hide show
  1. package/README.md +214 -119
  2. package/contracts/agent-customization-pack.v1.json +5 -0
  3. package/contracts/extension-cli-compatibility.v1.json +7 -2
  4. package/contracts/published-contract-catalog.v1.json +28 -1
  5. package/contracts/runtime-command-surface.v1.json +145 -1
  6. package/contracts/workspace-intelligence/model-usage-event.v1.json +82 -0
  7. package/contracts/workspace-intelligence/workspace-intelligence-evaluation-comparison.v1.json +53 -0
  8. package/contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json +120 -0
  9. package/contracts/workspace-intelligence-architecture.v1.json +31 -2
  10. package/contracts/workspace-intelligence-chain.v1.json +44 -3
  11. package/dist/analyze-EEEU3MIF.js +1 -0
  12. package/dist/{artifact-remediation-plan-EPALZ2LC.js → artifact-remediation-plan-SPOUHMK5.js} +1 -1
  13. package/dist/autopilot-release-XGVXPOZI.js +1 -0
  14. package/dist/{chunk-2TEDAKP6.js → chunk-32OJDBIG.js} +1 -1
  15. package/dist/{chunk-ZDN7RHXJ.js → chunk-37CVKXBD.js} +1 -1
  16. package/dist/{chunk-YCL3I2JO.js → chunk-3NU32T4A.js} +1 -1
  17. package/dist/chunk-3VFA7D5T.js +1 -0
  18. package/dist/{chunk-CW7PGBIQ.js → chunk-4HDYADHT.js} +1 -1
  19. package/dist/{chunk-PBHP6JNY.js → chunk-54EP5CEV.js} +1 -1
  20. package/dist/{chunk-QDWYIRHR.js → chunk-5S3DJQEP.js} +1 -1
  21. package/dist/{chunk-NOFM7MNA.js → chunk-AFL3ACCR.js} +1 -1
  22. package/dist/{chunk-MEMHNE7Y.js → chunk-BFLJ2R4D.js} +1 -1
  23. package/dist/{chunk-6SWRNA47.js → chunk-BGPXQQNY.js} +1 -1
  24. package/dist/chunk-BMWFQXGW.js +1 -0
  25. package/dist/{chunk-2GHUZDYA.js → chunk-CRHYBQI3.js} +1 -1
  26. package/dist/{chunk-76YOPAOT.js → chunk-ESLPI3XZ.js} +1 -1
  27. package/dist/{chunk-DV6GJD4K.js → chunk-HDXNIN4N.js} +1 -1
  28. package/dist/{chunk-TNQI5VCW.js → chunk-HZDXO65G.js} +14 -14
  29. package/dist/{chunk-BSRVO52Y.js → chunk-I46XEIPL.js} +1 -1
  30. package/dist/{chunk-COARSXRC.js → chunk-J5ENLXDF.js} +1 -1
  31. package/dist/chunk-LHOZXC2M.js +2 -0
  32. package/dist/{chunk-RWRLFSKW.js → chunk-NAJCUQ4X.js} +1 -1
  33. package/dist/{chunk-ZM5NQ5Z2.js → chunk-OW42TZFB.js} +1 -1
  34. package/dist/{chunk-SK6XRKGG.js → chunk-P3D5YQB2.js} +1 -1
  35. package/dist/{chunk-TWNFECMN.js → chunk-PHXQR6PX.js} +1 -1
  36. package/dist/{chunk-ITCAMC2E.js → chunk-PRTR2DQ2.js} +1 -1
  37. package/dist/{chunk-KZZ36CK5.js → chunk-QNONOO4F.js} +1 -1
  38. package/dist/{chunk-7VLCK5JW.js → chunk-RHQW3DTP.js} +1 -1
  39. package/dist/{chunk-22NJ2ZMG.js → chunk-T4YR4RAI.js} +1 -1
  40. package/dist/{chunk-HSGFUKCN.js → chunk-VU7NZHPM.js} +1 -1
  41. package/dist/{chunk-VBSQ7MF6.js → chunk-Y5UJLPS4.js} +19 -19
  42. package/dist/{chunk-U5EZHZBX.js → chunk-YJZOMRAS.js} +1 -1
  43. package/dist/{create-7JKJDAQV.js → create-DBQNAMKP.js} +1 -1
  44. package/dist/{doctor-PGPNIS76.js → doctor-4NNUDNGZ.js} +1 -1
  45. package/dist/{dotnet-webapi-clean-6TVFBTVI.js → dotnet-webapi-clean-A6MVDYXX.js} +4 -4
  46. package/dist/{gofiber-standard-2BL7GWZB.js → gofiber-standard-I5YPQG5V.js} +1 -1
  47. package/dist/{gogin-standard-XGP3KBXA.js → gogin-standard-VY2L4QT5.js} +1 -1
  48. package/dist/index.d.ts +32 -11
  49. package/dist/index.js +127 -125
  50. package/dist/{pipeline-IB6ILJSV.js → pipeline-TQM43A3K.js} +1 -1
  51. package/dist/{springboot-standard-JJNUID6M.js → springboot-standard-55XKCBIZ.js} +4 -4
  52. package/dist/{workspace-H3QXBFGB.js → workspace-NCWRINEF.js} +1 -1
  53. package/dist/{workspace-agent-sync-C7SG2Z5W.js → workspace-agent-sync-662QHXGF.js} +1 -1
  54. package/dist/{workspace-context-BKQBKA4C.js → workspace-context-23YYCUCP.js} +1 -1
  55. package/dist/{workspace-contract-RPQQBQXR.js → workspace-contract-TU2I7GC2.js} +1 -1
  56. package/dist/{workspace-dependency-graph-23BI2HG7.js → workspace-dependency-graph-BP4EXYQ5.js} +1 -1
  57. package/dist/workspace-explain-MWUEN643.js +1 -0
  58. package/dist/workspace-explain-contract-ZPI3JXJU.js +1 -0
  59. package/dist/{workspace-feedback-WAID3IOE.js → workspace-feedback-SUVH2LUJ.js} +1 -1
  60. package/dist/{workspace-foundation-5OOJEO2D.js → workspace-foundation-WXJ6I7ES.js} +1 -1
  61. package/dist/{workspace-history-C6OP3IAQ.js → workspace-history-BANOJRQ2.js} +1 -1
  62. package/dist/{workspace-intelligence-VKDL3H2J.js → workspace-intelligence-MFJE7W67.js} +1 -1
  63. package/dist/workspace-intelligence-evaluation-IPH7M3WV.js +1 -0
  64. package/dist/{workspace-intelligence-runner-LVALAZY7.js → workspace-intelligence-runner-THYLHHMF.js} +1 -1
  65. package/dist/{workspace-knowledge-graph-FE2NTZKV.js → workspace-knowledge-graph-ARDC6HHG.js} +1 -1
  66. package/dist/workspace-knowledge-graph-export-UYAYFTWX.js +10 -0
  67. package/dist/workspace-mcp-serve-EZR6O76D.js +3 -0
  68. package/dist/{workspace-model-S33CIB2R.js → workspace-model-7OU2M3LE.js} +1 -1
  69. package/dist/{workspace-registry-summary-A3YDL63D.js → workspace-registry-summary-ORDK7A36.js} +1 -1
  70. package/dist/workspace-run-RLIYSOTN.js +1 -0
  71. package/dist/{workspace-verify-ZGH3NXAH.js → workspace-verify-EBVL7FWT.js} +1 -1
  72. package/dist/{workspace-watch-EVBJTMV7.js → workspace-watch-3BPGLFLB.js} +1 -1
  73. package/docs/GLOSSARY.md +28 -24
  74. package/docs/README.md +17 -10
  75. package/docs/README_CONTENT_CONTRACT.md +154 -0
  76. package/docs/commands-reference.md +14 -1
  77. package/docs/contracts/ARTIFACT_CATALOG.md +28 -19
  78. package/docs/contracts/README.md +3 -0
  79. package/docs/graph-benchmark-methodology.md +2 -2
  80. package/docs/workspace-intelligence-evaluation.md +147 -0
  81. package/docs/workspace-knowledge-graph.md +31 -10
  82. package/package.json +1 -1
  83. package/dist/analyze-UVXPRGYZ.js +0 -1
  84. package/dist/autopilot-release-5BQ6F5L2.js +0 -1
  85. package/dist/chunk-LNRAB7UY.js +0 -1
  86. package/dist/chunk-NRYS4CLR.js +0 -2
  87. package/dist/workspace-explain-WVN7JH3U.js +0 -1
  88. package/dist/workspace-explain-contract-SEFTVF6J.js +0 -1
  89. package/dist/workspace-mcp-serve-KT2I676Z.js +0 -3
  90. package/dist/workspace-run-M4LNJILC.js +0 -1
@@ -856,6 +856,82 @@
856
856
  "--json"
857
857
  ]
858
858
  },
859
+ {
860
+ "invocation": "workspace eval",
861
+ "summary": "Measure model usage, agent activity, cost provenance, and verified task outcomes without storing prompt or response bodies.",
862
+ "canonicalArgv": [
863
+ "workspace",
864
+ "eval",
865
+ "status",
866
+ "--json"
867
+ ],
868
+ "input": {
869
+ "transport": "stdin",
870
+ "mediaType": "application/json",
871
+ "required": false,
872
+ "schemaVersion": "model-usage-event.v1",
873
+ "contractPath": "contracts/workspace-intelligence/model-usage-event.v1.json"
874
+ },
875
+ "output": {
876
+ "defaultFormat": "human-or-json",
877
+ "modes": [
878
+ {
879
+ "selector": "init <task> [strategy] --json",
880
+ "format": "json",
881
+ "mediaType": "application/json"
882
+ },
883
+ {
884
+ "selector": "record --json",
885
+ "format": "json",
886
+ "mediaType": "application/json"
887
+ },
888
+ {
889
+ "selector": "status --json",
890
+ "format": "json",
891
+ "mediaType": "application/json"
892
+ },
893
+ {
894
+ "selector": "report --json",
895
+ "format": "json",
896
+ "mediaType": "application/json"
897
+ },
898
+ {
899
+ "selector": "compare --from <report> --json",
900
+ "format": "json",
901
+ "mediaType": "application/json"
902
+ }
903
+ ]
904
+ }
905
+ },
906
+ {
907
+ "invocation": "workspace eval init",
908
+ "summary": "Initialize one live, versioned Workspace Intelligence evaluation run for a fixed task and retrieval strategy.",
909
+ "canonicalArgv": [
910
+ "workspace",
911
+ "eval",
912
+ "init"
913
+ ]
914
+ },
915
+ {
916
+ "invocation": "workspace eval record --json",
917
+ "summary": "Validate one privacy-bounded usage or outcome event from stdin and append it to the live evaluation artifact.",
918
+ "canonicalArgv": [
919
+ "workspace",
920
+ "eval",
921
+ "record",
922
+ "--json"
923
+ ]
924
+ },
925
+ {
926
+ "invocation": "workspace eval report --json",
927
+ "summary": "Finalize the live evaluation into an authoritative last-run report for IDE, CI, and comparison consumers.",
928
+ "canonicalArgv": [
929
+ "workspace",
930
+ "eval",
931
+ "report",
932
+ "--json"
933
+ ]
934
+ },
859
935
  {
860
936
  "invocation": "workspace explain",
861
937
  "summary": "Explain a workspace relationship, project, or blocker from traceable model and evidence references.",
@@ -930,7 +1006,7 @@
930
1006
  },
931
1007
  {
932
1008
  "invocation": "workspace graph",
933
- "summary": "Render the current workspace dependency graph in a supported representation.",
1009
+ "summary": "Query or export the evidence-backed workspace graph derived from the canonical model.",
934
1010
  "canonicalArgv": [
935
1011
  "workspace",
936
1012
  "graph",
@@ -960,6 +1036,26 @@
960
1036
  "format": "json",
961
1037
  "mediaType": "application/json"
962
1038
  },
1039
+ {
1040
+ "selector": "entities [kind] --json",
1041
+ "format": "json",
1042
+ "mediaType": "application/json"
1043
+ },
1044
+ {
1045
+ "selector": "evidence <id-or-unique-label> --json",
1046
+ "format": "json",
1047
+ "mediaType": "application/json"
1048
+ },
1049
+ {
1050
+ "selector": "path <from> <to> --json",
1051
+ "format": "json",
1052
+ "mediaType": "application/json"
1053
+ },
1054
+ {
1055
+ "selector": "overlay --from <graph> --json",
1056
+ "format": "json",
1057
+ "mediaType": "application/json"
1058
+ },
963
1059
  {
964
1060
  "selector": "dot",
965
1061
  "format": "raw-text",
@@ -969,6 +1065,21 @@
969
1065
  "selector": "mermaid",
970
1066
  "format": "raw-text",
971
1067
  "mediaType": "text/vnd.mermaid"
1068
+ },
1069
+ {
1070
+ "selector": "jsonld",
1071
+ "format": "raw-text",
1072
+ "mediaType": "application/ld+json"
1073
+ },
1074
+ {
1075
+ "selector": "graphml",
1076
+ "format": "raw-text",
1077
+ "mediaType": "application/graphml+xml"
1078
+ },
1079
+ {
1080
+ "selector": "gexf",
1081
+ "format": "raw-text",
1082
+ "mediaType": "application/gexf+xml"
972
1083
  }
973
1084
  ]
974
1085
  }
@@ -1402,6 +1513,37 @@
1402
1513
  ]
1403
1514
  ]
1404
1515
  },
1516
+ {
1517
+ "artifactPath": ".workspai/reports/workspace-intelligence-evaluation-live.json",
1518
+ "schemaVersion": "workspace-intelligence-evaluation.v1",
1519
+ "contractPath": "contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",
1520
+ "producerCommands": [
1521
+ [
1522
+ "workspace",
1523
+ "eval",
1524
+ "init"
1525
+ ],
1526
+ [
1527
+ "workspace",
1528
+ "eval",
1529
+ "record",
1530
+ "--json"
1531
+ ]
1532
+ ]
1533
+ },
1534
+ {
1535
+ "artifactPath": ".workspai/reports/workspace-intelligence-evaluation-last-run.json",
1536
+ "schemaVersion": "workspace-intelligence-evaluation.v1",
1537
+ "contractPath": "contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",
1538
+ "producerCommands": [
1539
+ [
1540
+ "workspace",
1541
+ "eval",
1542
+ "report",
1543
+ "--json"
1544
+ ]
1545
+ ]
1546
+ },
1405
1547
  {
1406
1548
  "artifactPath": ".workspai/workspace.contract.json",
1407
1549
  "schemaVersion": 1,
@@ -1668,6 +1810,7 @@
1668
1810
  "why",
1669
1811
  "trace",
1670
1812
  "feedback",
1813
+ "eval",
1671
1814
  "mcp",
1672
1815
  "policy",
1673
1816
  "contract",
@@ -1696,6 +1839,7 @@
1696
1839
  "why",
1697
1840
  "trace",
1698
1841
  "feedback",
1842
+ "eval",
1699
1843
  "mcp"
1700
1844
  ],
1701
1845
  "workspaceIntelligenceRootCommands": [
@@ -0,0 +1,82 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://getrapidkit.com/schemas/model-usage-event.v1.json",
4
+ "title": "Workspai Model and Agent Usage Event",
5
+ "description": "A privacy-bounded usage observation. Prompt and response bodies are deliberately excluded; consumers may provide hashes instead.",
6
+ "type": "object",
7
+ "required": ["schemaVersion", "eventId", "recordedAt", "kind"],
8
+ "properties": {
9
+ "schemaVersion": { "const": "model-usage-event.v1" },
10
+ "eventId": { "type": "string", "minLength": 1 },
11
+ "recordedAt": { "type": "string", "format": "date-time" },
12
+ "kind": { "enum": ["model-call", "tool-call", "outcome", "milestone"] },
13
+ "stage": { "type": "string", "minLength": 1 },
14
+ "modelCall": {
15
+ "type": "object",
16
+ "required": ["provider", "model", "source", "inputTokens", "outputTokens", "cachedInputTokens", "reasoningTokens", "latencyMs"],
17
+ "properties": {
18
+ "provider": { "type": "string", "minLength": 1 },
19
+ "model": { "type": "string", "minLength": 1 },
20
+ "source": { "enum": ["provider-reported", "tokenizer-counted", "estimated", "unavailable"] },
21
+ "tokenizer": { "type": "string", "minLength": 1 },
22
+ "inputTokens": { "type": ["integer", "null"], "minimum": 0 },
23
+ "outputTokens": { "type": ["integer", "null"], "minimum": 0 },
24
+ "cachedInputTokens": { "type": ["integer", "null"], "minimum": 0 },
25
+ "reasoningTokens": { "type": ["integer", "null"], "minimum": 0 },
26
+ "latencyMs": { "type": ["number", "null"], "minimum": 0 },
27
+ "promptHash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
28
+ "responseHash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
29
+ "cost": {
30
+ "type": "object",
31
+ "required": ["amount", "currency", "source"],
32
+ "properties": {
33
+ "amount": { "type": "number", "minimum": 0 },
34
+ "currency": { "type": "string", "pattern": "^[A-Z]{3}$" },
35
+ "source": { "enum": ["provider-reported", "catalog-estimated"] }
36
+ },
37
+ "additionalProperties": false
38
+ }
39
+ },
40
+ "additionalProperties": false
41
+ },
42
+ "toolCall": {
43
+ "type": "object",
44
+ "required": ["tool", "result", "changedSource", "durationMs"],
45
+ "properties": {
46
+ "tool": { "type": "string", "minLength": 1 },
47
+ "result": { "enum": ["passed", "failed", "blocked", "skipped"] },
48
+ "changedSource": { "type": "boolean" },
49
+ "durationMs": { "type": ["number", "null"], "minimum": 0 },
50
+ "artifact": { "type": "string", "minLength": 1 }
51
+ },
52
+ "additionalProperties": false
53
+ },
54
+ "outcome": {
55
+ "type": "object",
56
+ "required": ["status", "verified", "blockersResolved"],
57
+ "properties": {
58
+ "status": { "enum": ["passed", "failed", "blocked", "unknown"] },
59
+ "verified": { "type": "boolean" },
60
+ "blockersResolved": { "type": "integer", "minimum": 0 },
61
+ "summary": { "type": "string", "minLength": 1 }
62
+ },
63
+ "additionalProperties": false
64
+ },
65
+ "milestone": {
66
+ "type": "object",
67
+ "required": ["name"],
68
+ "properties": {
69
+ "name": { "type": "string", "minLength": 1 },
70
+ "detail": { "type": "string", "minLength": 1 }
71
+ },
72
+ "additionalProperties": false
73
+ }
74
+ },
75
+ "allOf": [
76
+ { "if": { "properties": { "kind": { "const": "model-call" } } }, "then": { "properties": { "modelCall": {} }, "required": ["modelCall"] } },
77
+ { "if": { "properties": { "kind": { "const": "tool-call" } } }, "then": { "properties": { "toolCall": {} }, "required": ["toolCall"] } },
78
+ { "if": { "properties": { "kind": { "const": "outcome" } } }, "then": { "properties": { "outcome": {} }, "required": ["outcome"] } },
79
+ { "if": { "properties": { "kind": { "const": "milestone" } } }, "then": { "properties": { "milestone": {} }, "required": ["milestone"] } }
80
+ ],
81
+ "additionalProperties": false
82
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://getrapidkit.com/schemas/workspace-intelligence-evaluation-comparison.v1.json",
4
+ "title": "Workspai Workspace Intelligence Evaluation Comparison",
5
+ "description": "A task-aligned comparison between two provenance-aware Workspace Intelligence evaluation runs.",
6
+ "type": "object",
7
+ "required": [
8
+ "schemaVersion",
9
+ "generatedAt",
10
+ "taskAligned",
11
+ "current",
12
+ "baseline",
13
+ "delta",
14
+ "comparableOutcome"
15
+ ],
16
+ "properties": {
17
+ "schemaVersion": { "const": "workspace-intelligence-evaluation-comparison.v1" },
18
+ "generatedAt": { "type": "string", "format": "date-time" },
19
+ "taskAligned": { "type": "boolean" },
20
+ "current": { "$ref": "#/$defs/run" },
21
+ "baseline": { "$ref": "#/$defs/run" },
22
+ "delta": {
23
+ "type": "object",
24
+ "required": ["tokens", "reductionPercent", "modelCalls", "toolCalls", "latencyMs"],
25
+ "properties": {
26
+ "tokens": { "type": "number" },
27
+ "reductionPercent": { "type": ["number", "null"] },
28
+ "modelCalls": { "type": "number" },
29
+ "toolCalls": { "type": "number" },
30
+ "latencyMs": { "type": "number" }
31
+ },
32
+ "additionalProperties": false
33
+ },
34
+ "comparableOutcome": { "type": "boolean" }
35
+ },
36
+ "$defs": {
37
+ "run": {
38
+ "type": "object",
39
+ "required": ["runId", "strategy", "tokens", "verified", "status"],
40
+ "properties": {
41
+ "runId": { "type": "string", "minLength": 1 },
42
+ "strategy": {
43
+ "enum": ["full-corpus", "grep", "vector", "graph", "workspace-intelligence", "custom"]
44
+ },
45
+ "tokens": { "type": "integer", "minimum": 0 },
46
+ "verified": { "type": "boolean" },
47
+ "status": { "enum": ["passed", "failed", "blocked", "unknown"] }
48
+ },
49
+ "additionalProperties": false
50
+ }
51
+ },
52
+ "additionalProperties": false
53
+ }
@@ -0,0 +1,120 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://getrapidkit.com/schemas/workspace-intelligence-evaluation.v1.json",
4
+ "title": "Workspai Workspace Intelligence Evaluation",
5
+ "description": "A live or finalized, provenance-aware measurement of model usage, agent activity, and verified task outcome.",
6
+ "type": "object",
7
+ "required": ["schemaVersion", "runId", "sessionId", "status", "startedAt", "updatedAt", "workspace", "configuration", "methodology", "events", "summary"],
8
+ "properties": {
9
+ "schemaVersion": { "const": "workspace-intelligence-evaluation.v1" },
10
+ "runId": { "type": "string", "minLength": 1 },
11
+ "sessionId": { "type": "string", "minLength": 1 },
12
+ "status": { "enum": ["live", "completed", "aborted"] },
13
+ "startedAt": { "type": "string", "format": "date-time" },
14
+ "updatedAt": { "type": "string", "format": "date-time" },
15
+ "completedAt": { "type": "string", "format": "date-time" },
16
+ "workspace": {
17
+ "type": "object",
18
+ "required": ["name", "path"],
19
+ "properties": {
20
+ "name": { "type": "string", "minLength": 1 },
21
+ "path": { "type": "string", "minLength": 1 }
22
+ },
23
+ "additionalProperties": false
24
+ },
25
+ "configuration": {
26
+ "type": "object",
27
+ "required": ["taskId", "strategy"],
28
+ "properties": {
29
+ "taskId": { "type": "string", "minLength": 1 },
30
+ "strategy": { "enum": ["full-corpus", "grep", "vector", "graph", "workspace-intelligence", "custom"] },
31
+ "provider": { "type": "string", "minLength": 1 },
32
+ "model": { "type": "string", "minLength": 1 },
33
+ "temperature": { "type": "number" },
34
+ "baselineRunId": { "type": "string", "minLength": 1 }
35
+ },
36
+ "additionalProperties": false
37
+ },
38
+ "methodology": {
39
+ "type": "object",
40
+ "required": ["id", "claimBoundary"],
41
+ "properties": {
42
+ "id": { "const": "provider-usage-and-verified-outcome.v1" },
43
+ "claimBoundary": { "type": "string", "minLength": 1 }
44
+ },
45
+ "additionalProperties": false
46
+ },
47
+ "events": {
48
+ "type": "array",
49
+ "items": { "$ref": "model-usage-event.v1.json" }
50
+ },
51
+ "summary": {
52
+ "type": "object",
53
+ "required": ["modelCalls", "toolCalls", "tokenSources", "tokens", "latencyMs", "costs", "outcome", "efficiency"],
54
+ "properties": {
55
+ "modelCalls": { "type": "integer", "minimum": 0 },
56
+ "toolCalls": { "type": "integer", "minimum": 0 },
57
+ "tokenSources": {
58
+ "type": "object",
59
+ "required": ["providerReported", "tokenizerCounted", "estimated", "unavailable"],
60
+ "properties": {
61
+ "providerReported": { "type": "integer", "minimum": 0 },
62
+ "tokenizerCounted": { "type": "integer", "minimum": 0 },
63
+ "estimated": { "type": "integer", "minimum": 0 },
64
+ "unavailable": { "type": "integer", "minimum": 0 }
65
+ },
66
+ "additionalProperties": false
67
+ },
68
+ "tokens": {
69
+ "type": "object",
70
+ "required": ["input", "output", "cachedInput", "reasoning", "observedTotal"],
71
+ "properties": {
72
+ "input": { "type": "integer", "minimum": 0 },
73
+ "output": { "type": "integer", "minimum": 0 },
74
+ "cachedInput": { "type": "integer", "minimum": 0 },
75
+ "reasoning": { "type": "integer", "minimum": 0 },
76
+ "observedTotal": { "type": "integer", "minimum": 0 }
77
+ },
78
+ "additionalProperties": false
79
+ },
80
+ "latencyMs": { "type": "number", "minimum": 0 },
81
+ "costs": {
82
+ "type": "array",
83
+ "items": {
84
+ "type": "object",
85
+ "required": ["currency", "amount", "providerReported", "estimated"],
86
+ "properties": {
87
+ "currency": { "type": "string", "pattern": "^[A-Z]{3}$" },
88
+ "amount": { "type": "number", "minimum": 0 },
89
+ "providerReported": { "type": "number", "minimum": 0 },
90
+ "estimated": { "type": "number", "minimum": 0 }
91
+ },
92
+ "additionalProperties": false
93
+ }
94
+ },
95
+ "outcome": {
96
+ "type": "object",
97
+ "required": ["status", "verified", "blockersResolved"],
98
+ "properties": {
99
+ "status": { "enum": ["passed", "failed", "blocked", "unknown"] },
100
+ "verified": { "type": "boolean" },
101
+ "blockersResolved": { "type": "integer", "minimum": 0 }
102
+ },
103
+ "additionalProperties": false
104
+ },
105
+ "efficiency": {
106
+ "type": "object",
107
+ "required": ["tokensPerVerifiedOutcome", "noProgressDecisions", "repeatedArtifactReads"],
108
+ "properties": {
109
+ "tokensPerVerifiedOutcome": { "type": ["number", "null"], "minimum": 0 },
110
+ "noProgressDecisions": { "type": "integer", "minimum": 0 },
111
+ "repeatedArtifactReads": { "type": "integer", "minimum": 0 }
112
+ },
113
+ "additionalProperties": false
114
+ }
115
+ },
116
+ "additionalProperties": false
117
+ }
118
+ },
119
+ "additionalProperties": false
120
+ }
@@ -101,7 +101,7 @@
101
101
  "scripts",
102
102
  "framework markers",
103
103
  "package dependencies",
104
- "supported source imports (currently bounded JavaScript and TypeScript scanning)"
104
+ "bounded multi-language source observations for supported file extensions"
105
105
  ],
106
106
  "entersAt": "model"
107
107
  },
@@ -299,8 +299,17 @@
299
299
  "commands": [
300
300
  "workspace graph emit",
301
301
  "workspace graph explain",
302
+ "workspace graph entities",
303
+ "workspace graph evidence",
304
+ "workspace graph path",
305
+ "workspace graph search",
306
+ "workspace graph benchmark",
307
+ "workspace graph overlay",
302
308
  "workspace graph dot",
303
- "workspace graph mermaid"
309
+ "workspace graph mermaid",
310
+ "workspace graph jsonld",
311
+ "workspace graph graphml",
312
+ "workspace graph gexf"
304
313
  ],
305
314
  "reads": [
306
315
  ".workspai/reports/workspace-model.json",
@@ -309,6 +318,26 @@
309
318
  "role": "Query the proof-backed graph derived from the canonical workspace model.",
310
319
  "chainStep": false
311
320
  },
321
+ {
322
+ "id": "evaluation",
323
+ "commands": [
324
+ "workspace eval init",
325
+ "workspace eval record",
326
+ "workspace eval status",
327
+ "workspace eval report",
328
+ "workspace eval compare"
329
+ ],
330
+ "reads": [
331
+ ".workspai/reports/workspace-intelligence-evaluation-live.json",
332
+ ".workspai/reports/workspace-intelligence-evaluation-last-run.json"
333
+ ],
334
+ "produces": [
335
+ ".workspai/reports/workspace-intelligence-evaluation-live.json",
336
+ ".workspai/reports/workspace-intelligence-evaluation-last-run.json"
337
+ ],
338
+ "role": "Measure model usage, activity, cost provenance, and verified outcomes without storing prompt or response bodies.",
339
+ "chainStep": false
340
+ },
312
341
  {
313
342
  "id": "watch",
314
343
  "commands": [
@@ -6,7 +6,7 @@
6
6
  "invariants": [
7
7
  "Missing or unreadable input is unknown or unavailable; it must not be presented as verified absence.",
8
8
  "Freshness and provenance travel with evidence and must not be discarded by projections.",
9
- "The current graph is a workspace dependency graph, not a complete cross-language symbol or call graph.",
9
+ "The current graph is an evidence-backed workspace knowledge graph with bounded source intelligence, not a complete cross-language symbol or call graph.",
10
10
  "Simple and standard presentations summarize the contract; their contractRefs must preserve complete traceability.",
11
11
  "Conditional provider outputs must be resolved through their dedicated inventory contract.",
12
12
  "Auxiliary capabilities expose or refresh intelligence but are not mandatory execution-chain steps.",
@@ -203,6 +203,18 @@
203
203
  "path": ".workspai/reports/workspace-intelligence-run-last-run.json",
204
204
  "schemaVersion": "workspace-intelligence-run.v1",
205
205
  "schemaContract": "contracts/workspace-intelligence/workspace-intelligence-run.v1.json"
206
+ },
207
+ {
208
+ "id": "evaluationLive",
209
+ "path": ".workspai/reports/workspace-intelligence-evaluation-live.json",
210
+ "schemaVersion": "workspace-intelligence-evaluation.v1",
211
+ "schemaContract": "contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json"
212
+ },
213
+ {
214
+ "id": "evaluationLastRun",
215
+ "path": ".workspai/reports/workspace-intelligence-evaluation-last-run.json",
216
+ "schemaVersion": "workspace-intelligence-evaluation.v1",
217
+ "schemaContract": "contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json"
206
218
  }
207
219
  ]
208
220
  },
@@ -258,7 +270,7 @@
258
270
  "scripts",
259
271
  "framework markers",
260
272
  "package dependencies",
261
- "supported source imports (currently bounded JavaScript and TypeScript scanning)"
273
+ "bounded multi-language source observations for supported file extensions"
262
274
  ],
263
275
  "entersAt": "model"
264
276
  },
@@ -496,8 +508,17 @@
496
508
  "commands": [
497
509
  "workspace graph emit",
498
510
  "workspace graph explain",
511
+ "workspace graph entities",
512
+ "workspace graph evidence",
513
+ "workspace graph path",
514
+ "workspace graph search",
515
+ "workspace graph benchmark",
516
+ "workspace graph overlay",
499
517
  "workspace graph dot",
500
- "workspace graph mermaid"
518
+ "workspace graph mermaid",
519
+ "workspace graph jsonld",
520
+ "workspace graph graphml",
521
+ "workspace graph gexf"
501
522
  ],
502
523
  "reads": [
503
524
  ".workspai/reports/workspace-model.json",
@@ -506,6 +527,26 @@
506
527
  "role": "Query the proof-backed graph derived from the canonical workspace model.",
507
528
  "chainStep": false
508
529
  },
530
+ {
531
+ "id": "evaluation",
532
+ "commands": [
533
+ "workspace eval init",
534
+ "workspace eval record",
535
+ "workspace eval status",
536
+ "workspace eval report",
537
+ "workspace eval compare"
538
+ ],
539
+ "reads": [
540
+ ".workspai/reports/workspace-intelligence-evaluation-live.json",
541
+ ".workspai/reports/workspace-intelligence-evaluation-last-run.json"
542
+ ],
543
+ "produces": [
544
+ ".workspai/reports/workspace-intelligence-evaluation-live.json",
545
+ ".workspai/reports/workspace-intelligence-evaluation-last-run.json"
546
+ ],
547
+ "role": "Measure model usage, activity, cost provenance, and verified outcomes without storing prompt or response bodies.",
548
+ "chainStep": false
549
+ },
509
550
  {
510
551
  "id": "watch",
511
552
  "commands": [
@@ -0,0 +1 @@
1
+ export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-54EP5CEV.js';
@@ -1,3 +1,3 @@
1
- import {a as a$1}from'./chunk-2E6WGUN6.js';import {a,e,b}from'./chunk-2TEDAKP6.js';import y from'path';import {existsSync}from'fs';import x from'fs-extra';var I=[{artifactKind:"bootstrap-compliance",cardId:"bootstrap",fileNames:["bootstrap-compliance.latest.json"]},{artifactKind:"doctor-workspace",cardId:"doctor",fileNames:["doctor-remediation-plan-last-run.json"]},{artifactKind:"analyze",cardId:"analyze",fileNames:["analyze-last-run.json"]},{artifactKind:"readiness",cardId:"readiness",fileNames:["release-readiness-last-run.json"]},{artifactKind:"pipeline",cardId:"pipeline",fileNames:["pipeline-last-run.json"]},{artifactKind:"workspace-run",cardId:"workspaceRun",fileNames:["workspace-run-last.json"]},{artifactKind:"workspace-verify",cardId:"workspaceVerify",fileNames:["workspace-verify-last-run.json"]}];function m(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function f(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function k(e){return [...new Set(e.map(r=>r.trim()).filter(Boolean))]}function K(e,r,t){return t?r:y.relative(e,r)}function C(e){let r=e?.trim()||"npx workspai bootstrap";if(!/(?:^|\s)--ci(?:\s|$)/.test(r)&&/(?:^|\s)--json(?:\s|$)/.test(r))return r.replace(/(?:^|\s)--json(?:\s|$)/,i=>{let n=i.startsWith(" ")?" ":"",c=i.endsWith(" ")?" ":"";return `${n}--ci --json${c}`}).trim();let t=/(?:^|\s)--ci(?:\s|$)/.test(r)?r:`${r} --ci`;return /(?:^|\s)--json(?:\s|$)/.test(t)?t:`${t} --json`}function M(e){return `${JSON.stringify({schemaVersion:"rapidkit.compatibility-matrix.v1",generatedAt:e,source:"workspai workspace remediation-plan",runtimes:{},notes:["Minimal enterprise baseline. Add runtime and toolchain entries as governance matures."]},null,2)}
1
+ import {a as a$1}from'./chunk-2E6WGUN6.js';import {a,e,b}from'./chunk-32OJDBIG.js';import y from'path';import {existsSync}from'fs';import x from'fs-extra';var I=[{artifactKind:"bootstrap-compliance",cardId:"bootstrap",fileNames:["bootstrap-compliance.latest.json"]},{artifactKind:"doctor-workspace",cardId:"doctor",fileNames:["doctor-remediation-plan-last-run.json"]},{artifactKind:"analyze",cardId:"analyze",fileNames:["analyze-last-run.json"]},{artifactKind:"readiness",cardId:"readiness",fileNames:["release-readiness-last-run.json"]},{artifactKind:"pipeline",cardId:"pipeline",fileNames:["pipeline-last-run.json"]},{artifactKind:"workspace-run",cardId:"workspaceRun",fileNames:["workspace-run-last.json"]},{artifactKind:"workspace-verify",cardId:"workspaceVerify",fileNames:["workspace-verify-last-run.json"]}];function m(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function f(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function k(e){return [...new Set(e.map(r=>r.trim()).filter(Boolean))]}function K(e,r,t){return t?r:y.relative(e,r)}function C(e){let r=e?.trim()||"npx workspai bootstrap";if(!/(?:^|\s)--ci(?:\s|$)/.test(r)&&/(?:^|\s)--json(?:\s|$)/.test(r))return r.replace(/(?:^|\s)--json(?:\s|$)/,i=>{let n=i.startsWith(" ")?" ":"",c=i.endsWith(" ")?" ":"";return `${n}--ci --json${c}`}).trim();let t=/(?:^|\s)--ci(?:\s|$)/.test(r)?r:`${r} --ci`;return /(?:^|\s)--json(?:\s|$)/.test(t)?t:`${t} --json`}function M(e){return `${JSON.stringify({schemaVersion:"rapidkit.compatibility-matrix.v1",generatedAt:e,source:"workspai workspace remediation-plan",runtimes:{},notes:["Minimal enterprise baseline. Add runtime and toolchain entries as governance matures."]},null,2)}
2
2
  `}function N(e){return `${JSON.stringify({schema_version:"1.0",enabled:false,strategy:"on-demand",artifacts:[],created_at:e,note:"Minimal enterprise baseline. Set enabled: true and add artifact entries to activate mirroring."},null,2)}
3
3
  `}function $(e){let r=e.payload,t=f(r.blockers),i=f(r.blockingReasons),n=f(r.failures),c=f(r.reasons),d=f(r.policyViolations),a=m(r.summary),l=f(a?.blockers);if(e.artifactKind==="analyze"){let o=(Array.isArray(r.findings)?r.findings:[]).map(s=>m(s)).filter(s=>!!s).map(s=>String(s.message??s.title??s.id??"").trim()).filter(Boolean);return k([...t,...o,...i])}if(e.artifactKind==="workspace-run"){let u=m(r.stages),o=Object.entries(u??{}).flatMap(([s,b])=>{let h=m(b);return (Array.isArray(h?.projects)?h.projects:[]).map(p=>m(p)).filter(p=>!!p).filter(p=>p.status==="failed"||p.ok===false).map(p=>`${s}: ${String(p.project??p.name??"project")} failed`)});return k([...t,...o,...i])}return k([...t,...i,...n,...c,...d,...l])}function g(e){return {id:e.id,artifactKind:e.artifactKind,cardId:e.cardId,title:e.title,order:e.order,phase:e.phase,scope:"workspace",status:e.status??"ready",mode:e.mode,risk:e.risk,requiresApproval:true,blocker:e.blocker,summary:e.summary,...e.command?{command:e.command}:{},verifyCommand:e.verifyCommand,cwd:"workspace",files:e.files??[],...e.operation?{operation:e.operation}:{},rollback:{available:!!e.operation,strategy:e.operation?"idempotent":"none"},notes:e.notes??[]}}function P(e){let r=[],t=C("npx workspai bootstrap --json");for(let i of e.blockers)i.includes("profile.enterprise.ci")&&r.push(g({id:"bootstrap.enterprise-ci",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Run bootstrap in deterministic CI mode",order:10,phase:"bootstrap-preflight",blocker:i,summary:"Enterprise bootstrap compliance requires --ci for deterministic execution.",mode:"run-command",risk:"safe",command:t,verifyCommand:t})),i.includes("profile.enterprise.compatibility-matrix")&&r.push(g({id:"bootstrap.compatibility-matrix",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Create enterprise compatibility matrix baseline",order:20,phase:"bootstrap-config",blocker:i,summary:"Create the missing compatibility matrix baseline without overwriting user data.",mode:"edit-file",risk:"safe",verifyCommand:t,files:[".workspai/compatibility-matrix.json"],operation:{type:"file-create",path:".workspai/compatibility-matrix.json",content:M(e.generatedAt),overwrite:false}})),i.includes("profile.enterprise.mirror-config")&&r.push(g({id:"bootstrap.mirror-config",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Create enterprise mirror config baseline",order:30,phase:"bootstrap-config",blocker:i,summary:"Create the missing mirror configuration baseline without enabling mirroring.",mode:"edit-file",risk:"safe",verifyCommand:t,files:[".workspai/mirror-config.json"],operation:{type:"file-create",path:".workspai/mirror-config.json",content:N(e.generatedAt),overwrite:false}}));return r}function S(e){if(e.report.artifactKind==="readiness"&&/dependenc(?:y|ies).*vulnerabil|vulnerabil.*dependenc(?:y|ies)|security audit/i.test(e.blocker))return g({id:`${e.report.cardId}.doctor-owner.${e.order}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:"Resolve dependency vulnerability through Doctor",order:e.order,phase:"dependency-remediation",blocker:e.blocker,summary:"Release Readiness is the aggregate gate; use the project-scoped Doctor remediation capability that owns this dependency failure.",mode:"verify-before-fix",risk:"guarded",status:"review-required",command:"npx workspai doctor workspace --plan --json",verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",notes:["Read doctor-remediation-plan-last-run.json and execute the matching surface-security-hygiene capability before rerunning Readiness.","Do not treat a Readiness refresh as remediation for a source dependency vulnerability."]});let t={analyze:{title:"Refresh analyze evidence",phase:"analysis",command:"npx workspai analyze --strict --json",verify:"npx workspai analyze --strict --json"},readiness:{title:"Refresh release readiness",phase:"release-readiness",command:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",verify:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json"},pipeline:{title:"Rerun governance pipeline",phase:"governance-pipeline",command:"npx workspai pipeline --json --strict",verify:"npx workspai pipeline --json --strict"},"workspace-run":{title:"Rerun failed workspace stage",phase:"fleet-run",command:e.ciMode?"npx workspai workspace run test --strict --json":"npx workspai workspace run test --json",verify:e.ciMode?"npx workspai workspace run test --strict --json":"npx workspai workspace run test --json"},"workspace-verify":{title:"Refresh workspace verify gate",phase:"verification",command:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json",verify:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json"},"doctor-workspace":{title:"Use Doctor remediation plan",phase:"doctor-remediation",command:"npx workspai doctor workspace --plan --json",verify:"npx workspai doctor workspace --json"}}[e.report.artifactKind]??{title:"Refresh artifact evidence",phase:"evidence-refresh",command:"npx workspai pipeline --json --strict",verify:"npx workspai pipeline --json --strict"};return g({id:`${e.report.cardId}.refresh.${e.order}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:t.title,order:e.order,phase:t.phase,blocker:e.blocker,summary:"No deterministic file operation is available for this artifact yet; refresh the evidence and continue with the card-specific plan.",mode:e.report.artifactKind==="doctor-workspace"?"verify-before-fix":"run-command",risk:"guarded",status:e.report.artifactKind==="doctor-workspace"?"review-required":"ready",command:t.command,verifyCommand:t.verify,notes:e.report.artifactKind==="doctor-workspace"?["Read doctor-remediation-plan-last-run.json for ordered file-level steps."]:[]})}async function O(e){let r=[a(e,".workspai/reports"),b(e,".workspai/reports")],t=[],i=new Set;for(let n of I)for(let c of n.fileNames){let d=(await Promise.all(r.map(a=>y.join(a,c)))).find(a=>existsSync(a));if(!(!d||i.has(`${n.artifactKind}:${c}`))){i.add(`${n.artifactKind}:${c}`);try{let a=await x.readJSON(d),l=m(a);if(!l)continue;t.push({artifactKind:n.artifactKind,cardId:n.cardId,fileName:c,absolutePath:d,payload:l});}catch{t.push({artifactKind:n.artifactKind,cardId:n.cardId,fileName:c,absolutePath:d,payload:{blockers:[`${n.artifactKind}: report exists but could not be parsed.`]}});}}}return t}async function F(e){let r=y.resolve(e.workspacePath),t=e.includeAbsolutePaths===true,i=e.ciMode===true,n=new Date().toISOString(),c=a(r,".workspai/reports"),d=await O(r),a$2=[],l=1;for(let o of d){let s=$(o);if(s.length!==0){if(o.artifactKind==="bootstrap-compliance"){a$2.push(...P({blockers:s,generatedAt:n})),l=a$2.length+1;continue}for(let b of s.slice(0,8))a$2.push(S({report:o,blocker:b,order:l,ciMode:i})),l+=1;}}let u={safe:a$2.filter(o=>o.risk==="safe").length,guarded:a$2.filter(o=>o.risk==="guarded").length,invasive:a$2.filter(o=>o.risk==="invasive").length};return {schemaVersion:a$1,generatedAt:n,workspace:{name:y.basename(r),...t?{path:r}:{}},source:{command:"workspace remediation-plan",reportsDir:K(r,c,t),includeAbsolutePaths:t,ciMode:i},summary:{artifactsScanned:d.length,cardsCovered:k(a$2.map(o=>o.cardId)).length,totalActions:a$2.length,executableActions:a$2.filter(o=>o.status==="ready").length,risk:u},actions:a$2}}async function W(e$1,r){return e(r,".workspai/reports/artifact-remediation-plan-last-run.json",e$1)}export{F as buildArtifactRemediationPlan,W as writeArtifactRemediationPlan};
@@ -0,0 +1 @@
1
+ export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-5S3DJQEP.js';
@@ -1,2 +1,2 @@
1
- import {b}from'./chunk-YCL3I2JO.js';import {r,s}from'./chunk-5XATWNME.js';import c from'path';import {randomUUID}from'crypto';import {open}from'fs/promises';import i from'fs-extra';function x(e,t){let s=c.resolve(e),r=t.trim();if(!r||c.isAbsolute(r))throw new Error(`Workspace artifact path must be non-empty and relative: ${t}`);let l=c.resolve(s,r),a=c.relative(s,l);if(a===".."||a.startsWith(`..${c.sep}`)||c.isAbsolute(a))throw new Error(`Workspace artifact path escapes workspace root: ${t}`);return l}function p(e,t){return x(e,r(t))}function $(e,t){return x(e,s(t))}async function W(e,t){let s=c.resolve(e);await i.ensureDir(s);let r=c.dirname(t);await i.ensureDir(r);let[l,a]=await Promise.all([i.realpath(s),i.realpath(r)]),o=c.relative(l,a);if(o===".."||o.startsWith(`..${c.sep}`)||c.isAbsolute(o))throw new Error(`Workspace artifact parent resolves outside workspace root: ${r}`)}async function M(e,t){let s=c.resolve(e),[r,l]=await Promise.all([i.realpath(s),i.realpath(t)]),a=c.relative(r,l);if(a===".."||a.startsWith(`..${c.sep}`)||c.isAbsolute(a))throw new Error(`Workspace artifact resolves outside workspace root: ${t}`)}function R(e){let t=e?.code;return process.platform==="win32"&&(t==="EPERM"||t==="EINVAL"||t==="ENOSYS")}async function T(e){try{await e.sync();}catch(t){if(!R(t))throw t}}async function y(e,t,s){await W(e,t);let r=c.dirname(t),l=`${c.basename(t)}.`,a=Date.now();for(let w of await i.readdir(r)){if(!w.startsWith(l)||!w.endsWith(".tmp"))continue;let f=c.join(r,w),n=await i.stat(f).catch(()=>null);n&&a-n.mtimeMs>3e4&&await i.remove(f).catch(()=>{});}let o=`${t}.${process.pid}.${randomUUID()}.tmp`;try{await s(o);let w=await open(o,"r");try{await T(w);}finally{await w.close();}let f=Number(process.env.WORKSPAI_TEST_ATOMIC_WRITE_DELAY_MS??0);Number.isFinite(f)&&f>0&&await new Promise(n=>setTimeout(n,Math.min(f,3e4)));try{await i.rename(o,t);}catch(n){let d=n.code;if(d!=="EEXIST"&&d!=="EPERM")throw n;await i.move(o,t,{overwrite:true});}}finally{await i.remove(o).catch(()=>{});}}async function _(e,t,s,r={}){let l=p(e,t);await W(e,l);let a=`${l}.lock`,o=r.timeoutMs??1e4,w=r.staleAfterMs??3e4,f=Date.now(),n;for(;!n;)try{n=await open(a,"wx"),await n.writeFile(`${JSON.stringify({pid:process.pid,createdAt:new Date().toISOString()})}
1
+ import {b}from'./chunk-3NU32T4A.js';import {r,s}from'./chunk-5XATWNME.js';import c from'path';import {randomUUID}from'crypto';import {open}from'fs/promises';import i from'fs-extra';function x(e,t){let s=c.resolve(e),r=t.trim();if(!r||c.isAbsolute(r))throw new Error(`Workspace artifact path must be non-empty and relative: ${t}`);let l=c.resolve(s,r),a=c.relative(s,l);if(a===".."||a.startsWith(`..${c.sep}`)||c.isAbsolute(a))throw new Error(`Workspace artifact path escapes workspace root: ${t}`);return l}function p(e,t){return x(e,r(t))}function $(e,t){return x(e,s(t))}async function W(e,t){let s=c.resolve(e);await i.ensureDir(s);let r=c.dirname(t);await i.ensureDir(r);let[l,a]=await Promise.all([i.realpath(s),i.realpath(r)]),o=c.relative(l,a);if(o===".."||o.startsWith(`..${c.sep}`)||c.isAbsolute(o))throw new Error(`Workspace artifact parent resolves outside workspace root: ${r}`)}async function M(e,t){let s=c.resolve(e),[r,l]=await Promise.all([i.realpath(s),i.realpath(t)]),a=c.relative(r,l);if(a===".."||a.startsWith(`..${c.sep}`)||c.isAbsolute(a))throw new Error(`Workspace artifact resolves outside workspace root: ${t}`)}function R(e){let t=e?.code;return process.platform==="win32"&&(t==="EPERM"||t==="EINVAL"||t==="ENOSYS")}async function T(e){try{await e.sync();}catch(t){if(!R(t))throw t}}async function y(e,t,s){await W(e,t);let r=c.dirname(t),l=`${c.basename(t)}.`,a=Date.now();for(let w of await i.readdir(r)){if(!w.startsWith(l)||!w.endsWith(".tmp"))continue;let f=c.join(r,w),n=await i.stat(f).catch(()=>null);n&&a-n.mtimeMs>3e4&&await i.remove(f).catch(()=>{});}let o=`${t}.${process.pid}.${randomUUID()}.tmp`;try{await s(o);let w=await open(o,"r");try{await T(w);}finally{await w.close();}let f=Number(process.env.WORKSPAI_TEST_ATOMIC_WRITE_DELAY_MS??0);Number.isFinite(f)&&f>0&&await new Promise(n=>setTimeout(n,Math.min(f,3e4)));try{await i.rename(o,t);}catch(n){let d=n.code;if(d!=="EEXIST"&&d!=="EPERM")throw n;await i.move(o,t,{overwrite:true});}}finally{await i.remove(o).catch(()=>{});}}async function _(e,t,s,r={}){let l=p(e,t);await W(e,l);let a=`${l}.lock`,o=r.timeoutMs??1e4,w=r.staleAfterMs??3e4,f=Date.now(),n;for(;!n;)try{n=await open(a,"wx"),await n.writeFile(`${JSON.stringify({pid:process.pid,createdAt:new Date().toISOString()})}
2
2
  `),await T(n);}catch(d){if(d.code!=="EEXIST")throw n&&(await n.close().catch(()=>{}),n=void 0,await i.remove(a).catch(()=>{})),d;let[A,S]=await Promise.all([i.stat(a).catch(()=>null),i.readJson(a).catch(()=>null)]),u=Number(S?.pid),m=Number.isInteger(u)&&u>0,h=false;if(m)try{process.kill(u,0),h=true;}catch(g){h=g.code==="EPERM";}let I=!m&&!!(A&&Date.now()-A.mtimeMs>w);if(m&&!h||I){await i.remove(a).catch(()=>{});continue}if(Date.now()-f>=o)throw new Error(`Timed out waiting for workspace artifact lock: ${t}`);await new Promise(g=>setTimeout(g,20));}try{return await s()}finally{await n.close().catch(()=>{}),await i.remove(a).catch(()=>{});}}async function z(e,t){let s=[p(e,t),$(e,t)];for(let r of s)if(await i.pathExists(r))return await M(e,r),r;return null}async function B(e,t,s){b(t,s);let r=p(e,t);return await y(e,r,l=>i.writeJson(l,s,{spaces:2})),r}async function H(e,t,s){if(s.length===0)return [];let r=s.map(a=>({...a,path:p(e,a.relativePath)})),l=r.find((a,o)=>r.findIndex(w=>w.path===a.path)!==o);if(l)throw new Error(`Duplicate workspace artifact transaction target: ${l.relativePath}`);for(let a of r)b(a.relativePath,a.payload);return _(e,t,async()=>{let a=await Promise.all(r.map(async o=>({path:o.path,exists:await i.pathExists(o.path),contents:await i.readFile(o.path).catch(()=>null)})));try{for(let o=0;o<r.length;o+=1){let w=r[o];await y(e,w.path,n=>i.writeJson(n,w.payload,{spaces:2}));let f=Number(process.env.WORKSPAI_TEST_FAIL_ARTIFACT_SET_AFTER??0);if(Number.isInteger(f)&&f===o+1)throw new Error(`Injected artifact-set failure after ${f} write(s).`)}return r.map(o=>o.path)}catch(o){let f=(await Promise.allSettled(a.map(async n=>{if(!n.exists||n.contents===null){await i.remove(n.path);return}await y(e,n.path,d=>i.writeFile(d,n.contents));}))).filter(n=>n.status==="rejected");throw f.length>0?new AggregateError([o,...f.map(n=>n.reason)],"Workspace artifact transaction failed and rollback was incomplete."):o}})}export{p as a,$ as b,_ as c,z as d,B as e,H as f};