@delexec/ops 0.1.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 (55) hide show
  1. package/README.md +3 -0
  2. package/README.zh-CN.md +6 -0
  3. package/node_modules/@delexec/caller-controller/README.md +3 -0
  4. package/node_modules/@delexec/caller-controller/README.zh-CN.md +6 -0
  5. package/node_modules/@delexec/caller-controller/package.json +53 -0
  6. package/node_modules/@delexec/caller-controller/src/server.js +127 -0
  7. package/node_modules/@delexec/caller-controller-core/README.md +3 -0
  8. package/node_modules/@delexec/caller-controller-core/README.zh-CN.md +6 -0
  9. package/node_modules/@delexec/caller-controller-core/package.json +26 -0
  10. package/node_modules/@delexec/caller-controller-core/src/index.js +1612 -0
  11. package/node_modules/@delexec/caller-skill-adapter/package.json +12 -0
  12. package/node_modules/@delexec/caller-skill-adapter/src/server.js +1042 -0
  13. package/node_modules/@delexec/caller-skill-mcp-adapter/README.md +65 -0
  14. package/node_modules/@delexec/caller-skill-mcp-adapter/package.json +16 -0
  15. package/node_modules/@delexec/caller-skill-mcp-adapter/src/server.js +527 -0
  16. package/node_modules/@delexec/responder-controller/README.md +3 -0
  17. package/node_modules/@delexec/responder-controller/README.zh-CN.md +6 -0
  18. package/node_modules/@delexec/responder-controller/package.json +53 -0
  19. package/node_modules/@delexec/responder-controller/src/server.js +254 -0
  20. package/node_modules/@delexec/responder-runtime-core/README.md +3 -0
  21. package/node_modules/@delexec/responder-runtime-core/README.zh-CN.md +6 -0
  22. package/node_modules/@delexec/responder-runtime-core/package.json +26 -0
  23. package/node_modules/@delexec/responder-runtime-core/src/executors.js +326 -0
  24. package/node_modules/@delexec/responder-runtime-core/src/index.js +1202 -0
  25. package/node_modules/@delexec/runtime-utils/README.md +3 -0
  26. package/node_modules/@delexec/runtime-utils/README.zh-CN.md +6 -0
  27. package/node_modules/@delexec/runtime-utils/package.json +23 -0
  28. package/node_modules/@delexec/runtime-utils/src/index.js +338 -0
  29. package/node_modules/@delexec/sqlite-store/README.md +3 -0
  30. package/node_modules/@delexec/sqlite-store/README.zh-CN.md +6 -0
  31. package/node_modules/@delexec/sqlite-store/package.json +26 -0
  32. package/node_modules/@delexec/sqlite-store/src/index.js +68 -0
  33. package/node_modules/@delexec/transport-email/README.md +3 -0
  34. package/node_modules/@delexec/transport-email/README.zh-CN.md +6 -0
  35. package/node_modules/@delexec/transport-email/package.json +23 -0
  36. package/node_modules/@delexec/transport-email/src/index.js +185 -0
  37. package/node_modules/@delexec/transport-emailengine/README.md +3 -0
  38. package/node_modules/@delexec/transport-emailengine/README.zh-CN.md +6 -0
  39. package/node_modules/@delexec/transport-emailengine/package.json +26 -0
  40. package/node_modules/@delexec/transport-emailengine/src/index.js +210 -0
  41. package/node_modules/@delexec/transport-gmail/README.md +3 -0
  42. package/node_modules/@delexec/transport-gmail/README.zh-CN.md +6 -0
  43. package/node_modules/@delexec/transport-gmail/package.json +26 -0
  44. package/node_modules/@delexec/transport-gmail/src/index.js +295 -0
  45. package/node_modules/@delexec/transport-relay-http/README.md +3 -0
  46. package/node_modules/@delexec/transport-relay-http/README.zh-CN.md +6 -0
  47. package/node_modules/@delexec/transport-relay-http/package.json +23 -0
  48. package/node_modules/@delexec/transport-relay-http/src/index.js +124 -0
  49. package/package.json +64 -0
  50. package/src/cli.js +1571 -0
  51. package/src/config.js +1180 -0
  52. package/src/example-hotline-worker.js +65 -0
  53. package/src/example-hotline.js +196 -0
  54. package/src/logging.js +56 -0
  55. package/src/supervisor.js +3070 -0
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+
3
+ import process from "node:process";
4
+
5
+ import { summarizeExampleText } from "./example-hotline.js";
6
+
7
+ let raw = "";
8
+
9
+ process.stdin.setEncoding("utf8");
10
+ process.stdin.on("data", (chunk) => {
11
+ raw += chunk;
12
+ });
13
+
14
+ process.stdin.on("end", () => {
15
+ try {
16
+ const payload = raw.trim() ? JSON.parse(raw) : {};
17
+ const text = payload?.input?.text ?? payload?.payload?.text ?? "";
18
+ const diagnostics = payload?.input?.diagnostics ?? payload?.payload?.diagnostics ?? {};
19
+ const checks = Array.isArray(diagnostics?.checks) ? diagnostics.checks : [];
20
+ const links = Array.isArray(diagnostics?.links) ? diagnostics.links : [];
21
+ const nextSteps = Array.isArray(diagnostics?.next_steps)
22
+ ? diagnostics.next_steps
23
+ : ["Run delexec-ops status.", "Run delexec-ops debug-snapshot if a check fails."];
24
+ const failing = checks.filter((item) => item?.status === "fail").length;
25
+ const warnings = checks.filter((item) => item?.status === "warn").length;
26
+ const summary =
27
+ failing > 0
28
+ ? `Local delegated-execution workspace has ${failing} failing check(s).`
29
+ : warnings > 0
30
+ ? `Local delegated-execution workspace is callable, with ${warnings} warning check(s).`
31
+ : "Local delegated-execution workspace is ready for a first trial call.";
32
+ process.stdout.write(
33
+ JSON.stringify({
34
+ status: "ok",
35
+ output: {
36
+ summary: text ? `${summary} Note: ${summarizeExampleText(text)}` : summary,
37
+ checks,
38
+ links,
39
+ next_steps: nextSteps
40
+ },
41
+ schema_valid: true,
42
+ usage: {
43
+ tokens_in: String(text || "").trim() ? 1 : 0,
44
+ tokens_out: Math.max(1, checks.length + links.length + nextSteps.length)
45
+ }
46
+ })
47
+ );
48
+ } catch (error) {
49
+ process.stdout.write(
50
+ JSON.stringify({
51
+ status: "error",
52
+ error: {
53
+ code: "HOTLINE_INVALID_INPUT",
54
+ message: error instanceof Error ? error.message : "invalid_input",
55
+ retryable: false
56
+ },
57
+ schema_valid: true,
58
+ usage: {
59
+ tokens_in: 0,
60
+ tokens_out: 0
61
+ }
62
+ })
63
+ );
64
+ }
65
+ });
@@ -0,0 +1,196 @@
1
+ import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+
4
+ export const LOCAL_EXAMPLE_HOTLINE_ID = "local.delegated-execution.workspace-summary.v1";
5
+ export const LOCAL_EXAMPLE_DISPLAY_NAME = "Local Workspace Doctor";
6
+ export const LOCAL_EXAMPLE_TASK_TYPE = "workspace_diagnose";
7
+ export const LOCAL_EXAMPLE_CAPABILITY = "workspace.diagnose";
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+ function quoteShellArg(value) {
13
+ return JSON.stringify(String(value));
14
+ }
15
+
16
+ export function resolveExampleWorkerPath() {
17
+ return path.resolve(__dirname, "example-hotline-worker.js");
18
+ }
19
+
20
+ export function buildExampleHotlineDefinition(existing = null) {
21
+ const base = {
22
+ hotline_id: LOCAL_EXAMPLE_HOTLINE_ID,
23
+ display_name: LOCAL_EXAMPLE_DISPLAY_NAME,
24
+ description:
25
+ "A read-only local delegated-execution workspace diagnostic. It checks local runtime readiness and points you to the next debug step without using admin secrets.",
26
+ summary:
27
+ "Run this first to verify that Caller, Responder, Relay, and Agent-facing adapters are ready on this machine.",
28
+ enabled: true,
29
+ task_types: [LOCAL_EXAMPLE_TASK_TYPE],
30
+ capabilities: [LOCAL_EXAMPLE_CAPABILITY],
31
+ tags: ["local", "example", "diagnostic"],
32
+ adapter_type: "process",
33
+ adapter: {
34
+ cmd: `${quoteShellArg(process.execPath)} ${quoteShellArg(resolveExampleWorkerPath())}`
35
+ },
36
+ timeouts: {
37
+ soft_timeout_s: 60,
38
+ hard_timeout_s: 180
39
+ },
40
+ review_status: "local_only",
41
+ submitted_for_review: false,
42
+ input_schema: {
43
+ type: "object",
44
+ additionalProperties: false,
45
+ properties: {
46
+ text: {
47
+ type: "string",
48
+ description:
49
+ "Optional note for the diagnostic run, such as what you just tried or which page sent you here."
50
+ }
51
+ }
52
+ },
53
+ output_schema: buildWorkspaceDoctorOutputSchema(),
54
+ input_summary: "Optional: add a short note about what you are trying to verify. The diagnostic itself is read-only.",
55
+ output_summary:
56
+ "Returns a compact local readiness report with service checks, useful console links, and next debug commands.",
57
+ recommended_for: [
58
+ "First local run after bootstrap",
59
+ "Verifying the Agent-callable local environment",
60
+ "Checking where to look next when a trial call fails"
61
+ ],
62
+ limitations: [
63
+ "Read-only: it does not approve platform reviews or mutate admin settings.",
64
+ "Local-only: it reports this machine's client runtime, not public platform availability."
65
+ ],
66
+ input_examples: [
67
+ {
68
+ title: "First local smoke check",
69
+ input: {
70
+ text: "I opened Catalog from Dashboard next-up and want to verify the local runtime."
71
+ }
72
+ }
73
+ ],
74
+ output_examples: [
75
+ {
76
+ title: "Workspace ready",
77
+ output: {
78
+ summary: "Local delegated-execution workspace is ready for a first trial call.",
79
+ checks: [
80
+ { name: "caller", status: "ok", detail: "Caller controller is running." },
81
+ { name: "responder", status: "ok", detail: "Local responder is enabled." }
82
+ ],
83
+ links: [
84
+ { label: "Runtime", url: "http://127.0.0.1:4173/general/runtime" },
85
+ { label: "Calls", url: "http://127.0.0.1:4173/caller/calls" }
86
+ ],
87
+ next_steps: ["Open Calls to inspect the request result.", "Run delexec-ops debug-snapshot if a check fails."]
88
+ }
89
+ }
90
+ ]
91
+ };
92
+ if (!existing || typeof existing !== "object") {
93
+ return base;
94
+ }
95
+ return {
96
+ ...base,
97
+ enabled: existing.enabled === false ? false : base.enabled,
98
+ review_status: typeof existing.review_status === "string" ? existing.review_status : base.review_status,
99
+ submitted_for_review:
100
+ typeof existing.submitted_for_review === "boolean" ? existing.submitted_for_review : base.submitted_for_review,
101
+ metadata: existing.metadata && typeof existing.metadata === "object" ? existing.metadata : base.metadata
102
+ };
103
+ }
104
+
105
+ export function isExampleHotlineDefinitionStale(existing = null) {
106
+ if (!existing || typeof existing !== "object") {
107
+ return false;
108
+ }
109
+ const current = buildExampleHotlineDefinition();
110
+ return (
111
+ existing.display_name !== current.display_name ||
112
+ JSON.stringify(existing.task_types || []) !== JSON.stringify(current.task_types || []) ||
113
+ JSON.stringify(existing.capabilities || []) !== JSON.stringify(current.capabilities || []) ||
114
+ JSON.stringify(existing.tags || []) !== JSON.stringify(current.tags || [])
115
+ );
116
+ }
117
+
118
+ export function buildWorkspaceDoctorOutputSchema() {
119
+ return {
120
+ type: "object",
121
+ additionalProperties: false,
122
+ required: ["summary", "checks", "links", "next_steps"],
123
+ properties: {
124
+ summary: {
125
+ type: "string",
126
+ description: "Human-readable local readiness summary."
127
+ },
128
+ checks: {
129
+ type: "array",
130
+ description: "Read-only local service and configuration checks.",
131
+ items: {
132
+ type: "object",
133
+ additionalProperties: false,
134
+ required: ["name", "status", "detail"],
135
+ properties: {
136
+ name: { type: "string" },
137
+ status: { type: "string", enum: ["ok", "warn", "fail"] },
138
+ detail: { type: "string" }
139
+ }
140
+ }
141
+ },
142
+ links: {
143
+ type: "array",
144
+ description: "Console links that help inspect the local run.",
145
+ items: {
146
+ type: "object",
147
+ additionalProperties: false,
148
+ required: ["label", "url"],
149
+ properties: {
150
+ label: { type: "string" },
151
+ url: { type: "string" }
152
+ }
153
+ }
154
+ },
155
+ next_steps: {
156
+ type: "array",
157
+ description: "Suggested local debug or follow-up commands.",
158
+ items: { type: "string" }
159
+ }
160
+ }
161
+ };
162
+ }
163
+
164
+ export function buildExampleRequestBody({
165
+ text,
166
+ responderId,
167
+ hotlineId = LOCAL_EXAMPLE_HOTLINE_ID,
168
+ signerPublicKeyPem = null,
169
+ diagnostics = null
170
+ } = {}) {
171
+ const payloadText = String(text || "Check this local delegated-execution workspace.").trim();
172
+ const payload = {
173
+ text: payloadText,
174
+ ...(diagnostics && typeof diagnostics === "object" ? { diagnostics } : {})
175
+ };
176
+ return {
177
+ responder_id: responderId,
178
+ hotline_id: hotlineId,
179
+ expected_signer_public_key_pem: signerPublicKeyPem,
180
+ task_type: LOCAL_EXAMPLE_TASK_TYPE,
181
+ input: payload,
182
+ payload,
183
+ output_schema: buildWorkspaceDoctorOutputSchema()
184
+ };
185
+ }
186
+
187
+ export function summarizeExampleText(text) {
188
+ const value = String(text || "").trim().replace(/\s+/g, " ");
189
+ if (!value) {
190
+ return "No input text provided.";
191
+ }
192
+ if (value.length <= 120) {
193
+ return value;
194
+ }
195
+ return `${value.slice(0, 117)}...`;
196
+ }
package/src/logging.js ADDED
@@ -0,0 +1,56 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+
4
+ import { ensureOpsDirectories, getOpsHomeDir } from "@delexec/runtime-utils";
5
+
6
+ function nowIso() {
7
+ return new Date().toISOString();
8
+ }
9
+
10
+ export function getOpsLogsDir() {
11
+ ensureOpsDirectories();
12
+ return path.join(getOpsHomeDir(), "logs");
13
+ }
14
+
15
+ export function getServiceLogFile(service) {
16
+ return path.join(getOpsLogsDir(), `${service}.log`);
17
+ }
18
+
19
+ export function getSupervisorEventsFile() {
20
+ return path.join(getOpsLogsDir(), "supervisor.events.jsonl");
21
+ }
22
+
23
+ export function appendServiceLog(service, chunk) {
24
+ fs.appendFileSync(getServiceLogFile(service), chunk, "utf8");
25
+ }
26
+
27
+ export function appendSupervisorEvent(event) {
28
+ const record = {
29
+ at: nowIso(),
30
+ ...event
31
+ };
32
+ fs.appendFileSync(getSupervisorEventsFile(), `${JSON.stringify(record)}\n`, "utf8");
33
+ return record;
34
+ }
35
+
36
+ export function readLogTail(filePath, { maxLines = 200 } = {}) {
37
+ if (!fs.existsSync(filePath)) {
38
+ return [];
39
+ }
40
+ const lines = fs.readFileSync(filePath, "utf8").split(/\r?\n/).filter(Boolean);
41
+ return lines.slice(-maxLines);
42
+ }
43
+
44
+ export function readServiceLogTail(service, options) {
45
+ return readLogTail(getServiceLogFile(service), options);
46
+ }
47
+
48
+ export function readSupervisorEventTail(options) {
49
+ return readLogTail(getSupervisorEventsFile(), options).map((line) => {
50
+ try {
51
+ return JSON.parse(line);
52
+ } catch {
53
+ return { at: null, type: "invalid_log_line", raw: line };
54
+ }
55
+ });
56
+ }