@soederpop/luca 0.0.6 → 0.0.8
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/CLAUDE.md +10 -1
- package/RUNME.md +56 -0
- package/bun.lock +1 -1
- package/commands/build-bootstrap.ts +78 -0
- package/commands/build-scaffolds.ts +24 -2
- package/commands/try-all-challenges.ts +543 -0
- package/commands/try-challenge.ts +100 -0
- package/docs/README.md +52 -80
- package/docs/TABLE-OF-CONTENTS.md +82 -51
- package/docs/apis/clients/elevenlabs.md +232 -8
- package/docs/apis/clients/graph.md +59 -8
- package/docs/apis/clients/openai.md +362 -2
- package/docs/apis/clients/rest.md +122 -2
- package/docs/apis/clients/websocket.md +71 -17
- package/docs/apis/features/agi/assistant.md +9 -3
- package/docs/apis/features/agi/assistants-manager.md +2 -2
- package/docs/apis/features/agi/claude-code.md +153 -14
- package/docs/apis/features/agi/conversation-history.md +15 -3
- package/docs/apis/features/agi/conversation.md +133 -20
- package/docs/apis/features/agi/openai-codex.md +90 -12
- package/docs/apis/features/agi/skills-library.md +23 -5
- package/docs/apis/features/node/container-link.md +59 -0
- package/docs/apis/features/node/content-db.md +1 -1
- package/docs/apis/features/node/disk-cache.md +1 -1
- package/docs/apis/features/node/dns.md +1 -0
- package/docs/apis/features/node/docker.md +2 -1
- package/docs/apis/features/node/esbuild.md +4 -3
- package/docs/apis/features/node/file-manager.md +13 -4
- package/docs/apis/features/node/fs.md +726 -171
- package/docs/apis/features/node/git.md +1 -0
- package/docs/apis/features/node/google-auth.md +23 -4
- package/docs/apis/features/node/google-calendar.md +14 -2
- package/docs/apis/features/node/google-docs.md +15 -2
- package/docs/apis/features/node/google-drive.md +21 -3
- package/docs/apis/features/node/google-sheets.md +14 -2
- package/docs/apis/features/node/grep.md +2 -0
- package/docs/apis/features/node/helpers.md +29 -0
- package/docs/apis/features/node/ink.md +2 -2
- package/docs/apis/features/node/networking.md +39 -4
- package/docs/apis/features/node/os.md +28 -0
- package/docs/apis/features/node/postgres.md +26 -4
- package/docs/apis/features/node/proc.md +37 -28
- package/docs/apis/features/node/process-manager.md +33 -5
- package/docs/apis/features/node/repl.md +1 -1
- package/docs/apis/features/node/runpod.md +1 -0
- package/docs/apis/features/node/secure-shell.md +7 -0
- package/docs/apis/features/node/semantic-search.md +12 -5
- package/docs/apis/features/node/sqlite.md +26 -4
- package/docs/apis/features/node/telegram.md +30 -5
- package/docs/apis/features/node/tts.md +17 -2
- package/docs/apis/features/node/ui.md +1 -1
- package/docs/apis/features/node/vault.md +4 -9
- package/docs/apis/features/node/vm.md +3 -12
- package/docs/apis/features/node/window-manager.md +128 -20
- package/docs/apis/features/web/asset-loader.md +13 -1
- package/docs/apis/features/web/container-link.md +59 -0
- package/docs/apis/features/web/esbuild.md +4 -3
- package/docs/apis/features/web/helpers.md +29 -0
- package/docs/apis/features/web/network.md +16 -2
- package/docs/apis/features/web/speech.md +16 -2
- package/docs/apis/features/web/vault.md +4 -9
- package/docs/apis/features/web/vm.md +3 -12
- package/docs/apis/features/web/voice.md +18 -1
- package/docs/apis/servers/express.md +18 -2
- package/docs/apis/servers/mcp.md +29 -4
- package/docs/apis/servers/websocket.md +34 -6
- package/docs/bootstrap/CLAUDE.md +100 -0
- package/docs/bootstrap/SKILL.md +222 -0
- package/docs/bootstrap/templates/about-command.ts +41 -0
- package/docs/bootstrap/templates/docs-models.ts +22 -0
- package/docs/bootstrap/templates/docs-readme.md +43 -0
- package/docs/bootstrap/templates/example-feature.ts +53 -0
- package/docs/bootstrap/templates/health-endpoint.ts +15 -0
- package/docs/bootstrap/templates/luca-cli.ts +25 -0
- package/docs/bootstrap/templates/runme.md +54 -0
- package/docs/challenges/caching-proxy.md +16 -0
- package/docs/challenges/content-db-round-trip.md +14 -0
- package/docs/challenges/custom-command.md +9 -0
- package/docs/challenges/file-watcher-pipeline.md +11 -0
- package/docs/challenges/grep-audit-report.md +15 -0
- package/docs/challenges/multi-feature-dashboard.md +14 -0
- package/docs/challenges/process-orchestrator.md +17 -0
- package/docs/challenges/rest-api-server-with-client.md +12 -0
- package/docs/challenges/script-runner-with-vm.md +11 -0
- package/docs/challenges/simple-rest-api.md +15 -0
- package/docs/challenges/websocket-serve-and-client.md +11 -0
- package/docs/challenges/yaml-config-system.md +14 -0
- package/docs/command-system-overhaul.md +94 -0
- package/docs/examples/assistant/CORE.md +18 -0
- package/docs/examples/assistant/hooks.ts +3 -0
- package/docs/examples/assistant/tools.ts +10 -0
- package/docs/examples/window-manager-layouts.md +180 -0
- package/docs/in-memory-fs.md +4 -0
- package/docs/models.ts +13 -10
- package/docs/philosophy.md +4 -3
- package/docs/reports/console-hmr-design.md +170 -0
- package/docs/reports/helper-semantic-search.md +72 -0
- package/docs/scaffolds/client.md +29 -20
- package/docs/scaffolds/command.md +64 -50
- package/docs/scaffolds/endpoint.md +31 -36
- package/docs/scaffolds/feature.md +28 -18
- package/docs/scaffolds/selector.md +91 -0
- package/docs/scaffolds/server.md +18 -9
- package/docs/selectors.md +115 -0
- package/docs/sessions/custom-command/attempt-log-2.md +195 -0
- package/docs/sessions/file-watcher-pipeline/attempt-log-1.md +728 -0
- package/docs/sessions/file-watcher-pipeline/attempt-log-2.md +555 -0
- package/docs/sessions/grep-audit-report/attempt-log-1.md +289 -0
- package/docs/sessions/multi-feature-dashboard/attempt-log-2.md +679 -0
- package/docs/sessions/rest-api-server-with-client/attempt-log-1.md +1 -0
- package/docs/sessions/rest-api-server-with-client/attempt-log-3.md +920 -0
- package/docs/sessions/simple-rest-api/attempt-log-1.md +593 -0
- package/docs/sessions/websocket-serve-and-client/attempt-log-2.md +995 -0
- package/docs/tutorials/00-bootstrap.md +148 -0
- package/docs/tutorials/07-endpoints.md +7 -7
- package/docs/tutorials/08-commands.md +153 -72
- package/luca.cli.ts +3 -0
- package/package.json +6 -5
- package/public/index.html +1430 -0
- package/scripts/examples/using-ollama.ts +2 -1
- package/scripts/update-introspection-data.ts +2 -2
- package/src/agi/endpoints/experts.ts +1 -1
- package/src/agi/features/assistant.ts +7 -0
- package/src/agi/features/assistants-manager.ts +5 -5
- package/src/agi/features/claude-code.ts +263 -3
- package/src/agi/features/conversation-history.ts +7 -1
- package/src/agi/features/conversation.ts +26 -3
- package/src/agi/features/openai-codex.ts +26 -2
- package/src/agi/features/openapi.ts +6 -1
- package/src/agi/features/skills-library.ts +9 -1
- package/src/bootstrap/generated.ts +595 -0
- package/src/cli/cli.ts +64 -21
- package/src/client.ts +23 -357
- package/src/clients/civitai/index.ts +1 -1
- package/src/clients/client-template.ts +1 -1
- package/src/clients/comfyui/index.ts +13 -2
- package/src/clients/elevenlabs/index.ts +2 -1
- package/src/clients/graph.ts +87 -0
- package/src/clients/openai/index.ts +10 -1
- package/src/clients/rest.ts +207 -0
- package/src/clients/websocket.ts +176 -0
- package/src/command.ts +281 -34
- package/src/commands/bootstrap.ts +185 -0
- package/src/commands/chat.ts +5 -4
- package/src/commands/describe.ts +341 -4
- package/src/commands/help.ts +35 -9
- package/src/commands/index.ts +3 -0
- package/src/commands/introspect.ts +92 -2
- package/src/commands/prompt.ts +5 -6
- package/src/commands/run.ts +75 -10
- package/src/commands/save-api-docs.ts +49 -0
- package/src/commands/scaffold.ts +169 -23
- package/src/commands/select.ts +94 -0
- package/src/commands/serve.ts +10 -1
- package/src/container.ts +15 -0
- package/src/endpoint.ts +19 -0
- package/src/graft.ts +181 -0
- package/src/introspection/generated.agi.ts +12458 -8968
- package/src/introspection/generated.node.ts +10573 -7145
- package/src/introspection/generated.web.ts +1 -1
- package/src/introspection/index.ts +26 -0
- package/src/node/container.ts +6 -7
- package/src/node/features/content-db.ts +49 -2
- package/src/node/features/disk-cache.ts +16 -9
- package/src/node/features/dns.ts +16 -3
- package/src/node/features/docker.ts +16 -4
- package/src/node/features/esbuild.ts +22 -2
- package/src/node/features/file-manager.ts +184 -29
- package/src/node/features/fs.ts +704 -248
- package/src/node/features/git.ts +21 -8
- package/src/node/features/grep.ts +23 -3
- package/src/node/features/helpers.ts +372 -43
- package/src/node/features/networking.ts +39 -4
- package/src/node/features/opener.ts +28 -15
- package/src/node/features/os.ts +76 -0
- package/src/node/features/port-exposer.ts +11 -1
- package/src/node/features/postgres.ts +17 -1
- package/src/node/features/proc.ts +4 -1
- package/src/node/features/python.ts +63 -14
- package/src/node/features/repl.ts +11 -7
- package/src/node/features/runpod.ts +16 -3
- package/src/node/features/secure-shell.ts +27 -2
- package/src/node/features/semantic-search.ts +12 -1
- package/src/node/features/ui.ts +5 -69
- package/src/node/features/vm.ts +17 -0
- package/src/node/features/window-manager.ts +68 -20
- package/src/node.ts +5 -0
- package/src/scaffolds/generated.ts +492 -290
- package/src/scaffolds/template.ts +9 -0
- package/src/schemas/base.ts +46 -5
- package/src/selector.ts +282 -0
- package/src/server.ts +11 -0
- package/src/servers/express.ts +27 -12
- package/src/servers/socket.ts +45 -11
- package/src/web/clients/socket.ts +4 -1
- package/src/web/container.ts +2 -1
- package/src/web/features/network.ts +7 -1
- package/src/web/features/voice-recognition.ts +16 -1
- package/test/clients-servers.test.ts +2 -1
- package/test/command.test.ts +267 -0
- package/test/vm-context.test.ts +146 -0
- package/test-integration/assistants-manager.test.ts +10 -20
- package/docs/apis/features/node/launcher-app-command-listener.md +0 -145
- package/docs/examples/launcher-app-command-listener.md +0 -120
- package/docs/tasks/web-container-helper-discovery.md +0 -71
- package/docs/todos.md +0 -1
- package/scripts/test-command-listener.ts +0 -123
- package/src/node/features/launcher-app-command-listener.ts +0 -389
package/src/graft.ts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { Helper } from './helper.js'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
export type GraftScope = 'features' | 'clients' | 'servers' | 'commands' | 'endpoints' | 'selectors'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Export names that map to static class properties or receive special handling.
|
|
8
|
+
* Everything else that is a function goes onto the prototype as a method.
|
|
9
|
+
*/
|
|
10
|
+
const RESERVED_EXPORTS = new Set([
|
|
11
|
+
'description', 'envVars',
|
|
12
|
+
'stateSchema', 'optionsSchema', 'eventsSchema',
|
|
13
|
+
'args', 'argsSchema',
|
|
14
|
+
'positionals',
|
|
15
|
+
'getters',
|
|
16
|
+
'run', 'handler',
|
|
17
|
+
'cacheKey', 'cacheable',
|
|
18
|
+
'default',
|
|
19
|
+
])
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns true when the candidate is a class (constructor function) whose
|
|
23
|
+
* prototype chain includes BaseClass. Handles cross-module-boundary cases
|
|
24
|
+
* by checking both reference equality and class name.
|
|
25
|
+
*/
|
|
26
|
+
export function isNativeHelperClass(candidate: unknown, BaseClass: typeof Helper | any): boolean {
|
|
27
|
+
if (typeof candidate !== 'function') return false
|
|
28
|
+
if (!BaseClass) return false
|
|
29
|
+
if (candidate === BaseClass) return true
|
|
30
|
+
|
|
31
|
+
let proto = Object.getPrototypeOf(candidate)
|
|
32
|
+
while (proto) {
|
|
33
|
+
if (proto === BaseClass) return true
|
|
34
|
+
if (BaseClass.name && proto.name === BaseClass.name) return true
|
|
35
|
+
proto = Object.getPrototypeOf(proto)
|
|
36
|
+
}
|
|
37
|
+
return false
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Synthesize a Helper subclass from plain module exports.
|
|
42
|
+
*
|
|
43
|
+
* Given a set of exports from a module file and a Helper base class, produces a
|
|
44
|
+
* fully-formed subclass ready for registration in the appropriate registry.
|
|
45
|
+
*
|
|
46
|
+
* Static export mappings:
|
|
47
|
+
* description → static description
|
|
48
|
+
* stateSchema → static stateSchema
|
|
49
|
+
* optionsSchema → static optionsSchema (also aliased from `args`)
|
|
50
|
+
* eventsSchema → static eventsSchema
|
|
51
|
+
* envVars → static envVars
|
|
52
|
+
* argsSchema → static argsSchema (Command scope; also aliased from `args`)
|
|
53
|
+
* positionals → static positionals (Command scope; stored for CLI dispatch mapping)
|
|
54
|
+
* getters → Object.defineProperty(proto, key, { get }) per key
|
|
55
|
+
* run → override run() for Command scope (receives named args + context)
|
|
56
|
+
* handler → legacy: wired through parseArgs() for backward compat
|
|
57
|
+
* [fn exports] → prototype methods (all other function-valued named exports)
|
|
58
|
+
*/
|
|
59
|
+
export function graftModule<T extends typeof Helper>(
|
|
60
|
+
BaseClass: T,
|
|
61
|
+
moduleExports: Record<string, any>,
|
|
62
|
+
id: string,
|
|
63
|
+
scope: GraftScope,
|
|
64
|
+
): T {
|
|
65
|
+
// Resolve schemas — prefer explicit exports, fall back to whatever the base class has
|
|
66
|
+
const optionsSchema = moduleExports.optionsSchema
|
|
67
|
+
?? moduleExports.args
|
|
68
|
+
?? (BaseClass as any).optionsSchema
|
|
69
|
+
|
|
70
|
+
const stateSchema = moduleExports.stateSchema
|
|
71
|
+
?? (BaseClass as any).stateSchema
|
|
72
|
+
|
|
73
|
+
const eventsSchema = moduleExports.eventsSchema
|
|
74
|
+
?? (BaseClass as any).eventsSchema
|
|
75
|
+
|
|
76
|
+
// Build the subclass
|
|
77
|
+
const GraftedClass = class extends (BaseClass as any) {} as unknown as T & { prototype: any }
|
|
78
|
+
|
|
79
|
+
// Static overrides
|
|
80
|
+
const statics: Record<string, any> = {
|
|
81
|
+
shortcut: `${scope}.${id}`,
|
|
82
|
+
description: moduleExports.description ?? '',
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (moduleExports.envVars) statics.envVars = moduleExports.envVars
|
|
86
|
+
if (optionsSchema) statics.optionsSchema = optionsSchema
|
|
87
|
+
if (stateSchema) statics.stateSchema = stateSchema
|
|
88
|
+
if (eventsSchema) statics.eventsSchema = eventsSchema
|
|
89
|
+
|
|
90
|
+
// Command-specific statics
|
|
91
|
+
if (scope === 'commands') {
|
|
92
|
+
const argsSchema = moduleExports.argsSchema ?? moduleExports.args ?? optionsSchema
|
|
93
|
+
statics.argsSchema = argsSchema
|
|
94
|
+
statics.commandDescription = moduleExports.description ?? ''
|
|
95
|
+
if (moduleExports.positionals) {
|
|
96
|
+
statics.positionals = moduleExports.positionals
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Selector-specific statics (must be set before Object.assign)
|
|
101
|
+
if (scope === 'selectors') {
|
|
102
|
+
statics.cacheable = moduleExports.cacheable !== false
|
|
103
|
+
statics.selectorDescription = moduleExports.description ?? ''
|
|
104
|
+
statics.argsSchema = moduleExports.argsSchema ?? moduleExports.args ?? optionsSchema
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
Object.assign(GraftedClass, statics)
|
|
108
|
+
|
|
109
|
+
// Wire run() for Command scope
|
|
110
|
+
if (scope === 'commands') {
|
|
111
|
+
if (typeof moduleExports.run === 'function') {
|
|
112
|
+
const runFn = moduleExports.run
|
|
113
|
+
;(GraftedClass as any).prototype.run = async function (args: any, context: any) {
|
|
114
|
+
return runFn(args, context)
|
|
115
|
+
}
|
|
116
|
+
} else if (typeof moduleExports.handler === 'function') {
|
|
117
|
+
const handlerFn = moduleExports.handler
|
|
118
|
+
;(GraftedClass as any).prototype.run = async function (args: any, context: any) {
|
|
119
|
+
return handlerFn(args, context)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Wire run() and resolveCacheKey() for Selector scope
|
|
125
|
+
if (scope === 'selectors') {
|
|
126
|
+
if (typeof moduleExports.run === 'function') {
|
|
127
|
+
const runFn = moduleExports.run
|
|
128
|
+
;(GraftedClass as any).prototype.run = async function (args: any, context: any) {
|
|
129
|
+
return runFn(args, context)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (typeof moduleExports.cacheKey === 'function') {
|
|
134
|
+
const cacheKeyFn = moduleExports.cacheKey
|
|
135
|
+
;(GraftedClass as any).prototype.resolveCacheKey = function (args: any, context: any) {
|
|
136
|
+
return cacheKeyFn(args, context)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Install getters from the `getters` export
|
|
142
|
+
const getterMap: Record<string, () => any> = moduleExports.getters ?? {}
|
|
143
|
+
for (const [key, fn] of Object.entries(getterMap)) {
|
|
144
|
+
if (typeof fn === 'function') {
|
|
145
|
+
Object.defineProperty((GraftedClass as any).prototype, key, {
|
|
146
|
+
get: fn,
|
|
147
|
+
configurable: true,
|
|
148
|
+
enumerable: false,
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Graft all exported functions (that are not reserved) as prototype methods
|
|
154
|
+
for (const [key, value] of Object.entries(moduleExports)) {
|
|
155
|
+
if (RESERVED_EXPORTS.has(key)) continue
|
|
156
|
+
if (typeof value !== 'function') continue
|
|
157
|
+
;(GraftedClass as any).prototype[key] = value
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Name the class
|
|
161
|
+
const suffix = SCOPE_SUFFIXES[scope] || ''
|
|
162
|
+
const className = pascalCase(id) + suffix
|
|
163
|
+
Object.defineProperty(GraftedClass, 'name', { value: className, configurable: true })
|
|
164
|
+
|
|
165
|
+
return GraftedClass as T
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const SCOPE_SUFFIXES: Record<string, string> = {
|
|
169
|
+
features: 'Feature',
|
|
170
|
+
clients: 'Client',
|
|
171
|
+
servers: 'Server',
|
|
172
|
+
commands: 'Command',
|
|
173
|
+
endpoints: 'Endpoint',
|
|
174
|
+
selectors: 'Selector',
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function pascalCase(id: string): string {
|
|
178
|
+
return id
|
|
179
|
+
.replace(/[-_](.)/g, (_: string, c: string) => c.toUpperCase())
|
|
180
|
+
.replace(/^(.)/, (_: string, c: string) => c.toUpperCase())
|
|
181
|
+
}
|