@shogo-ai/worker 1.0.10
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 +432 -0
- package/bin/shogo.mjs +38 -0
- package/dist/cli.mjs +64 -0
- package/package.json +62 -0
- package/src/cli.ts +199 -0
- package/src/commands/agent.ts +123 -0
- package/src/commands/config.ts +29 -0
- package/src/commands/doctor.ts +128 -0
- package/src/commands/login.ts +126 -0
- package/src/commands/logs.ts +24 -0
- package/src/commands/project-checkout.ts +179 -0
- package/src/commands/project-pull.ts +133 -0
- package/src/commands/project-push.ts +89 -0
- package/src/commands/runtime.ts +104 -0
- package/src/commands/start.ts +290 -0
- package/src/commands/status.ts +22 -0
- package/src/commands/stop.ts +13 -0
- package/src/lib/__tests__/agent-launch.test.ts +92 -0
- package/src/lib/__tests__/cloud-login-coverage.test.ts +210 -0
- package/src/lib/__tests__/cloud-login.test.ts +218 -0
- package/src/lib/__tests__/cloud-sync-watcher.test.ts +214 -0
- package/src/lib/__tests__/config.test.ts +141 -0
- package/src/lib/__tests__/db-doctor.test.ts +204 -0
- package/src/lib/__tests__/git-cloner.test.ts +382 -0
- package/src/lib/__tests__/runtime-manager-auto-pull.test.ts +275 -0
- package/src/lib/__tests__/runtime-manager-cloud-sync-gate.test.ts +119 -0
- package/src/lib/__tests__/runtime-manager-coverage-gaps.test.ts +768 -0
- package/src/lib/__tests__/runtime-manager-describe-rejection.test.ts +42 -0
- package/src/lib/__tests__/runtime-manager-git-pull.test.ts +207 -0
- package/src/lib/__tests__/runtime-manager-idle-eviction.test.ts +196 -0
- package/src/lib/__tests__/runtime-manager-restart-cap.test.ts +310 -0
- package/src/lib/__tests__/runtime-manager-tree-sitter-env.test.ts +189 -0
- package/src/lib/__tests__/runtime-manager-wait-for-health.test.ts +269 -0
- package/src/lib/__tests__/runtime-resolver.test.ts +112 -0
- package/src/lib/__tests__/tunnel-coverage.test.ts +1094 -0
- package/src/lib/__tests__/tunnel-structured-502.test.ts +101 -0
- package/src/lib/__tests__/worker-commands-greenfield.test.ts +463 -0
- package/src/lib/__tests__/worker-libs-greenfield.test.ts +355 -0
- package/src/lib/__tests__/worker-transport-greenfield.test.ts +176 -0
- package/src/lib/api-discovery.ts +36 -0
- package/src/lib/cloud-login.ts +320 -0
- package/src/lib/cloud-sync-watcher.ts +322 -0
- package/src/lib/config.ts +68 -0
- package/src/lib/db-doctor.ts +355 -0
- package/src/lib/device-id.ts +27 -0
- package/src/lib/git-cloner.ts +354 -0
- package/src/lib/paths.ts +53 -0
- package/src/lib/preflight.ts +158 -0
- package/src/lib/process-manager.ts +123 -0
- package/src/lib/resource-limits.ts +340 -0
- package/src/lib/runtime-install.ts +371 -0
- package/src/lib/runtime-manager.ts +1873 -0
- package/src/lib/runtime-resolver.ts +136 -0
- package/src/lib/transport.ts +202 -0
- package/src/lib/tunnel.ts +710 -0
- package/src/lib/user-agent.ts +28 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (C) 2026 Shogo Technologies, Inc.
|
|
3
|
+
/**
|
|
4
|
+
* Canonical product token for the Shogo worker CLI, e.g. `shogo-cli/1.2.3`.
|
|
5
|
+
*
|
|
6
|
+
* Sent as the `User-Agent` on every request the worker makes to Shogo Cloud
|
|
7
|
+
* (heartbeat, tunnel WebSocket, device login). Without it, Node/Bun `fetch`
|
|
8
|
+
* emits a generic runtime User-Agent (or none), which is indistinguishable
|
|
9
|
+
* from arbitrary bot traffic at the CDN edge — a problem for headless
|
|
10
|
+
* cloud/datacenter deployments where the source ASN already looks like
|
|
11
|
+
* "Hosting" to bot-management heuristics (see issue #783). A stable,
|
|
12
|
+
* self-identifying UA lets the edge scope bot-mitigation exceptions to
|
|
13
|
+
* genuine worker traffic instead of relying on IP allowlists.
|
|
14
|
+
*
|
|
15
|
+
* `__SHOGO_WORKER_VERSION__` is injected by bundlers via
|
|
16
|
+
* `--define '__SHOGO_WORKER_VERSION__="x.y.z"'`. The `typeof` guard returns
|
|
17
|
+
* `'undefined'` without throwing when the identifier was never defined
|
|
18
|
+
* (standalone library consumers), in which case we fall back to a purely
|
|
19
|
+
* diagnostic `unknown` tag.
|
|
20
|
+
*/
|
|
21
|
+
declare const __SHOGO_WORKER_VERSION__: string | undefined;
|
|
22
|
+
|
|
23
|
+
export function workerUserAgent(): string {
|
|
24
|
+
if (typeof __SHOGO_WORKER_VERSION__ === 'string' && __SHOGO_WORKER_VERSION__.length > 0) {
|
|
25
|
+
return `shogo-cli/${__SHOGO_WORKER_VERSION__}`;
|
|
26
|
+
}
|
|
27
|
+
return 'shogo-cli/unknown';
|
|
28
|
+
}
|