totemlayer 0.1.6 → 0.1.12
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/README.md +26 -44
- package/bin/agent-profile.mjs +18 -2
- package/bin/agent-runner.mjs +25 -17
- package/bin/agent-setup.mjs +141 -55
- package/bin/automatic-runtime.mjs +131 -0
- package/bin/cloud-bootstrap.mjs +64 -0
- package/bin/connected-agent-service.mjs +84 -0
- package/bin/device-login.mjs +168 -0
- package/bin/installation.mjs +160 -0
- package/bin/mcp-install.mjs +74 -18
- package/bin/mcp.mjs +55 -0
- package/bin/mission-agent-service.mjs +40 -2
- package/bin/mission-infrastructure.mjs +609 -0
- package/bin/mission-worker.mjs +59 -3
- package/bin/model-adapter.mjs +164 -0
- package/bin/network-runtime.mjs +58 -3
- package/bin/platform-client.mjs +3 -0
- package/bin/provider-detection.mjs +94 -0
- package/bin/runtime-installation.mjs +305 -0
- package/bin/sdk/index.js +5 -0
- package/bin/totem.mjs +13 -3
- package/bin/worker-core/adapters.mjs +279 -0
- package/bin/worker-core/errors.mjs +60 -0
- package/package.json +2 -1
- package/scripts/prepare.mjs +5 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const SAFE_CODES = new Set([
|
|
2
|
+
"INTERNAL_ERROR",
|
|
3
|
+
"INVALID_AGENT_RESULT",
|
|
4
|
+
"INVALID_ADAPTER_ENV",
|
|
5
|
+
"INVALID_RUNNER_ARGUMENTS",
|
|
6
|
+
"INSECURE_WORKER_CONFIG",
|
|
7
|
+
"INVALID_WORKER_CONFIG",
|
|
8
|
+
"INVALID_ADAPTER_CONFIG",
|
|
9
|
+
"JOURNAL_INSIDE_WORKSPACE",
|
|
10
|
+
"INVALID_BROKER_MODULE",
|
|
11
|
+
"BROKER_IDENTITY_REQUIRED",
|
|
12
|
+
"BROKER_IDENTITY_MISMATCH",
|
|
13
|
+
"SECRET_VALUES_NOT_ALLOWED_IN_CONFIG",
|
|
14
|
+
"UNKNOWN_ADAPTER_TYPE",
|
|
15
|
+
"INVALID_LEASE",
|
|
16
|
+
"RUN_CANCELLED",
|
|
17
|
+
"BROKER_UNAVAILABLE",
|
|
18
|
+
"INVALID_JOURNAL",
|
|
19
|
+
"AUTHORIZATION_DENIED",
|
|
20
|
+
"WORKER_BUSY",
|
|
21
|
+
"INVALID_JOURNAL_PATH",
|
|
22
|
+
"INSECURE_JOURNAL_DIRECTORY",
|
|
23
|
+
"JOURNAL_LOCK_FAILED",
|
|
24
|
+
"WORKER_ALREADY_LOCKED",
|
|
25
|
+
"JOURNAL_NOT_LOCKED",
|
|
26
|
+
"INVALID_PROMPT",
|
|
27
|
+
"AGENT_START_FAILED",
|
|
28
|
+
"AGENT_EXIT_FAILED",
|
|
29
|
+
"AGENT_REPORTED_FAILURE",
|
|
30
|
+
"UNKNOWN_HTTP_OUTCOME",
|
|
31
|
+
"HTTP_AGENT_FAILED",
|
|
32
|
+
"OUTPUT_LIMIT_EXCEEDED",
|
|
33
|
+
"RUN_TIMEOUT",
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
export class WorkerError extends Error {
|
|
37
|
+
constructor(code) {
|
|
38
|
+
super(code);
|
|
39
|
+
this.name = "WorkerError";
|
|
40
|
+
this.code = code;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function errorCode(error) {
|
|
45
|
+
return error instanceof WorkerError && SAFE_CODES.has(error.code) ? error.code : "INTERNAL_ERROR";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function validateResult(value) {
|
|
49
|
+
if (
|
|
50
|
+
!value ||
|
|
51
|
+
typeof value !== "object" ||
|
|
52
|
+
!["completed", "blocked", "failed"].includes(value.status) ||
|
|
53
|
+
typeof value.output !== "string" ||
|
|
54
|
+
Buffer.byteLength(value.output) > 16 * 1024 * 1024 ||
|
|
55
|
+
(value.status === "completed" && !value.output.trim())
|
|
56
|
+
) {
|
|
57
|
+
throw new WorkerError("INVALID_AGENT_RESULT");
|
|
58
|
+
}
|
|
59
|
+
return { status: value.status, output: value.output };
|
|
60
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "totemlayer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Cross-platform CLI for TotemLayer agent identity and authorization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"zod": "4.4.3"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
|
+
"postinstall": "node bin/installation.mjs --postinstall",
|
|
39
40
|
"prepack": "node scripts/prepare.mjs"
|
|
40
41
|
}
|
|
41
42
|
}
|
package/scripts/prepare.mjs
CHANGED
|
@@ -13,3 +13,8 @@ for (const name of await readdir(new URL("../../sdk/dist/", import.meta.url))) {
|
|
|
13
13
|
if (name.endsWith(".js"))
|
|
14
14
|
await copyFile(new URL(`../../sdk/dist/${name}`, import.meta.url), new URL(name, destination));
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
const workerCore = new URL("../bin/worker-core/", import.meta.url);
|
|
18
|
+
await mkdir(workerCore, { recursive: true });
|
|
19
|
+
for (const name of ["adapters.mjs", "errors.mjs"])
|
|
20
|
+
await copyFile(new URL(`../../agent-worker/${name}`, import.meta.url), new URL(name, workerCore));
|