@h-rig/contracts 0.0.6-alpha.16 → 0.0.6-alpha.161
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/dist/index.cjs +3280 -0
- package/dist/index.mjs +3239 -0
- package/dist/src/agent-roles.d.ts +8 -0
- package/dist/src/artifact.d.ts +13 -0
- package/dist/src/artifact.js +3 -0
- package/dist/src/baseSchemas.d.ts +63 -0
- package/dist/src/baseSchemas.js +6 -0
- package/dist/src/browser.d.ts +80 -0
- package/dist/src/browser.js +13 -0
- package/dist/src/capability-id.d.ts +22 -0
- package/dist/src/capability-id.js +8 -0
- package/dist/src/cli-output.d.ts +348 -0
- package/dist/src/cli-output.js +190 -0
- package/dist/src/cli-runner.d.ts +43 -0
- package/dist/src/cli-runner.js +13 -0
- package/dist/src/collab-session-viewer.d.ts +36 -0
- package/dist/src/collab-session-viewer.js +13 -0
- package/dist/src/config.d.ts +551 -0
- package/dist/src/config.js +765 -162
- package/dist/src/control-plane-types.d.ts +323 -0
- package/dist/src/control-plane-types.js +13 -0
- package/dist/src/conversation.d.ts +50 -0
- package/dist/src/conversation.js +3 -0
- package/dist/src/dependency-preflight.d.ts +43 -0
- package/dist/src/dependency-preflight.js +13 -0
- package/dist/src/doctor.d.ts +90 -0
- package/dist/src/doctor.js +13 -0
- package/dist/src/drift.d.ts +28 -0
- package/dist/src/drift.js +69 -0
- package/dist/src/editor.d.ts +25 -0
- package/dist/src/editor.js +3 -0
- package/dist/src/errors.d.ts +13 -0
- package/dist/src/errors.js +17 -0
- package/dist/src/git.d.ts +144 -0
- package/dist/src/git.js +3 -0
- package/dist/src/github.d.ts +146 -0
- package/dist/src/github.js +17 -0
- package/dist/src/graph.d.ts +360 -0
- package/dist/src/graph.js +137 -1
- package/dist/src/guard.d.ts +111 -0
- package/dist/src/guard.js +6 -0
- package/dist/src/harness-events.d.ts +8 -0
- package/dist/src/harness-events.js +1 -0
- package/dist/src/help-catalog.d.ts +41 -0
- package/dist/src/help-catalog.js +13 -0
- package/dist/src/host.d.ts +41 -0
- package/dist/src/host.js +13 -0
- package/dist/src/identity.d.ts +44 -0
- package/dist/src/identity.js +1 -0
- package/dist/src/index.d.ts +77 -0
- package/dist/src/index.js +2661 -3970
- package/dist/src/isolation.d.ts +213 -0
- package/dist/src/isolation.js +13 -0
- package/dist/src/kernel.d.ts +200 -0
- package/dist/src/kernel.js +261 -0
- package/dist/src/keybindings.d.ts +71 -0
- package/dist/src/keybindings.js +3 -0
- package/dist/src/layout.d.ts +49 -0
- package/dist/src/layout.js +10 -0
- package/dist/src/lifecycle-capabilities.d.ts +128 -0
- package/dist/src/lifecycle-capabilities.js +25 -0
- package/dist/src/managed-repos.d.ts +136 -0
- package/dist/src/managed-repos.js +17 -0
- package/dist/src/memory.d.ts +199 -0
- package/dist/src/memory.js +15 -0
- package/dist/src/model.d.ts +77 -0
- package/dist/src/notify.d.ts +46 -0
- package/dist/src/notify.js +13 -0
- package/dist/src/orchestration.d.ts +43 -0
- package/dist/src/orchestration.js +28 -961
- package/dist/src/panel-protocol.d.ts +17 -0
- package/dist/src/panel-protocol.js +10 -0
- package/dist/src/pi-session.d.ts +113 -0
- package/dist/src/pi-session.js +1 -0
- package/dist/src/planning.d.ts +64 -0
- package/dist/src/planning.js +90 -0
- package/dist/src/plugin-hooks.d.ts +51 -0
- package/dist/src/plugin-hooks.js +386 -0
- package/dist/src/plugin.d.ts +476 -0
- package/dist/src/plugin.js +346 -64
- package/dist/src/policy.d.ts +16 -0
- package/dist/src/policy.js +3 -0
- package/dist/src/project.d.ts +71 -0
- package/dist/src/project.js +3 -0
- package/dist/src/prompt.d.ts +29 -0
- package/dist/src/prompt.js +13 -0
- package/dist/src/protocol-version.d.ts +21 -0
- package/dist/src/protocol-version.js +6 -0
- package/dist/src/provider-instructions.d.ts +41 -0
- package/dist/src/provider-instructions.js +13 -0
- package/dist/src/provider.d.ts +105 -0
- package/dist/src/provider.js +4 -824
- package/dist/src/remote.d.ts +318 -0
- package/dist/src/remote.js +238 -1078
- package/dist/src/review.d.ts +18 -0
- package/dist/src/review.js +3 -0
- package/dist/src/rollups.d.ts +41 -0
- package/dist/src/rollups.js +70 -0
- package/dist/src/run-discovery.d.ts +79 -0
- package/dist/src/run-discovery.js +13 -0
- package/dist/src/run-dispatch.d.ts +34 -0
- package/dist/src/run-dispatch.js +13 -0
- package/dist/src/run-identity.d.ts +47 -0
- package/dist/src/run-identity.js +13 -0
- package/dist/src/run-journal.d.ts +694 -0
- package/dist/src/run-journal.js +569 -0
- package/dist/src/run-read-model.d.ts +234 -0
- package/dist/src/run-read-model.js +13 -0
- package/dist/src/run-record.d.ts +45 -0
- package/dist/src/run-record.js +1 -0
- package/dist/src/run-registry-backbone.d.ts +56 -0
- package/dist/src/run-registry-backbone.js +13 -0
- package/dist/src/run-session-journal.d.ts +69 -0
- package/dist/src/run-session-journal.js +78 -0
- package/dist/src/run-status.d.ts +10 -0
- package/dist/src/run-status.js +27 -0
- package/dist/src/run-timeline.d.ts +7 -0
- package/dist/src/run-timeline.js +1 -0
- package/dist/src/runtime-task-context.d.ts +82 -0
- package/dist/src/runtime-task-context.js +1 -0
- package/dist/src/runtime.d.ts +103 -0
- package/dist/src/runtime.js +73 -906
- package/dist/src/session-asset-materializer.d.ts +35 -0
- package/dist/src/session-asset-materializer.js +13 -0
- package/dist/src/setup.d.ts +47 -0
- package/dist/src/setup.js +13 -0
- package/dist/src/stage.d.ts +245 -0
- package/dist/src/stage.js +169 -0
- package/dist/src/supervisor-journal.d.ts +204 -0
- package/dist/src/supervisor-journal.js +334 -0
- package/dist/src/task-data.d.ts +239 -0
- package/dist/src/task-data.js +13 -0
- package/dist/src/task-graph-primitives.d.ts +47 -0
- package/dist/src/task-graph-primitives.js +1 -0
- package/dist/src/task-source.d.ts +102 -0
- package/dist/src/task-source.js +12 -0
- package/dist/src/task-state-metadata.d.ts +21 -0
- package/dist/src/task-state-metadata.js +1 -0
- package/dist/src/terminal.d.ts +130 -0
- package/dist/src/terminal.js +3 -0
- package/dist/src/tool-materializer.d.ts +36 -0
- package/dist/src/tool-materializer.js +13 -0
- package/dist/src/tool-registry.d.ts +3 -0
- package/dist/src/tool-registry.js +58 -0
- package/dist/src/toolchain-sources.d.ts +54 -0
- package/dist/src/toolchain-sources.js +17 -0
- package/dist/src/validation.d.ts +14 -0
- package/dist/src/validation.js +3 -0
- package/dist/src/workflow-journal.d.ts +92 -0
- package/dist/src/workflow-journal.js +18 -0
- package/dist/src/workspace-config.d.ts +18 -0
- package/dist/src/workspace-config.js +13 -0
- package/dist/src/workspace.d.ts +204 -0
- package/dist/src/workspace.js +76 -911
- package/package.json +51 -4
- package/dist/src/engine.js +0 -2278
- package/dist/src/providerRuntime.js +0 -1630
- package/dist/src/rig.js +0 -2374
- package/dist/src/server.js +0 -1053
- package/dist/src/serviceFabric.js +0 -1066
- package/dist/src/ws.js +0 -2968
- /package/dist/src/{ipc.js → agent-roles.js} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const EDITORS: readonly [{
|
|
3
|
+
readonly id: "cursor";
|
|
4
|
+
readonly label: "Cursor";
|
|
5
|
+
readonly command: "cursor";
|
|
6
|
+
}, {
|
|
7
|
+
readonly id: "vscode";
|
|
8
|
+
readonly label: "VS Code";
|
|
9
|
+
readonly command: "code";
|
|
10
|
+
}, {
|
|
11
|
+
readonly id: "zed";
|
|
12
|
+
readonly label: "Zed";
|
|
13
|
+
readonly command: "zed";
|
|
14
|
+
}, {
|
|
15
|
+
readonly id: "file-manager";
|
|
16
|
+
readonly label: "File Manager";
|
|
17
|
+
readonly command: null;
|
|
18
|
+
}];
|
|
19
|
+
export declare const EditorId: Schema.Literals<("cursor" | "vscode" | "zed" | "file-manager")[]>;
|
|
20
|
+
export type EditorId = typeof EditorId.Type;
|
|
21
|
+
export declare const OpenInEditorInput: Schema.Struct<{
|
|
22
|
+
readonly cwd: Schema.Trim;
|
|
23
|
+
readonly editor: Schema.Literals<("cursor" | "vscode" | "zed" | "file-manager")[]>;
|
|
24
|
+
}>;
|
|
25
|
+
export type OpenInEditorInput = typeof OpenInEditorInput.Type;
|
package/dist/src/editor.js
CHANGED
|
@@ -16,6 +16,9 @@ var WorkspaceId = makeEntityId("WorkspaceId");
|
|
|
16
16
|
var GraphId = makeEntityId("GraphId");
|
|
17
17
|
var TaskId = makeEntityId("TaskId");
|
|
18
18
|
var RunId = makeEntityId("RunId");
|
|
19
|
+
var SafePathSegment = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)).pipe(Schema.brand("SafePathSegment"));
|
|
20
|
+
var SafeRunId = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/)).pipe(Schema.brand("SafeRunId"));
|
|
21
|
+
var SafeGitRefComponent = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)).pipe(Schema.brand("SafeGitRefComponent"));
|
|
19
22
|
var EngineRuntimeId = makeEntityId("EngineRuntimeId");
|
|
20
23
|
var ConversationId = makeEntityId("ConversationId");
|
|
21
24
|
var ActionId = makeEntityId("ActionId");
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class CliError extends Error {
|
|
2
|
+
readonly exitCode: number;
|
|
3
|
+
/**
|
|
4
|
+
* Optional remediation hint. Rendered on its own `Next: <hint>` line (and
|
|
5
|
+
* carried in the `--json` error payload) so a failure can name the next
|
|
6
|
+
* command to run. Pure vocab — the exec machinery (now in @rig/guard-plugin)
|
|
7
|
+
* throws this with a hint without importing a CLI-seed error class.
|
|
8
|
+
*/
|
|
9
|
+
readonly hint?: string;
|
|
10
|
+
constructor(message: string, exitCode?: number, options?: {
|
|
11
|
+
readonly hint?: string;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/contracts/src/errors.ts
|
|
3
|
+
class CliError extends Error {
|
|
4
|
+
exitCode;
|
|
5
|
+
hint;
|
|
6
|
+
constructor(message, exitCode = 1, options = {}) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "CliError";
|
|
9
|
+
this.exitCode = exitCode;
|
|
10
|
+
if (options.hint?.trim()) {
|
|
11
|
+
this.hint = options.hint.trim();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
CliError
|
|
17
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const GitStackedAction: Schema.Literals<readonly ["commit", "commit_push", "commit_push_pr"]>;
|
|
3
|
+
export type GitStackedAction = typeof GitStackedAction.Type;
|
|
4
|
+
export declare const GitBranch: Schema.Struct<{
|
|
5
|
+
readonly name: Schema.Trim;
|
|
6
|
+
readonly isRemote: Schema.optional<Schema.Boolean>;
|
|
7
|
+
readonly remoteName: Schema.optional<Schema.Trim>;
|
|
8
|
+
readonly current: Schema.Boolean;
|
|
9
|
+
readonly isDefault: Schema.Boolean;
|
|
10
|
+
readonly worktreePath: Schema.NullOr<Schema.Trim>;
|
|
11
|
+
}>;
|
|
12
|
+
export type GitBranch = typeof GitBranch.Type;
|
|
13
|
+
export declare const GitStatusInput: Schema.Struct<{
|
|
14
|
+
readonly cwd: Schema.Trim;
|
|
15
|
+
}>;
|
|
16
|
+
export type GitStatusInput = typeof GitStatusInput.Type;
|
|
17
|
+
export declare const GitPullInput: Schema.Struct<{
|
|
18
|
+
readonly cwd: Schema.Trim;
|
|
19
|
+
}>;
|
|
20
|
+
export type GitPullInput = typeof GitPullInput.Type;
|
|
21
|
+
export declare const GitReadWorkingTreePatchInput: Schema.Struct<{
|
|
22
|
+
readonly cwd: Schema.Trim;
|
|
23
|
+
readonly relativePath: Schema.optional<Schema.Trim>;
|
|
24
|
+
}>;
|
|
25
|
+
export type GitReadWorkingTreePatchInput = typeof GitReadWorkingTreePatchInput.Type;
|
|
26
|
+
export declare const GitRunStackedActionInput: Schema.Struct<{
|
|
27
|
+
readonly cwd: Schema.Trim;
|
|
28
|
+
readonly action: Schema.Literals<readonly ["commit", "commit_push", "commit_push_pr"]>;
|
|
29
|
+
readonly commitMessage: Schema.optional<Schema.Trim>;
|
|
30
|
+
readonly featureBranch: Schema.optional<Schema.Boolean>;
|
|
31
|
+
}>;
|
|
32
|
+
export type GitRunStackedActionInput = typeof GitRunStackedActionInput.Type;
|
|
33
|
+
export declare const GitListBranchesInput: Schema.Struct<{
|
|
34
|
+
readonly cwd: Schema.Trim;
|
|
35
|
+
}>;
|
|
36
|
+
export type GitListBranchesInput = typeof GitListBranchesInput.Type;
|
|
37
|
+
export declare const GitCreateWorktreeInput: Schema.Struct<{
|
|
38
|
+
readonly cwd: Schema.Trim;
|
|
39
|
+
readonly branch: Schema.Trim;
|
|
40
|
+
readonly newBranch: Schema.Trim;
|
|
41
|
+
readonly path: Schema.NullOr<Schema.Trim>;
|
|
42
|
+
}>;
|
|
43
|
+
export type GitCreateWorktreeInput = typeof GitCreateWorktreeInput.Type;
|
|
44
|
+
export declare const GitRemoveWorktreeInput: Schema.Struct<{
|
|
45
|
+
readonly cwd: Schema.Trim;
|
|
46
|
+
readonly path: Schema.Trim;
|
|
47
|
+
readonly force: Schema.optional<Schema.Boolean>;
|
|
48
|
+
}>;
|
|
49
|
+
export type GitRemoveWorktreeInput = typeof GitRemoveWorktreeInput.Type;
|
|
50
|
+
export declare const GitCreateBranchInput: Schema.Struct<{
|
|
51
|
+
readonly cwd: Schema.Trim;
|
|
52
|
+
readonly branch: Schema.Trim;
|
|
53
|
+
}>;
|
|
54
|
+
export type GitCreateBranchInput = typeof GitCreateBranchInput.Type;
|
|
55
|
+
export declare const GitCheckoutInput: Schema.Struct<{
|
|
56
|
+
readonly cwd: Schema.Trim;
|
|
57
|
+
readonly branch: Schema.Trim;
|
|
58
|
+
}>;
|
|
59
|
+
export type GitCheckoutInput = typeof GitCheckoutInput.Type;
|
|
60
|
+
export declare const GitInitInput: Schema.Struct<{
|
|
61
|
+
readonly cwd: Schema.Trim;
|
|
62
|
+
}>;
|
|
63
|
+
export type GitInitInput = typeof GitInitInput.Type;
|
|
64
|
+
export declare const GitStatusResult: Schema.Struct<{
|
|
65
|
+
readonly branch: Schema.NullOr<Schema.Trim>;
|
|
66
|
+
readonly hasWorkingTreeChanges: Schema.Boolean;
|
|
67
|
+
readonly workingTree: Schema.Struct<{
|
|
68
|
+
readonly files: Schema.$Array<Schema.Struct<{
|
|
69
|
+
readonly path: Schema.Trim;
|
|
70
|
+
readonly insertions: Schema.Int;
|
|
71
|
+
readonly deletions: Schema.Int;
|
|
72
|
+
}>>;
|
|
73
|
+
readonly insertions: Schema.Int;
|
|
74
|
+
readonly deletions: Schema.Int;
|
|
75
|
+
}>;
|
|
76
|
+
readonly hasUpstream: Schema.Boolean;
|
|
77
|
+
readonly aheadCount: Schema.Int;
|
|
78
|
+
readonly behindCount: Schema.Int;
|
|
79
|
+
readonly pr: Schema.NullOr<Schema.Struct<{
|
|
80
|
+
readonly number: Schema.Int;
|
|
81
|
+
readonly title: Schema.Trim;
|
|
82
|
+
readonly url: Schema.String;
|
|
83
|
+
readonly baseBranch: Schema.Trim;
|
|
84
|
+
readonly headBranch: Schema.Trim;
|
|
85
|
+
readonly state: Schema.Literals<readonly ["open", "closed", "merged"]>;
|
|
86
|
+
}>>;
|
|
87
|
+
}>;
|
|
88
|
+
export type GitStatusResult = typeof GitStatusResult.Type;
|
|
89
|
+
export declare const GitListBranchesResult: Schema.Struct<{
|
|
90
|
+
readonly branches: Schema.$Array<Schema.Struct<{
|
|
91
|
+
readonly name: Schema.Trim;
|
|
92
|
+
readonly isRemote: Schema.optional<Schema.Boolean>;
|
|
93
|
+
readonly remoteName: Schema.optional<Schema.Trim>;
|
|
94
|
+
readonly current: Schema.Boolean;
|
|
95
|
+
readonly isDefault: Schema.Boolean;
|
|
96
|
+
readonly worktreePath: Schema.NullOr<Schema.Trim>;
|
|
97
|
+
}>>;
|
|
98
|
+
readonly isRepo: Schema.Boolean;
|
|
99
|
+
}>;
|
|
100
|
+
export type GitListBranchesResult = typeof GitListBranchesResult.Type;
|
|
101
|
+
export declare const GitCreateWorktreeResult: Schema.Struct<{
|
|
102
|
+
readonly worktree: Schema.Struct<{
|
|
103
|
+
readonly path: Schema.Trim;
|
|
104
|
+
readonly branch: Schema.Trim;
|
|
105
|
+
}>;
|
|
106
|
+
}>;
|
|
107
|
+
export type GitCreateWorktreeResult = typeof GitCreateWorktreeResult.Type;
|
|
108
|
+
export declare const GitRunStackedActionResult: Schema.Struct<{
|
|
109
|
+
readonly action: Schema.Literals<readonly ["commit", "commit_push", "commit_push_pr"]>;
|
|
110
|
+
readonly branch: Schema.Struct<{
|
|
111
|
+
readonly status: Schema.Literals<readonly ["created", "skipped_not_requested"]>;
|
|
112
|
+
readonly name: Schema.optional<Schema.Trim>;
|
|
113
|
+
}>;
|
|
114
|
+
readonly commit: Schema.Struct<{
|
|
115
|
+
readonly status: Schema.Literals<readonly ["created", "skipped_no_changes"]>;
|
|
116
|
+
readonly commitSha: Schema.optional<Schema.Trim>;
|
|
117
|
+
readonly subject: Schema.optional<Schema.Trim>;
|
|
118
|
+
}>;
|
|
119
|
+
readonly push: Schema.Struct<{
|
|
120
|
+
readonly status: Schema.Literals<readonly ["pushed", "skipped_not_requested", "skipped_up_to_date"]>;
|
|
121
|
+
readonly branch: Schema.optional<Schema.Trim>;
|
|
122
|
+
readonly upstreamBranch: Schema.optional<Schema.Trim>;
|
|
123
|
+
readonly setUpstream: Schema.optional<Schema.Boolean>;
|
|
124
|
+
}>;
|
|
125
|
+
readonly pr: Schema.Struct<{
|
|
126
|
+
readonly status: Schema.Literals<readonly ["created", "opened_existing", "skipped_not_requested"]>;
|
|
127
|
+
readonly url: Schema.optional<Schema.String>;
|
|
128
|
+
readonly number: Schema.optional<Schema.Int>;
|
|
129
|
+
readonly baseBranch: Schema.optional<Schema.Trim>;
|
|
130
|
+
readonly headBranch: Schema.optional<Schema.Trim>;
|
|
131
|
+
readonly title: Schema.optional<Schema.Trim>;
|
|
132
|
+
}>;
|
|
133
|
+
}>;
|
|
134
|
+
export type GitRunStackedActionResult = typeof GitRunStackedActionResult.Type;
|
|
135
|
+
export declare const GitPullResult: Schema.Struct<{
|
|
136
|
+
readonly status: Schema.Literals<readonly ["pulled", "skipped_up_to_date"]>;
|
|
137
|
+
readonly branch: Schema.Trim;
|
|
138
|
+
readonly upstreamBranch: Schema.NullOr<Schema.Trim>;
|
|
139
|
+
}>;
|
|
140
|
+
export type GitPullResult = typeof GitPullResult.Type;
|
|
141
|
+
export declare const GitReadWorkingTreePatchResult: Schema.Struct<{
|
|
142
|
+
readonly diff: Schema.String;
|
|
143
|
+
}>;
|
|
144
|
+
export type GitReadWorkingTreePatchResult = typeof GitReadWorkingTreePatchResult.Type;
|
package/dist/src/git.js
CHANGED
|
@@ -16,6 +16,9 @@ var WorkspaceId = makeEntityId("WorkspaceId");
|
|
|
16
16
|
var GraphId = makeEntityId("GraphId");
|
|
17
17
|
var TaskId = makeEntityId("TaskId");
|
|
18
18
|
var RunId = makeEntityId("RunId");
|
|
19
|
+
var SafePathSegment = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)).pipe(Schema.brand("SafePathSegment"));
|
|
20
|
+
var SafeRunId = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/)).pipe(Schema.brand("SafeRunId"));
|
|
21
|
+
var SafeGitRefComponent = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)).pipe(Schema.brand("SafeGitRefComponent"));
|
|
19
22
|
var EngineRuntimeId = makeEntityId("EngineRuntimeId");
|
|
20
23
|
var ConversationId = makeEntityId("ConversationId");
|
|
21
24
|
var ActionId = makeEntityId("ActionId");
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure GitHub-provider contract types.
|
|
3
|
+
*
|
|
4
|
+
* This is the neutral home for the GitHub SCM-provider data model so that the
|
|
5
|
+
* @rig/github-provider-plugin (which owns the implementation), the
|
|
6
|
+
* @rig/task-sources-plugin (which consumes the credential-provider abstraction),
|
|
7
|
+
* and any future dumb runtime substrate can all reference the same vocabulary
|
|
8
|
+
* without a substrate->plugin import cycle. These types carry no behaviour and
|
|
9
|
+
* import nothing — exactly like `memory.ts` / `lifecycle-capabilities.ts`.
|
|
10
|
+
*
|
|
11
|
+
* The plugin registers its executable GitHub-provider service under
|
|
12
|
+
* {@link GITHUB_PROVIDER_CAPABILITY_ID} on `contributes.capabilities[].run`; a
|
|
13
|
+
* dumb substrate consumer would resolve it by id from a plugin host built from
|
|
14
|
+
* the project's rig.config via a typed port — the same seam shape proven by
|
|
15
|
+
* the memory/lifecycle capability ports. (Today the only substrate-facing
|
|
16
|
+
* GitHub primitive — reading a token from an env-pointed state file — stays in
|
|
17
|
+
* @rig/runtime/control-plane/github/token-env as a dumb reader; the policy that
|
|
18
|
+
* produces that token lives in this plugin.)
|
|
19
|
+
*/
|
|
20
|
+
import type { CapabilityId } from "./capability-id";
|
|
21
|
+
/** Capability id the GitHub-provider plugin registers its service factory under. */
|
|
22
|
+
export declare const GITHUB_PROVIDER_CAPABILITY_ID = "github.provider";
|
|
23
|
+
export type GitHubCredentialPurpose = "selected-repo" | "admin-fallback";
|
|
24
|
+
export type GitHubCredentialSource = "signed-in-user" | "host-admin-fallback";
|
|
25
|
+
export type GitHubCredentialProviderOptions = {
|
|
26
|
+
/**
|
|
27
|
+
* Session-scoped tokens keyed as:
|
|
28
|
+
* `user:<userId>|repo:<owner>/<repo>|workspace:<workspaceId>`.
|
|
29
|
+
* This intentionally models the app/session auth boundary; host tokens are
|
|
30
|
+
* not used for normal selected-repo operations.
|
|
31
|
+
*/
|
|
32
|
+
sessionTokens?: Readonly<Record<string, string>>;
|
|
33
|
+
hostToken?: string | null;
|
|
34
|
+
};
|
|
35
|
+
export type ResolveGitHubTokenInput = {
|
|
36
|
+
owner: string;
|
|
37
|
+
repo: string;
|
|
38
|
+
workspaceId: string;
|
|
39
|
+
userId?: string;
|
|
40
|
+
purpose: GitHubCredentialPurpose;
|
|
41
|
+
};
|
|
42
|
+
export type ResolvedGitHubToken = {
|
|
43
|
+
token: string;
|
|
44
|
+
source: GitHubCredentialSource;
|
|
45
|
+
};
|
|
46
|
+
export interface GitHubCredentialProvider {
|
|
47
|
+
resolveGitHubToken(input: ResolveGitHubTokenInput): Promise<ResolvedGitHubToken>;
|
|
48
|
+
}
|
|
49
|
+
/** Options the state-file-backed credential provider accepts. */
|
|
50
|
+
export type GitHubStateCredentialProviderOptions = {
|
|
51
|
+
stateFile?: string;
|
|
52
|
+
stateDir?: string;
|
|
53
|
+
};
|
|
54
|
+
export type GitHubAuthStatus = {
|
|
55
|
+
readonly signedIn: boolean;
|
|
56
|
+
readonly login: string | null;
|
|
57
|
+
readonly userId: string | null;
|
|
58
|
+
readonly scopes: readonly string[];
|
|
59
|
+
readonly selectedRepo: string | null;
|
|
60
|
+
readonly oauthConfigured: boolean;
|
|
61
|
+
readonly tokenSource: "oauth-device" | "manual-token" | "env" | null;
|
|
62
|
+
};
|
|
63
|
+
export type GitHubUserInfo = {
|
|
64
|
+
readonly login: string;
|
|
65
|
+
readonly id: string;
|
|
66
|
+
readonly scopes?: readonly string[];
|
|
67
|
+
};
|
|
68
|
+
export type GitHubRepositoryProbe = {
|
|
69
|
+
readonly ok: boolean;
|
|
70
|
+
readonly owner: string;
|
|
71
|
+
readonly repo: string;
|
|
72
|
+
readonly status: number;
|
|
73
|
+
readonly authenticated: boolean;
|
|
74
|
+
readonly authenticationRequired: boolean;
|
|
75
|
+
readonly fullName: string | null;
|
|
76
|
+
readonly private: boolean | null;
|
|
77
|
+
readonly message: string;
|
|
78
|
+
readonly scopes: readonly string[];
|
|
79
|
+
};
|
|
80
|
+
export interface GitHubProjectSummary {
|
|
81
|
+
id: string;
|
|
82
|
+
number: number;
|
|
83
|
+
title: string;
|
|
84
|
+
url?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface GitHubProjectStatusField {
|
|
87
|
+
id: string;
|
|
88
|
+
name: string;
|
|
89
|
+
options: Array<{
|
|
90
|
+
id: string;
|
|
91
|
+
name: string;
|
|
92
|
+
}>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The executable surface the GitHub-provider capability `run()` returns. Kept
|
|
96
|
+
* intentionally narrow to the substrate-relevant seam (token resolution); the
|
|
97
|
+
* plugin's full API (OAuth device flow, Projects sync, issue analysis) is
|
|
98
|
+
* imported directly by above-runtime consumers and is not part of this port.
|
|
99
|
+
*/
|
|
100
|
+
export interface GitHubProviderService {
|
|
101
|
+
createCredentialProvider(options?: GitHubCredentialProviderOptions): GitHubCredentialProvider;
|
|
102
|
+
}
|
|
103
|
+
/** The capability `run` shape the plugin registers: a zero-arg service factory. */
|
|
104
|
+
export type GitHubProviderServiceRun = () => GitHubProviderService;
|
|
105
|
+
/**
|
|
106
|
+
* Typed capability id, phantom-typed with {@link GitHubProviderService} so
|
|
107
|
+
* consumers (task-sources/doctor/init) resolve it off the host with no cast.
|
|
108
|
+
* String value is {@link GITHUB_PROVIDER_CAPABILITY_ID}.
|
|
109
|
+
*/
|
|
110
|
+
export declare const GITHUB_PROVIDER: CapabilityId<GitHubProviderService>;
|
|
111
|
+
/** Capability id the issue-triage provider registers its runner under. */
|
|
112
|
+
export declare const ISSUE_TRIAGE_CAPABILITY_ID = "cap:issue-triage";
|
|
113
|
+
/** Pure input to a triage pass: which project + an optional reason label. */
|
|
114
|
+
export type IssueTriageInput = {
|
|
115
|
+
readonly projectRoot: string;
|
|
116
|
+
readonly reason?: string;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Pure summary of a triage pass. Contracts-owned mirror of the plugin's
|
|
120
|
+
* `IssueAnalysisTriageRunResult` so substrate consumers read the outcome
|
|
121
|
+
* without importing the plugin. Structurally compatible with the impl result.
|
|
122
|
+
*/
|
|
123
|
+
export type IssueTriageResult = {
|
|
124
|
+
readonly ok: true;
|
|
125
|
+
readonly enabled: boolean;
|
|
126
|
+
readonly reason: string;
|
|
127
|
+
readonly sourceId: string | null;
|
|
128
|
+
readonly sourceKind: string | null;
|
|
129
|
+
readonly analyzedIssues: number;
|
|
130
|
+
readonly metadataPatches: number;
|
|
131
|
+
readonly labelsAdded: number;
|
|
132
|
+
readonly labelsRemoved: number;
|
|
133
|
+
readonly generatedIssues: number;
|
|
134
|
+
readonly writeBackRefreshes: number;
|
|
135
|
+
readonly refreshedIssueCount: number | null;
|
|
136
|
+
readonly skippedReason?: "no-config" | "disabled";
|
|
137
|
+
};
|
|
138
|
+
/** The cohesive triage operation the CLI surface depends on. Async (does IO). */
|
|
139
|
+
export interface IssueTriageService {
|
|
140
|
+
runTriage(input: IssueTriageInput): Promise<IssueTriageResult>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Typed capability id, phantom-typed with {@link IssueTriageService}. String
|
|
144
|
+
* value is {@link ISSUE_TRIAGE_CAPABILITY_ID}.
|
|
145
|
+
*/
|
|
146
|
+
export declare const ISSUE_TRIAGE: CapabilityId<IssueTriageService>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/contracts/src/capability-id.ts
|
|
3
|
+
function makeCapabilityId(id) {
|
|
4
|
+
return id;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// packages/contracts/src/github.ts
|
|
8
|
+
var GITHUB_PROVIDER_CAPABILITY_ID = "github.provider";
|
|
9
|
+
var GITHUB_PROVIDER = makeCapabilityId(GITHUB_PROVIDER_CAPABILITY_ID);
|
|
10
|
+
var ISSUE_TRIAGE_CAPABILITY_ID = "cap:issue-triage";
|
|
11
|
+
var ISSUE_TRIAGE = makeCapabilityId(ISSUE_TRIAGE_CAPABILITY_ID);
|
|
12
|
+
export {
|
|
13
|
+
ISSUE_TRIAGE_CAPABILITY_ID,
|
|
14
|
+
ISSUE_TRIAGE,
|
|
15
|
+
GITHUB_PROVIDER_CAPABILITY_ID,
|
|
16
|
+
GITHUB_PROVIDER
|
|
17
|
+
};
|