@microck/canonfig 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +263 -0
- package/dist/agent/agent-resolution.errors.js +42 -0
- package/dist/agent/agent-resolution.layer.js +204 -0
- package/dist/agent/agent-resolution.service.js +2259 -0
- package/dist/agent/agent-resolution.types.js +1 -0
- package/dist/agent/controlled-executor.js +704 -0
- package/dist/agent/harness-adapters.js +85 -0
- package/dist/cli/cli.js +618 -0
- package/dist/cli/exit-codes.js +28 -0
- package/dist/cli/follower-commands.js +3 -0
- package/dist/cli/render.js +56 -0
- package/dist/cli/source-commands.js +5 -0
- package/dist/domain/brand.js +29 -0
- package/dist/domain/identity.js +31 -0
- package/dist/domain/npm-package-spec.js +186 -0
- package/dist/domain/profile.js +950 -0
- package/dist/domain/recipe-versions.js +297 -0
- package/dist/domain/resource.js +259 -0
- package/dist/domain/synchronization.js +346 -0
- package/dist/enrollment/enrollment.errors.js +43 -0
- package/dist/enrollment/enrollment.layer.js +724 -0
- package/dist/enrollment/enrollment.service.js +3 -0
- package/dist/enrollment/enrollment.types.js +59 -0
- package/dist/enrollment/follower-client.js +585 -0
- package/dist/enrollment/source-server.js +313 -0
- package/dist/machine/linux.layer.js +1183 -0
- package/dist/machine/machine-state.errors.js +52 -0
- package/dist/machine/machine-state.service.js +3 -0
- package/dist/machine/machine-state.types.js +1 -0
- package/dist/machine/macos.layer.js +470 -0
- package/dist/machine/windows.layer.js +879 -0
- package/dist/profile/discovery.js +740 -0
- package/dist/profile/profile-catalog.errors.js +50 -0
- package/dist/profile/profile-catalog.layer.js +20 -0
- package/dist/profile/profile-catalog.service.js +7 -0
- package/dist/profile/profile-codec.js +153 -0
- package/dist/profile/publication.js +298 -0
- package/dist/profile/tool-catalog.js +384 -0
- package/dist/runtime/doctor.js +306 -0
- package/dist/runtime/layers.js +706 -0
- package/dist/runtime/main.js +38 -0
- package/dist/schedule/linux-schedule.js +24 -0
- package/dist/schedule/macos-schedule.js +25 -0
- package/dist/schedule/schedule-manager.errors.js +17 -0
- package/dist/schedule/schedule-manager.layer.js +205 -0
- package/dist/schedule/schedule-manager.service.js +3 -0
- package/dist/schedule/schedule-manager.types.js +114 -0
- package/dist/schedule/windows-schedule.js +25 -0
- package/dist/state/state-repository.errors.js +55 -0
- package/dist/state/state-repository.layer.js +1507 -0
- package/dist/state/state-repository.service.js +3 -0
- package/dist/state/state-repository.types.js +1 -0
- package/dist/state/state-schema.js +298 -0
- package/dist/synchronization/config-codec.js +97 -0
- package/dist/synchronization/executor.js +700 -0
- package/dist/synchronization/follower-orchestration.js +939 -0
- package/dist/synchronization/follower-sync-config.js +81 -0
- package/dist/synchronization/npm-artifact.js +670 -0
- package/dist/synchronization/planner.js +378 -0
- package/dist/synchronization/recovery.js +397 -0
- package/dist/synchronization/resource-executors.js +1198 -0
- package/dist/synchronization/resource-plans.js +645 -0
- package/dist/synchronization/synchronization.errors.js +102 -0
- package/dist/synchronization/synchronization.layer.js +97 -0
- package/dist/synchronization/synchronization.service.js +11 -0
- package/dist/synchronization/synchronization.types.js +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Option, Schema } from "effect";
|
|
2
|
+
const encoder = new TextEncoder();
|
|
3
|
+
const ClaudeResultSchema = Schema.Struct({
|
|
4
|
+
type: Schema.Literal("result"),
|
|
5
|
+
result: Schema.String,
|
|
6
|
+
});
|
|
7
|
+
const GeminiResultSchema = Schema.Struct({
|
|
8
|
+
response: Schema.String,
|
|
9
|
+
});
|
|
10
|
+
const CodexEventSchema = Schema.Struct({
|
|
11
|
+
type: Schema.String,
|
|
12
|
+
item: Schema.optional(Schema.Struct({
|
|
13
|
+
type: Schema.String,
|
|
14
|
+
text: Schema.optional(Schema.String),
|
|
15
|
+
})),
|
|
16
|
+
});
|
|
17
|
+
export const encodeAgentTask = (task) => {
|
|
18
|
+
const document = {
|
|
19
|
+
schema: "canonfig.agent-task/v1",
|
|
20
|
+
task,
|
|
21
|
+
responseContract: {
|
|
22
|
+
format: "json",
|
|
23
|
+
actions: ["process"],
|
|
24
|
+
selfReportIsProof: false,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
return encoder.encode(`${JSON.stringify(document, undefined, 2)}\n`);
|
|
28
|
+
};
|
|
29
|
+
const harnessArguments = (harness) => {
|
|
30
|
+
switch (harness) {
|
|
31
|
+
case "codex":
|
|
32
|
+
return ["exec", "--json", "--sandbox", "read-only", "-"];
|
|
33
|
+
case "claude":
|
|
34
|
+
return ["--print", "--permission-mode", "plan", "--output-format", "json"];
|
|
35
|
+
case "gemini":
|
|
36
|
+
return ["--approval-mode", "plan", "--output-format", "json"];
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Harness selection is an explicit configuration value. No task text or
|
|
41
|
+
* executable name is inspected to infer a harness.
|
|
42
|
+
*/
|
|
43
|
+
export const adaptHarnessInvocation = (configuration, task) => ({
|
|
44
|
+
executable: configuration.executable,
|
|
45
|
+
arguments: [
|
|
46
|
+
...(configuration.arguments ?? []),
|
|
47
|
+
...harnessArguments(configuration.harness),
|
|
48
|
+
],
|
|
49
|
+
environment: configuration.environment ?? [],
|
|
50
|
+
input: encodeAgentTask(task),
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Normalizes each supported CLI's machine-readable envelope. Recording
|
|
54
|
+
* harnesses may return the proposal JSON directly.
|
|
55
|
+
*/
|
|
56
|
+
export const extractHarnessResponse = (harness, output) => {
|
|
57
|
+
if (harness === "codex") {
|
|
58
|
+
const events = output
|
|
59
|
+
.split(/\r?\n/u)
|
|
60
|
+
.filter((line) => line.trim().length > 0)
|
|
61
|
+
.flatMap((line) => {
|
|
62
|
+
try {
|
|
63
|
+
const decoded = Schema.decodeUnknownOption(CodexEventSchema)(JSON.parse(line));
|
|
64
|
+
return Option.isSome(decoded) ? [decoded.value] : [];
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const message = [...events].reverse().find((event) => event.item?.type === "agent_message" && event.item.text !== undefined)?.item?.text;
|
|
71
|
+
return message ?? output;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const parsed = JSON.parse(output);
|
|
75
|
+
if (harness === "claude") {
|
|
76
|
+
const decoded = Schema.decodeUnknownOption(ClaudeResultSchema)(parsed);
|
|
77
|
+
return Option.isSome(decoded) ? decoded.value.result : output;
|
|
78
|
+
}
|
|
79
|
+
const decoded = Schema.decodeUnknownOption(GeminiResultSchema)(parsed);
|
|
80
|
+
return Option.isSome(decoded) ? decoded.value.response : output;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return output;
|
|
84
|
+
}
|
|
85
|
+
};
|