@oh-my-pi/pi-coding-agent 17.2.5 → 17.2.7

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 (201) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/dist/{CHANGELOG-q2w43aw3.md → CHANGELOG-1p8yvde7.md} +35 -1
  3. package/dist/cli.js +3340 -3339
  4. package/dist/types/advisor/advise-tool.d.ts +10 -4
  5. package/dist/types/autoresearch/tools/init-experiment.d.ts +19 -7
  6. package/dist/types/autoresearch/tools/log-experiment.d.ts +19 -11
  7. package/dist/types/autoresearch/tools/run-experiment.d.ts +4 -2
  8. package/dist/types/autoresearch/tools/update-notes.d.ts +5 -2
  9. package/dist/types/cli/gc-cli.d.ts +1 -0
  10. package/dist/types/commit/agentic/tools/analyze-file.d.ts +5 -2
  11. package/dist/types/commit/agentic/tools/git-file-diff.d.ts +5 -2
  12. package/dist/types/commit/agentic/tools/git-hunk.d.ts +6 -2
  13. package/dist/types/commit/agentic/tools/git-overview.d.ts +5 -2
  14. package/dist/types/commit/agentic/tools/propose-changelog.d.ts +29 -7
  15. package/dist/types/commit/agentic/tools/propose-commit.d.ts +14 -4
  16. package/dist/types/commit/agentic/tools/recent-commits.d.ts +4 -2
  17. package/dist/types/commit/agentic/tools/schemas.d.ts +7 -3
  18. package/dist/types/commit/agentic/tools/split-commit.d.ts +37 -10
  19. package/dist/types/commit/changelog/generate.d.ts +13 -3
  20. package/dist/types/commit/shared-llm.d.ts +13 -4
  21. package/dist/types/config/config-file.d.ts +1 -1
  22. package/dist/types/config/models-config-schema-bundle.d.ts +1992 -981
  23. package/dist/types/config/models-config-schema.d.ts +1201 -580
  24. package/dist/types/config/models-config.d.ts +355 -371
  25. package/dist/types/edit/hashline/params.d.ts +4 -2
  26. package/dist/types/edit/modes/apply-patch.d.ts +4 -2
  27. package/dist/types/edit/modes/patch.d.ts +16 -5
  28. package/dist/types/edit/modes/replace.d.ts +8 -3
  29. package/dist/types/eval/bridge-timeout.d.ts +5 -2
  30. package/dist/types/eval/completion-bridge.d.ts +13 -0
  31. package/dist/types/eval/py/tool-bridge.d.ts +12 -0
  32. package/dist/types/extensibility/custom-commands/types.d.ts +4 -4
  33. package/dist/types/extensibility/custom-tools/types.d.ts +4 -4
  34. package/dist/types/extensibility/extensions/types.d.ts +4 -4
  35. package/dist/types/extensibility/hooks/types.d.ts +4 -4
  36. package/dist/types/extensibility/legacy-pi-ai-shim.d.ts +1 -1
  37. package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +1 -1
  38. package/dist/types/extensibility/legacy-typebox.d.ts +8 -0
  39. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +6 -13
  40. package/dist/types/goals/tools/goal-tool.d.ts +12 -4
  41. package/dist/types/launch/client.d.ts +9 -1
  42. package/dist/types/launch/protocol.d.ts +17 -0
  43. package/dist/types/lsp/index.d.ts +15 -5
  44. package/dist/types/lsp/types.d.ts +15 -5
  45. package/dist/types/modes/components/btw-panel.d.ts +3 -0
  46. package/dist/types/modes/controllers/btw-controller.d.ts +2 -0
  47. package/dist/types/modes/controllers/command-controller.d.ts +1 -0
  48. package/dist/types/modes/interactive-mode.d.ts +4 -1
  49. package/dist/types/modes/types.d.ts +3 -1
  50. package/dist/types/security/contracts/schemas.d.ts +1115 -537
  51. package/dist/types/security/publication.d.ts +92 -34
  52. package/dist/types/session/agent-session-types.d.ts +5 -0
  53. package/dist/types/session/agent-session.d.ts +26 -2
  54. package/dist/types/session/launch-completion.d.ts +10 -0
  55. package/dist/types/session/session-entries.d.ts +15 -1
  56. package/dist/types/session/session-manager.d.ts +7 -0
  57. package/dist/types/session/yield-queue.d.ts +6 -1
  58. package/dist/types/task/types.d.ts +63 -18
  59. package/dist/types/tools/ask.d.ts +34 -8
  60. package/dist/types/tools/ast-edit.d.ts +16 -4
  61. package/dist/types/tools/ast-grep.d.ts +12 -4
  62. package/dist/types/tools/bash.d.ts +20 -11
  63. package/dist/types/tools/browser.d.ts +64 -20
  64. package/dist/types/tools/checkpoint.d.ts +16 -8
  65. package/dist/types/tools/computer.d.ts +1 -1
  66. package/dist/types/tools/debug.d.ts +118 -48
  67. package/dist/types/tools/eval.d.ts +11 -5
  68. package/dist/types/tools/gh.d.ts +74 -26
  69. package/dist/types/tools/glob.d.ts +16 -6
  70. package/dist/types/tools/grep.d.ts +18 -6
  71. package/dist/types/tools/hub/index.d.ts +116 -46
  72. package/dist/types/tools/image-gen.d.ts +25 -8
  73. package/dist/types/tools/index.d.ts +9 -0
  74. package/dist/types/tools/inspect-image.d.ts +10 -4
  75. package/dist/types/tools/learn.d.ts +26 -8
  76. package/dist/types/tools/manage-skill.d.ts +16 -6
  77. package/dist/types/tools/memory-edit.d.ts +18 -6
  78. package/dist/types/tools/memory-recall.d.ts +8 -4
  79. package/dist/types/tools/memory-reflect.d.ts +10 -4
  80. package/dist/types/tools/memory-retain.d.ts +14 -4
  81. package/dist/types/tools/read.d.ts +8 -4
  82. package/dist/types/tools/security-scan.d.ts +82 -30
  83. package/dist/types/tools/todo.d.ts +30 -10
  84. package/dist/types/tools/tts.d.ts +12 -5
  85. package/dist/types/tools/vibe.d.ts +42 -18
  86. package/dist/types/tools/write.d.ts +10 -4
  87. package/dist/types/web/search/index.d.ts +20 -6
  88. package/package.json +13 -13
  89. package/scripts/legacy-pi-virtual-module.ts +2 -2
  90. package/src/advisor/advise-tool.ts +1 -1
  91. package/src/advisor/config.ts +1 -1
  92. package/src/autoresearch/tools/init-experiment.ts +1 -2
  93. package/src/autoresearch/tools/log-experiment.ts +1 -2
  94. package/src/autoresearch/tools/run-experiment.ts +1 -1
  95. package/src/autoresearch/tools/update-notes.ts +1 -1
  96. package/src/cli/gc-cli.ts +641 -21
  97. package/src/commit/agentic/tools/analyze-file.ts +1 -1
  98. package/src/commit/agentic/tools/git-file-diff.ts +1 -1
  99. package/src/commit/agentic/tools/git-hunk.ts +1 -1
  100. package/src/commit/agentic/tools/git-overview.ts +1 -1
  101. package/src/commit/agentic/tools/propose-changelog.ts +1 -1
  102. package/src/commit/agentic/tools/propose-commit.ts +1 -1
  103. package/src/commit/agentic/tools/recent-commits.ts +1 -1
  104. package/src/commit/agentic/tools/schemas.ts +1 -1
  105. package/src/commit/agentic/tools/split-commit.ts +1 -1
  106. package/src/commit/analysis/summary.ts +1 -1
  107. package/src/commit/changelog/generate.ts +1 -1
  108. package/src/config/config-file.ts +2 -2
  109. package/src/config/model-discovery.ts +14 -14
  110. package/src/config/model-registry.ts +10 -8
  111. package/src/config/models-config-schema-bundle.ts +1 -8
  112. package/src/config/settings.ts +1 -1
  113. package/src/discovery/codex.ts +22 -9
  114. package/src/edit/hashline/params.ts +1 -1
  115. package/src/edit/modes/apply-patch.ts +1 -1
  116. package/src/edit/modes/patch.ts +1 -1
  117. package/src/edit/modes/replace.ts +2 -1
  118. package/src/eval/agent-bridge.ts +4 -2
  119. package/src/eval/bridge-timeout.ts +5 -2
  120. package/src/eval/completion-bridge.ts +3 -2
  121. package/src/eval/executor-base.ts +20 -1
  122. package/src/eval/js/context-manager.ts +94 -6
  123. package/src/eval/py/tool-bridge.ts +29 -9
  124. package/src/export/html/index.ts +10 -3
  125. package/src/export/share.ts +4 -0
  126. package/src/extensibility/custom-commands/loader.ts +3 -3
  127. package/src/extensibility/custom-commands/types.ts +4 -4
  128. package/src/extensibility/custom-tools/loader.ts +3 -3
  129. package/src/extensibility/custom-tools/types.ts +5 -4
  130. package/src/extensibility/extensions/loader.ts +3 -3
  131. package/src/extensibility/extensions/types.ts +5 -4
  132. package/src/extensibility/hooks/loader.ts +3 -3
  133. package/src/extensibility/hooks/types.ts +4 -4
  134. package/src/extensibility/legacy-pi-ai-shim.ts +1 -1
  135. package/src/extensibility/legacy-pi-coding-agent-shim.ts +2 -2
  136. package/src/extensibility/legacy-typebox.ts +101 -0
  137. package/src/extensibility/plugins/legacy-pi-compat.ts +13 -22
  138. package/src/goals/tools/goal-tool.ts +1 -1
  139. package/src/launch/broker.ts +222 -6
  140. package/src/launch/client.ts +161 -9
  141. package/src/launch/protocol.ts +52 -0
  142. package/src/lsp/types.ts +1 -1
  143. package/src/main.ts +13 -6
  144. package/src/mcp/config-writer.ts +1 -1
  145. package/src/modes/components/btw-panel.ts +41 -4
  146. package/src/modes/controllers/btw-controller.ts +55 -7
  147. package/src/modes/controllers/command-controller.ts +31 -0
  148. package/src/modes/controllers/input-controller.ts +24 -7
  149. package/src/modes/interactive-mode.ts +16 -2
  150. package/src/modes/theme/theme.ts +3 -3
  151. package/src/modes/types.ts +8 -1
  152. package/src/prompts/session/launch-completion.md +1 -0
  153. package/src/sdk.ts +15 -0
  154. package/src/security/contracts/schemas.ts +202 -184
  155. package/src/security/contracts/validation.ts +6 -2
  156. package/src/security/publication.ts +1 -1
  157. package/src/security/store.ts +2 -2
  158. package/src/session/agent-session-types.ts +6 -0
  159. package/src/session/agent-session.ts +190 -14
  160. package/src/session/launch-completion.ts +37 -0
  161. package/src/session/session-context.ts +26 -0
  162. package/src/session/session-entries.ts +17 -1
  163. package/src/session/session-manager.ts +21 -0
  164. package/src/session/yield-queue.ts +121 -16
  165. package/src/slash-commands/builtin-registry.ts +10 -1
  166. package/src/task/types.ts +1 -1
  167. package/src/tools/ask.ts +1 -1
  168. package/src/tools/ast-edit.ts +1 -1
  169. package/src/tools/ast-grep.ts +1 -1
  170. package/src/tools/bash.ts +61 -3
  171. package/src/tools/browser/cmux/cmux-tab.ts +92 -4
  172. package/src/tools/browser.ts +1 -1
  173. package/src/tools/checkpoint.ts +1 -1
  174. package/src/tools/computer.ts +1 -1
  175. package/src/tools/debug.ts +1 -1
  176. package/src/tools/eval.ts +1 -1
  177. package/src/tools/gh.ts +1 -2
  178. package/src/tools/glob.ts +1 -1
  179. package/src/tools/grep.ts +1 -1
  180. package/src/tools/hub/index.ts +1 -1
  181. package/src/tools/hub/launch.ts +122 -6
  182. package/src/tools/image-gen.ts +1 -1
  183. package/src/tools/index.ts +9 -0
  184. package/src/tools/inspect-image.ts +1 -1
  185. package/src/tools/learn.ts +1 -1
  186. package/src/tools/manage-skill.ts +1 -1
  187. package/src/tools/memory-edit.ts +1 -1
  188. package/src/tools/memory-recall.ts +1 -1
  189. package/src/tools/memory-reflect.ts +1 -1
  190. package/src/tools/memory-retain.ts +1 -1
  191. package/src/tools/read.ts +1 -1
  192. package/src/tools/security-scan.ts +1 -1
  193. package/src/tools/todo.ts +1 -1
  194. package/src/tools/tts.ts +1 -1
  195. package/src/tools/vibe.ts +2 -1
  196. package/src/tools/write.ts +1 -1
  197. package/src/web/search/index.ts +2 -1
  198. package/dist/types/config/file-lock.d.ts +0 -29
  199. package/dist/types/extensibility/typebox.d.ts +0 -181
  200. package/src/config/file-lock.ts +0 -164
  201. package/src/extensibility/typebox.ts +0 -958
