twinclaw 1.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/README.md +66 -0
- package/bin/npm-twinclaw.js +17 -0
- package/bin/run-twinbot-cli.js +36 -0
- package/bin/twinbot.js +4 -0
- package/bin/twinclaw.js +4 -0
- package/dist/api/handlers/browser.js +160 -0
- package/dist/api/handlers/callback.js +80 -0
- package/dist/api/handlers/config-validate.js +19 -0
- package/dist/api/handlers/health.js +117 -0
- package/dist/api/handlers/local-state-backup.js +118 -0
- package/dist/api/handlers/persona-state.js +59 -0
- package/dist/api/handlers/skill-packages.js +94 -0
- package/dist/api/router.js +278 -0
- package/dist/api/runtime-event-producer.js +99 -0
- package/dist/api/shared.js +82 -0
- package/dist/api/websocket-hub.js +305 -0
- package/dist/config/config-loader.js +2 -0
- package/dist/config/env-schema.js +202 -0
- package/dist/config/env-validator.js +223 -0
- package/dist/config/identity-bootstrap.js +115 -0
- package/dist/config/json-config.js +344 -0
- package/dist/config/workspace.js +186 -0
- package/dist/core/channels-cli.js +77 -0
- package/dist/core/cli.js +119 -0
- package/dist/core/context-assembly.js +33 -0
- package/dist/core/doctor.js +365 -0
- package/dist/core/gateway-cli.js +323 -0
- package/dist/core/gateway.js +416 -0
- package/dist/core/heartbeat.js +54 -0
- package/dist/core/install-cli.js +320 -0
- package/dist/core/lane-executor.js +134 -0
- package/dist/core/logs-cli.js +70 -0
- package/dist/core/onboarding.js +760 -0
- package/dist/core/pairing-cli.js +78 -0
- package/dist/core/secret-vault-cli.js +204 -0
- package/dist/core/types.js +1 -0
- package/dist/index.js +404 -0
- package/dist/interfaces/dispatcher.js +214 -0
- package/dist/interfaces/telegram_handler.js +82 -0
- package/dist/interfaces/tui-dashboard.js +53 -0
- package/dist/interfaces/whatsapp_handler.js +94 -0
- package/dist/release/cli.js +97 -0
- package/dist/release/mvp-gate-cli.js +118 -0
- package/dist/release/twinbot-config-schema.js +162 -0
- package/dist/release/twinclaw-config-schema.js +162 -0
- package/dist/services/block-chunker.js +174 -0
- package/dist/services/browser-service.js +334 -0
- package/dist/services/context-lifecycle.js +314 -0
- package/dist/services/db.js +1055 -0
- package/dist/services/delivery-tracker.js +110 -0
- package/dist/services/dm-pairing.js +245 -0
- package/dist/services/embedding-service.js +125 -0
- package/dist/services/file-watcher.js +125 -0
- package/dist/services/inbound-debounce.js +92 -0
- package/dist/services/incident-manager.js +516 -0
- package/dist/services/job-scheduler.js +176 -0
- package/dist/services/local-state-backup.js +682 -0
- package/dist/services/mcp-client-adapter.js +291 -0
- package/dist/services/mcp-server-manager.js +143 -0
- package/dist/services/model-router.js +927 -0
- package/dist/services/mvp-gate.js +845 -0
- package/dist/services/orchestration-service.js +422 -0
- package/dist/services/persona-state.js +256 -0
- package/dist/services/policy-engine.js +92 -0
- package/dist/services/proactive-notifier.js +94 -0
- package/dist/services/queue-service.js +146 -0
- package/dist/services/release-pipeline.js +652 -0
- package/dist/services/runtime-budget-governor.js +415 -0
- package/dist/services/secret-vault.js +704 -0
- package/dist/services/semantic-memory.js +249 -0
- package/dist/services/skill-package-manager.js +806 -0
- package/dist/services/skill-registry.js +122 -0
- package/dist/services/streaming-output.js +75 -0
- package/dist/services/stt-service.js +39 -0
- package/dist/services/tts-service.js +44 -0
- package/dist/skills/builtin.js +250 -0
- package/dist/skills/shell.js +87 -0
- package/dist/skills/types.js +1 -0
- package/dist/types/api.js +1 -0
- package/dist/types/context-budget.js +1 -0
- package/dist/types/doctor.js +1 -0
- package/dist/types/file-watcher.js +1 -0
- package/dist/types/incident.js +1 -0
- package/dist/types/local-state-backup.js +1 -0
- package/dist/types/mcp.js +1 -0
- package/dist/types/messaging.js +1 -0
- package/dist/types/model-routing.js +1 -0
- package/dist/types/mvp-gate.js +2 -0
- package/dist/types/orchestration.js +1 -0
- package/dist/types/persona-state.js +22 -0
- package/dist/types/policy.js +1 -0
- package/dist/types/reasoning-graph.js +1 -0
- package/dist/types/release.js +1 -0
- package/dist/types/reliability.js +1 -0
- package/dist/types/runtime-budget.js +1 -0
- package/dist/types/scheduler.js +1 -0
- package/dist/types/secret-vault.js +1 -0
- package/dist/types/skill-packages.js +1 -0
- package/dist/types/websocket.js +14 -0
- package/dist/utils/logger.js +57 -0
- package/dist/utils/retry.js +61 -0
- package/dist/utils/secret-scan.js +208 -0
- package/mcp-servers.json +179 -0
- package/package.json +81 -0
- package/skill-packages.json +92 -0
- package/skill-packages.lock.json +5 -0
- package/src/skills/builtin.ts +275 -0
- package/src/skills/shell.ts +118 -0
- package/src/skills/types.ts +30 -0
- package/src/types/api.ts +252 -0
- package/src/types/blessed-contrib.d.ts +4 -0
- package/src/types/context-budget.ts +76 -0
- package/src/types/doctor.ts +29 -0
- package/src/types/file-watcher.ts +26 -0
- package/src/types/incident.ts +57 -0
- package/src/types/local-state-backup.ts +121 -0
- package/src/types/mcp.ts +106 -0
- package/src/types/messaging.ts +35 -0
- package/src/types/model-routing.ts +61 -0
- package/src/types/mvp-gate.ts +99 -0
- package/src/types/orchestration.ts +65 -0
- package/src/types/persona-state.ts +61 -0
- package/src/types/policy.ts +27 -0
- package/src/types/reasoning-graph.ts +58 -0
- package/src/types/release.ts +115 -0
- package/src/types/reliability.ts +43 -0
- package/src/types/runtime-budget.ts +85 -0
- package/src/types/scheduler.ts +47 -0
- package/src/types/secret-vault.ts +62 -0
- package/src/types/skill-packages.ts +81 -0
- package/src/types/sqlite-vec.d.ts +5 -0
- package/src/types/websocket.ts +122 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type SecretScope = 'api' | 'model' | 'messaging' | 'runtime' | 'storage' | 'integration';
|
|
2
|
+
|
|
3
|
+
export type SecretSource = 'env' | 'vault' | 'runtime';
|
|
4
|
+
|
|
5
|
+
export type SecretLifecycleStatus = 'active' | 'revoked' | 'expired';
|
|
6
|
+
|
|
7
|
+
export interface SecretMetadata {
|
|
8
|
+
name: string;
|
|
9
|
+
scope: SecretScope;
|
|
10
|
+
source: SecretSource;
|
|
11
|
+
required: boolean;
|
|
12
|
+
rotationWindowHours: number;
|
|
13
|
+
warningWindowHours: number;
|
|
14
|
+
lastRotatedAt: string | null;
|
|
15
|
+
expiresAt: string | null;
|
|
16
|
+
revokedAt: string | null;
|
|
17
|
+
status: SecretLifecycleStatus;
|
|
18
|
+
version: number;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SecretSetInput {
|
|
24
|
+
name: string;
|
|
25
|
+
value: string;
|
|
26
|
+
scope?: SecretScope;
|
|
27
|
+
source?: SecretSource;
|
|
28
|
+
required?: boolean;
|
|
29
|
+
rotationWindowHours?: number;
|
|
30
|
+
warningWindowHours?: number;
|
|
31
|
+
expiresAt?: string | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface SecretRotateInput {
|
|
35
|
+
name: string;
|
|
36
|
+
nextValue: string;
|
|
37
|
+
reason?: string;
|
|
38
|
+
rotationWindowHours?: number;
|
|
39
|
+
warningWindowHours?: number;
|
|
40
|
+
expiresAt?: string | null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface SecretRevokeInput {
|
|
44
|
+
name: string;
|
|
45
|
+
reason?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface SecretHealthReport {
|
|
49
|
+
missingRequired: string[];
|
|
50
|
+
expired: string[];
|
|
51
|
+
warnings: string[];
|
|
52
|
+
hasIssues: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface SecretDiagnostics {
|
|
56
|
+
health: SecretHealthReport;
|
|
57
|
+
total: number;
|
|
58
|
+
active: number;
|
|
59
|
+
revoked: number;
|
|
60
|
+
expired: number;
|
|
61
|
+
dueForRotation: string[];
|
|
62
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { McpServerConfig } from './mcp.js';
|
|
2
|
+
|
|
3
|
+
export interface SkillPackageMetadata {
|
|
4
|
+
displayName: string;
|
|
5
|
+
description: string;
|
|
6
|
+
deprecated?: boolean;
|
|
7
|
+
deprecationMessage?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface SkillPackageCompatibility {
|
|
11
|
+
node?: string;
|
|
12
|
+
runtimeApi?: string;
|
|
13
|
+
requiredTools?: string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface SkillPackageManifest {
|
|
17
|
+
name: string;
|
|
18
|
+
version: string;
|
|
19
|
+
metadata: SkillPackageMetadata;
|
|
20
|
+
dependencies?: Record<string, string>;
|
|
21
|
+
compatibility?: SkillPackageCompatibility;
|
|
22
|
+
server: McpServerConfig;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface SkillPackageCatalog {
|
|
26
|
+
packages: SkillPackageManifest[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface SkillPackageLockEntry {
|
|
30
|
+
name: string;
|
|
31
|
+
version: string;
|
|
32
|
+
dependencies: Record<string, string>;
|
|
33
|
+
checksum: string;
|
|
34
|
+
integrity: string;
|
|
35
|
+
installedAt: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface SkillPackageLockfile {
|
|
39
|
+
version: 1;
|
|
40
|
+
generatedAt: string;
|
|
41
|
+
packages: Record<string, SkillPackageLockEntry>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type SkillPackageViolationCode =
|
|
45
|
+
| 'missing-manifest'
|
|
46
|
+
| 'version-conflict'
|
|
47
|
+
| 'node-incompatible'
|
|
48
|
+
| 'runtime-api-incompatible'
|
|
49
|
+
| 'missing-required-tool'
|
|
50
|
+
| 'missing-dependency'
|
|
51
|
+
| 'duplicate-server-id';
|
|
52
|
+
|
|
53
|
+
export interface SkillPackageViolation {
|
|
54
|
+
packageName: string;
|
|
55
|
+
version: string;
|
|
56
|
+
code: SkillPackageViolationCode;
|
|
57
|
+
message: string;
|
|
58
|
+
remediation: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface SkillPackageDiagnostics {
|
|
62
|
+
installed: SkillPackageLockEntry[];
|
|
63
|
+
warnings: string[];
|
|
64
|
+
violations: SkillPackageViolation[];
|
|
65
|
+
activePackageCount: number;
|
|
66
|
+
blockedPackageCount: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface SkillPackageActivationPlan {
|
|
70
|
+
servers: McpServerConfig[];
|
|
71
|
+
diagnostics: SkillPackageDiagnostics;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface SkillPackageMutationResult {
|
|
75
|
+
action: 'install' | 'upgrade' | 'uninstall';
|
|
76
|
+
packageName: string;
|
|
77
|
+
version?: string;
|
|
78
|
+
changed: boolean;
|
|
79
|
+
diagnostics: SkillPackageDiagnostics;
|
|
80
|
+
}
|
|
81
|
+
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// ── Close Codes ────────────────────────────────────────────────────────────────
|
|
2
|
+
|
|
3
|
+
/** Deterministic close codes for WebSocket control-plane lifecycle events. */
|
|
4
|
+
export const WsCloseCode = {
|
|
5
|
+
/** Authentication token missing or invalid. */
|
|
6
|
+
AuthFailed: 4001,
|
|
7
|
+
/** Client did not complete auth handshake within the required window. */
|
|
8
|
+
AuthRequired: 4002,
|
|
9
|
+
/** Subscription request contains an unrecognised topic. */
|
|
10
|
+
InvalidSubscription: 4003,
|
|
11
|
+
/** Client failed to respond to ping heartbeats (stale). */
|
|
12
|
+
StaleConnection: 4004,
|
|
13
|
+
/** Server is shutting down gracefully. */
|
|
14
|
+
ServerShutdown: 4005,
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
export type WsCloseCode = (typeof WsCloseCode)[keyof typeof WsCloseCode];
|
|
18
|
+
|
|
19
|
+
// ── Event Topics ───────────────────────────────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
/** All subscribable runtime event topics. */
|
|
22
|
+
export type WsEventTopic = 'health' | 'reliability' | 'incidents' | 'routing';
|
|
23
|
+
|
|
24
|
+
// ── Inbound Messages (client → server) ────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
/** First message a client MUST send to authenticate the session. */
|
|
27
|
+
export interface WsAuthMessage {
|
|
28
|
+
type: 'auth';
|
|
29
|
+
/** Must equal the configured API_SECRET. */
|
|
30
|
+
token: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Subscribe to one or more event topics (sent after auth_ok). */
|
|
34
|
+
export interface WsSubscribeMessage {
|
|
35
|
+
type: 'subscribe';
|
|
36
|
+
topics: WsEventTopic[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Client-initiated ping to keep the connection alive. */
|
|
40
|
+
export interface WsPingMessage {
|
|
41
|
+
type: 'ping';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type WsInboundMessage = WsAuthMessage | WsSubscribeMessage | WsPingMessage;
|
|
45
|
+
|
|
46
|
+
// ── Outbound Messages (server → client) ────────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
/** Sent after a successful authentication handshake. */
|
|
49
|
+
export interface WsAuthOkMessage {
|
|
50
|
+
type: 'auth_ok';
|
|
51
|
+
clientId: string;
|
|
52
|
+
ts: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Acknowledgement for a successful subscription request. */
|
|
56
|
+
export interface WsSubscribedMessage {
|
|
57
|
+
type: 'subscribed';
|
|
58
|
+
topics: WsEventTopic[];
|
|
59
|
+
ts: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Server-originated error notification. */
|
|
63
|
+
export interface WsErrorMessage {
|
|
64
|
+
type: 'error';
|
|
65
|
+
code: number;
|
|
66
|
+
message: string;
|
|
67
|
+
ts: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Response to a client ping. */
|
|
71
|
+
export interface WsPongMessage {
|
|
72
|
+
type: 'pong';
|
|
73
|
+
ts: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ── Event Envelope ─────────────────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Versioned, typed wrapper for all runtime state update events.
|
|
80
|
+
*
|
|
81
|
+
* Every event emitted over the WebSocket channel is wrapped in this envelope
|
|
82
|
+
* so consumers can version-check, sequence, and timestamp inbound frames.
|
|
83
|
+
*/
|
|
84
|
+
export interface WsEventEnvelope<T = unknown> {
|
|
85
|
+
type: 'event';
|
|
86
|
+
/** Schema version — increment when the envelope shape changes. */
|
|
87
|
+
v: 1;
|
|
88
|
+
topic: WsEventTopic;
|
|
89
|
+
/** Monotonically increasing sequence number per hub instance. */
|
|
90
|
+
seq: number;
|
|
91
|
+
/** ISO-8601 server-side emission timestamp. */
|
|
92
|
+
ts: string;
|
|
93
|
+
payload: T;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ── Snapshot Payload ───────────────────────────────────────────────────────────
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Initial full-state snapshot dispatched to a client immediately after it
|
|
100
|
+
* subscribes. Only topics the client subscribed to are populated.
|
|
101
|
+
*/
|
|
102
|
+
export interface WsSnapshotPayload {
|
|
103
|
+
type: 'snapshot';
|
|
104
|
+
v: 1;
|
|
105
|
+
ts: string;
|
|
106
|
+
health?: unknown;
|
|
107
|
+
reliability?: unknown;
|
|
108
|
+
incidents?: unknown;
|
|
109
|
+
routing?: unknown;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ── Hub Diagnostics ────────────────────────────────────────────────────────────
|
|
113
|
+
|
|
114
|
+
/** Operator-facing metrics for the WebSocket hub. */
|
|
115
|
+
export interface WsHubMetrics {
|
|
116
|
+
activeClients: number;
|
|
117
|
+
totalConnections: number;
|
|
118
|
+
authFailures: number;
|
|
119
|
+
droppedEvents: number;
|
|
120
|
+
staleCleaned: number;
|
|
121
|
+
lastEventAt: string | null;
|
|
122
|
+
}
|