@@ -1,201 +1,219 @@
1
- import { type } from "arktype";
1
+ import { type } from "@oh-my-pi/omptype";
2
+ import { once } from "@oh-my-pi/pi-utils";
2
3
 
3
- const stringRecordSchema = type({ "[string]": "string" });
4
- const unknownRecordSchema = type({ "[string]": "unknown" });
4
+ export const getSecurityContractSchemas = once(() => {
5
+ const stringRecordSchema = type({ "[string]": "string" });
6
+ const unknownRecordSchema = type({ "[string]": "unknown" });
5
7
 
6
- export const securityProducerSchema = type({
7
- kind: "'omp-native' | 'codex-security-bundle' | 'codex-security-cloud' | 'sarif-import'",
8
- name: "string > 0",
9
- "version?": "string",
10
- "vendor?": "string",
11
- "revision?": "string",
12
- "pluginVersion?": "string",
13
- });
14
-
15
- export const securityProvenanceSchema = type({
16
- producer: securityProducerSchema,
17
- createdAt: "string > 0",
18
- "importedAt?": "string",
19
- "sourceIds?": stringRecordSchema,
20
- "vendorFingerprints?": stringRecordSchema,
21
- "upstream?": {
22
- "repository?": "string",
8
+ const securityProducerSchema = type({
9
+ kind: "'omp-native' | 'codex-security-bundle' | 'codex-security-cloud' | 'sarif-import'",
10
+ name: "string > 0",
11
+ "version?": "string",
12
+ "vendor?": "string",
23
13
  "revision?": "string",
24
- "packageVersion?": "string",
25
14
  "pluginVersion?": "string",
26
- "archiveSha256?": "string",
27
- },
28
- "metadata?": unknownRecordSchema,
29
- });
15
+ });
30
16
 
31
- export const securityLocationSchema = type({
32
- path: "string > 0",
33
- startLine: "number.integer >= 1",
34
- "endLine?": "number.integer >= 1",
35
- "startColumn?": "number.integer >= 1",
36
- "endColumn?": "number.integer >= 1",
37
- "role?": "string",
38
- });
17
+ const securityProvenanceSchema = type({
18
+ producer: securityProducerSchema,
19
+ createdAt: "string > 0",
20
+ "importedAt?": "string",
21
+ "sourceIds?": stringRecordSchema,
22
+ "vendorFingerprints?": stringRecordSchema,
23
+ "upstream?": {
24
+ "repository?": "string",
25
+ "revision?": "string",
26
+ "packageVersion?": "string",
27
+ "pluginVersion?": "string",
28
+ "archiveSha256?": "string",
29
+ },
30
+ "metadata?": unknownRecordSchema,
31
+ });
39
32
 
40
- export const securityEvidenceSchema = type({
41
- id: "string > 0",
42
- kind: "'code' | 'trace' | 'validation' | 'note'",
43
- label: "string > 0",
44
- explanation: "string",
45
- "location?": securityLocationSchema,
46
- "excerpt?": "string",
47
- });
33
+ const securityLocationSchema = type({
34
+ path: "string > 0",
35
+ startLine: "number.integer >= 1",
36
+ "endLine?": "number.integer >= 1",
37
+ "startColumn?": "number.integer >= 1",
38
+ "endColumn?": "number.integer >= 1",
39
+ "role?": "string",
40
+ });
48
41
 
49
- export const securityOccurrenceSchema = type({
50
- id: "string > 0",
51
- locations: securityLocationSchema.array().atLeastLength(1),
52
- evidenceIds: "string[]",
53
- });
42
+ const securityEvidenceSchema = type({
43
+ id: "string > 0",
44
+ kind: "'code' | 'trace' | 'validation' | 'note'",
45
+ label: "string > 0",
46
+ explanation: "string",
47
+ "location?": securityLocationSchema,
48
+ "excerpt?": "string",
49
+ });
54
50
 
55
- export const securityFindingSchema = type({
56
- id: "string > 0",
57
- scanId: "string > 0",
58
- fingerprint: "string > 0",
59
- ruleId: "string > 0",
60
- "anchor?": "string",
61
- title: "string > 0",
62
- summary: "string",
63
- severity: {
64
- level: "'critical' | 'high' | 'medium' | 'low' | 'informational'",
65
- "score?": "number",
66
- "scoringSystem?": "string",
67
- "vector?": "string",
68
- "rationale?": "string",
69
- },
70
- confidence: {
71
- level: "'high' | 'medium' | 'low'",
72
- "rationale?": "string",
73
- },
74
- taxonomy: {
75
- category: "string > 0",
76
- cwe: "string[]",
77
- "tags?": "string[]",
78
- },
79
- occurrences: securityOccurrenceSchema.array().atLeastLength(1),
80
- evidence: securityEvidenceSchema.array(),
81
- "remediation?": "string",
82
- validation: {
83
- status: "'unvalidated' | 'validated' | 'rejected' | 'partial' | 'error'",
84
- "summary?": "string",
51
+ const securityOccurrenceSchema = type({
52
+ id: "string > 0",
53
+ locations: securityLocationSchema.array().atLeastLength(1),
85
54
  evidenceIds: "string[]",
86
- "validatedAt?": "string",
87
- },
88
- disposition: {
89
- status: "'open' | 'false_positive' | 'accepted_risk' | 'fixed' | 'wont_fix'",
90
- "rationale?": "string",
91
- "updatedAt?": "string",
92
- "actor?": "string",
93
- },
94
- provenance: securityProvenanceSchema,
95
- "extensions?": unknownRecordSchema,
96
- });
55
+ });
97
56
 
98
- export const securityCoverageSchema = type({
99
- mode: "'repository' | 'scoped_path' | 'diff' | 'working_tree' | 'deep_repository' | 'imported'",
100
- completeness: "'complete' | 'partial' | 'unknown'",
101
- inventoryStrategy: "'repository' | 'scoped_path' | 'diff' | 'directory' | 'custom' | 'imported'",
102
- includePaths: "string[]",
103
- excludePaths: "string[]",
104
- surfaces: type({
105
- id: "string > 0",
106
- label: "string > 0",
107
- disposition: "'reported' | 'no_issue_found' | 'rejected' | 'not_applicable' | 'needs_follow_up'",
108
- receiptRefs: "string[]",
109
- "riskArea?": "string",
110
- "notes?": "string",
111
- }).array(),
112
- explicitExclusions: type({ pattern: "string", reason: "string" }).array(),
113
- deferred: type({
57
+ const securityFindingSchema = type({
114
58
  id: "string > 0",
115
- reason: "string > 0",
116
- "paths?": "string[]",
117
- "surfaceIds?": "string[]",
118
- }).array(),
119
- "openQuestions?": type({ question: "string > 0", "followUpPrompt?": "string" }).array(),
120
- });
59
+ scanId: "string > 0",
60
+ fingerprint: "string > 0",
61
+ ruleId: "string > 0",
62
+ "anchor?": "string",
63
+ title: "string > 0",
64
+ summary: "string",
65
+ severity: {
66
+ level: "'critical' | 'high' | 'medium' | 'low' | 'informational'",
67
+ "score?": "number",
68
+ "scoringSystem?": "string",
69
+ "vector?": "string",
70
+ "rationale?": "string",
71
+ },
72
+ confidence: {
73
+ level: "'high' | 'medium' | 'low'",
74
+ "rationale?": "string",
75
+ },
76
+ taxonomy: {
77
+ category: "string > 0",
78
+ cwe: "string[]",
79
+ "tags?": "string[]",
80
+ },
81
+ occurrences: securityOccurrenceSchema.array().atLeastLength(1),
82
+ evidence: securityEvidenceSchema.array(),
83
+ "remediation?": "string",
84
+ validation: {
85
+ status: "'unvalidated' | 'validated' | 'rejected' | 'partial' | 'error'",
86
+ "summary?": "string",
87
+ evidenceIds: "string[]",
88
+ "validatedAt?": "string",
89
+ },
90
+ disposition: {
91
+ status: "'open' | 'false_positive' | 'accepted_risk' | 'fixed' | 'wont_fix'",
92
+ "rationale?": "string",
93
+ "updatedAt?": "string",
94
+ "actor?": "string",
95
+ },
96
+ provenance: securityProvenanceSchema,
97
+ "extensions?": unknownRecordSchema,
98
+ });
121
99
 
122
- export const securityTargetSchema = type({
123
- kind: "'repository' | 'scoped_path' | 'ref_diff' | 'working_tree' | 'imported'",
124
- repositoryRoot: "string > 0",
125
- displayName: "string > 0",
126
- "revision?": "string",
127
- "baseRevision?": "string",
128
- "headRevision?": "string",
129
- includePaths: "string[]",
130
- excludePaths: "string[]",
131
- treeDigest: "string > 0",
132
- });
100
+ const securityCoverageSchema = type({
101
+ mode: "'repository' | 'scoped_path' | 'diff' | 'working_tree' | 'deep_repository' | 'imported'",
102
+ completeness: "'complete' | 'partial' | 'unknown'",
103
+ inventoryStrategy: "'repository' | 'scoped_path' | 'diff' | 'directory' | 'custom' | 'imported'",
104
+ includePaths: "string[]",
105
+ excludePaths: "string[]",
106
+ surfaces: type({
107
+ id: "string > 0",
108
+ label: "string > 0",
109
+ disposition: "'reported' | 'no_issue_found' | 'rejected' | 'not_applicable' | 'needs_follow_up'",
110
+ receiptRefs: "string[]",
111
+ "riskArea?": "string",
112
+ "notes?": "string",
113
+ }).array(),
114
+ explicitExclusions: type({ pattern: "string", reason: "string" }).array(),
115
+ deferred: type({
116
+ id: "string > 0",
117
+ reason: "string > 0",
118
+ "paths?": "string[]",
119
+ "surfaceIds?": "string[]",
120
+ }).array(),
121
+ "openQuestions?": type({ question: "string > 0", "followUpPrompt?": "string" }).array(),
122
+ });
133
123
 
134
- export const securityScanPlanSchema = type({
135
- documentType: "'omp-security.scan-plan'",
136
- schemaVersion: "'1.0'",
137
- id: "string > 0",
138
- createdAt: "string > 0",
139
- repositoryRoot: "string > 0",
140
- target: securityTargetSchema,
141
- knowledgeBases: type({ path: "string > 0", sha256: "string > 0", size: "number.integer >= 0" }).array(),
142
- output: {
143
- root: "string > 0",
144
- archiveExisting: "boolean",
145
- existingState: "'absent' | 'empty' | 'archivable'",
146
- },
147
- model: { provider: "string > 0", modelId: "string > 0", "thinkingLevel?": "string" },
148
- account: {
149
- provider: "string > 0",
150
- credentialId: "number.integer >= 1",
151
- "accountId?": "string",
152
- "email?": "string",
153
- "organizationId?": "string",
154
- "organizationName?": "string",
155
- },
156
- configFingerprint: "string > 0",
157
- workflowFingerprint: "string > 0",
158
- fingerprint: "string > 0",
159
- });
124
+ const securityTargetSchema = type({
125
+ kind: "'repository' | 'scoped_path' | 'ref_diff' | 'working_tree' | 'imported'",
126
+ repositoryRoot: "string > 0",
127
+ displayName: "string > 0",
128
+ "revision?": "string",
129
+ "baseRevision?": "string",
130
+ "headRevision?": "string",
131
+ includePaths: "string[]",
132
+ excludePaths: "string[]",
133
+ treeDigest: "string > 0",
134
+ });
160
135
 
161
- export const securityScanMetricsSchema = type({
162
- "runtimeMs?": "number >= 0",
163
- "tokenUsage?": {
164
- input: "number >= 0",
165
- output: "number >= 0",
166
- reasoning: "number >= 0",
167
- cacheRead: "number >= 0",
168
- cacheWrite: "number >= 0",
169
- total: "number >= 0",
170
- },
171
- "cost?": "number >= 0",
172
- "premiumRequests?": "number >= 0",
173
- });
136
+ const securityScanPlanSchema = type({
137
+ documentType: "'omp-security.scan-plan'",
138
+ schemaVersion: "'1.0'",
139
+ id: "string > 0",
140
+ createdAt: "string > 0",
141
+ repositoryRoot: "string > 0",
142
+ target: securityTargetSchema,
143
+ knowledgeBases: type({ path: "string > 0", sha256: "string > 0", size: "number.integer >= 0" }).array(),
144
+ output: {
145
+ root: "string > 0",
146
+ archiveExisting: "boolean",
147
+ existingState: "'absent' | 'empty' | 'archivable'",
148
+ },
149
+ model: { provider: "string > 0", modelId: "string > 0", "thinkingLevel?": "string" },
150
+ account: {
151
+ provider: "string > 0",
152
+ credentialId: "number.integer >= 1",
153
+ "accountId?": "string",
154
+ "email?": "string",
155
+ "organizationId?": "string",
156
+ "organizationName?": "string",
157
+ },
158
+ configFingerprint: "string > 0",
159
+ workflowFingerprint: "string > 0",
160
+ fingerprint: "string > 0",
161
+ });
174
162
 
175
- export const securityScanSchema = type({
176
- documentType: "'omp-security.scan'",
177
- schemaVersion: "'1.0'",
178
- id: "string > 0",
179
- projectKey: "string > 0",
180
- status: "'planned' | 'running' | 'completed' | 'partial' | 'cancelled' | 'failed'",
181
- createdAt: "string > 0",
182
- "startedAt?": "string",
183
- "completedAt?": "string",
184
- "plan?": securityScanPlanSchema,
185
- target: securityTargetSchema,
186
- producer: securityProducerSchema,
187
- provenance: securityProvenanceSchema,
188
- findingIds: "string[]",
189
- coverage: securityCoverageSchema,
190
- "reportRef?": "string",
191
- "sarifRef?": "string",
192
- "error?": "string",
193
- "metrics?": securityScanMetricsSchema,
194
- });
163
+ const securityScanMetricsSchema = type({
164
+ "runtimeMs?": "number >= 0",
165
+ "tokenUsage?": {
166
+ input: "number >= 0",
167
+ output: "number >= 0",
168
+ reasoning: "number >= 0",
169
+ cacheRead: "number >= 0",
170
+ cacheWrite: "number >= 0",
171
+ total: "number >= 0",
172
+ },
173
+ "cost?": "number >= 0",
174
+ "premiumRequests?": "number >= 0",
175
+ });
176
+
177
+ const securityScanSchema = type({
178
+ documentType: "'omp-security.scan'",
179
+ schemaVersion: "'1.0'",
180
+ id: "string > 0",
181
+ projectKey: "string > 0",
182
+ status: "'planned' | 'running' | 'completed' | 'partial' | 'cancelled' | 'failed'",
183
+ createdAt: "string > 0",
184
+ "startedAt?": "string",
185
+ "completedAt?": "string",
186
+ "plan?": securityScanPlanSchema,
187
+ target: securityTargetSchema,
188
+ producer: securityProducerSchema,
189
+ provenance: securityProvenanceSchema,
190
+ findingIds: "string[]",
191
+ coverage: securityCoverageSchema,
192
+ "reportRef?": "string",
193
+ "sarifRef?": "string",
194
+ "error?": "string",
195
+ "metrics?": securityScanMetricsSchema,
196
+ });
197
+
198
+ const securityScanBundleSchema = type({
199
+ scan: securityScanSchema,
200
+ findings: securityFindingSchema.array(),
201
+ "report?": "string",
202
+ "sarif?": unknownRecordSchema,
203
+ });
195
204
 
196
- export const securityScanBundleSchema = type({
197
- scan: securityScanSchema,
198
- findings: securityFindingSchema.array(),
199
- "report?": "string",
200
- "sarif?": unknownRecordSchema,
205
+ return {
206
+ securityProducerSchema,
207
+ securityProvenanceSchema,
208
+ securityLocationSchema,
209
+ securityEvidenceSchema,
210
+ securityOccurrenceSchema,
211
+ securityFindingSchema,
212
+ securityCoverageSchema,
213
+ securityTargetSchema,
214
+ securityScanPlanSchema,
215
+ securityScanMetricsSchema,
216
+ securityScanSchema,
217
+ securityScanBundleSchema,
218
+ };
201
219
  });
@@ -1,5 +1,5 @@
1
- import { type } from "arktype";
2
- import { securityFindingSchema, securityScanBundleSchema, securityScanPlanSchema, securityScanSchema } from "./schemas";
1
+ import { type } from "@oh-my-pi/omptype";
2
+ import { getSecurityContractSchemas } from "./schemas";
3
3
  import type { SecurityFinding, SecurityScan, SecurityScanBundle, SecurityScanPlan } from "./types";
4
4
 
5
5
  function schemaError(label: string, errors: type.errors): Error {
@@ -7,24 +7,28 @@ function schemaError(label: string, errors: type.errors): Error {
7
7
  }
8
8
 
9
9
  export function parseSecurityFinding(value: unknown): SecurityFinding {
10
+ const { securityFindingSchema } = getSecurityContractSchemas();
10
11
  const result = securityFindingSchema(value);
11
12
  if (result instanceof type.errors) throw schemaError("Security finding", result);
12
13
  return result as SecurityFinding;
13
14
  }
14
15
 
15
16
  export function parseSecurityScan(value: unknown): SecurityScan {
17
+ const { securityScanSchema } = getSecurityContractSchemas();
16
18
  const result = securityScanSchema(value);
17
19
  if (result instanceof type.errors) throw schemaError("Security scan", result);
18
20
  return result as SecurityScan;
19
21
  }
20
22
 
21
23
  export function parseSecurityScanPlan(value: unknown): SecurityScanPlan {
24
+ const { securityScanPlanSchema } = getSecurityContractSchemas();
22
25
  const result = securityScanPlanSchema(value);
23
26
  if (result instanceof type.errors) throw schemaError("Security scan plan", result);
24
27
  return result as SecurityScanPlan;
25
28
  }
26
29
 
27
30
  export function parseSecurityScanBundle(value: unknown): SecurityScanBundle {
31
+ const { securityScanBundleSchema } = getSecurityContractSchemas();
28
32
  const result = securityScanBundleSchema(value);
29
33
  if (result instanceof type.errors) throw schemaError("Security scan bundle", result);
30
34
  const bundle = result as SecurityScanBundle;
@@ -1,4 +1,4 @@
1
- import { type } from "arktype";
1
+ import { type } from "@oh-my-pi/omptype";
2
2
  import type { ToolDefinition } from "../extensibility/extensions";
3
3
  import securityPublishDescription from "../prompts/tools/security-publish.md" with { type: "text" };
4
4
  import type {
@@ -1,7 +1,7 @@
1
1
  import * as fs from "node:fs/promises";
2
2
  import * as path from "node:path";
3
3
  import { getSecurityProjectDir, isEnoent } from "@oh-my-pi/pi-utils";
4
- import { withFileLock } from "../config/file-lock";
4
+ import { withFileLock } from "@oh-my-pi/pi-utils/file-lock";
5
5
  import * as git from "../utils/git";
6
6
  import { compareSecurityLineage } from "./comparison";
7
7
  import type {
@@ -34,7 +34,7 @@ const SECURITY_STORE_WRITE_CHAINS = new Map<string, Promise<unknown>>();
34
34
  async function withSecurityStoreWrite<T>(key: string, operation: () => Promise<T>): Promise<T> {
35
35
  const lockTarget = path.join(key, "index.json");
36
36
  const run = (SECURITY_STORE_WRITE_CHAINS.get(key) ?? Promise.resolve()).then(() =>
37
- withFileLock(lockTarget, operation, { staleMs: 60_000, retries: 200, retryDelayMs: 50 }),
37
+ withFileLock(lockTarget, operation, { retries: 200, retryDelayMs: 50 }),
38
38
  );
39
39
  const guarded = run.catch(() => undefined);
40
40
  SECURITY_STORE_WRITE_CHAINS.set(key, guarded);
@@ -389,5 +389,11 @@ export interface FreshSessionResult {
389
389
  closedProviderSessions: number;
390
390
  }
391
391
 
392
+ /** Outcome of an in-place `/clear` conversation-context reset. */
393
+ export interface ResetSessionContextResult {
394
+ /** Number of live messages dropped from the model's context. */
395
+ droppedCount: number;
396
+ }
397
+
392
398
  /** Queued user content restored to the editor. */
393
399
  export type RestoredQueuedMessage = { text: string; images?: ImageContent[] };