@soederpop/luca 0.0.6 → 0.0.7
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/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/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 +540 -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 +181 -0
- package/src/commands/chat.ts +5 -4
- package/src/commands/describe.ts +225 -2
- 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 +33 -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 +20 -0
- 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-integration/assistants-manager.test.ts +10 -20
- package/tmp/.cache/luca-disk-cache/content-v2/sha512/1b/b5/c75b28794f00f94c4d609a98978e9420e9b7146d204a7fbf5b0b30477292581705d207c0100dabaac27eef540aaaece3374af75104a93219d4ec8bfb44e7 +1 -0
- package/tmp/.cache/luca-disk-cache/content-v2/sha512/da/df/1d90ce4e042abeb035a197832c6d6893420a747a056be773eb00e4f745a037d505c8db13dde7d36b36b6b893addbb7df0f5fe9f0c13e665f20056447318b +1 -0
- package/tmp/.cache/luca-disk-cache/content-v2/sha512/ed/04/e1d0c2a58c2db29b3921ca2affb3ea4febe831c53b38ebc21019fb799823aba6ed5b4611873d2cd25d422d49955b852a9c326da0d678899bc1c2c2960901 +1 -0
- package/tmp/.cache/luca-disk-cache/index-v5/00/13/572aa4c9a94f99eda999695d050cdd0ca7fe2d23a50af03234d4c8ce0791 +2 -0
- package/tmp/.cache/luca-disk-cache/index-v5/75/a9/cb61dc0f0589e8ec10a9aca27b834bc73884c479941042d22a2b22324cd3 +2 -0
- package/tmp/.cache/luca-disk-cache/index-v5/9f/0f/8b1f915ee64cfff7667dd96acd7a5ac0a96aa91a346e19cefd45909a9c9c +2 -0
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# GraphClient (clients.graph)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
GraphQL client that wraps RestClient with convenience methods for executing queries and mutations. Automatically handles the GraphQL request envelope (query/variables/operationName) and unwraps responses, extracting the `data` field and emitting events for GraphQL-level errors.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -23,29 +23,69 @@ container.client('graph', {
|
|
|
23
23
|
| `json` | `boolean` | Whether to automatically parse responses as JSON |
|
|
24
24
|
| `endpoint` | `string` | The GraphQL endpoint path, defaults to /graphql |
|
|
25
25
|
|
|
26
|
+
## Methods
|
|
27
|
+
|
|
28
|
+
### query
|
|
29
|
+
|
|
30
|
+
Execute a GraphQL query and return the unwrapped data.
|
|
31
|
+
|
|
32
|
+
**Parameters:**
|
|
33
|
+
|
|
34
|
+
| Name | Type | Required | Description |
|
|
35
|
+
|------|------|----------|-------------|
|
|
36
|
+
| `query` | `string` | ✓ | The GraphQL query string |
|
|
37
|
+
| `variables` | `Record<string, any>` | | Optional variables for the query |
|
|
38
|
+
| `operationName` | `string` | | Optional operation name when the query contains multiple operations |
|
|
39
|
+
|
|
40
|
+
**Returns:** `Promise<R>`
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### mutate
|
|
45
|
+
|
|
46
|
+
Execute a GraphQL mutation and return the unwrapped data. Semantically identical to query() but named for clarity when performing mutations.
|
|
47
|
+
|
|
48
|
+
**Parameters:**
|
|
49
|
+
|
|
50
|
+
| Name | Type | Required | Description |
|
|
51
|
+
|------|------|----------|-------------|
|
|
52
|
+
| `mutation` | `string` | ✓ | The GraphQL mutation string |
|
|
53
|
+
| `variables` | `Record<string, any>` | | Optional variables for the mutation |
|
|
54
|
+
| `operationName` | `string` | | Optional operation name when the mutation contains multiple operations |
|
|
55
|
+
|
|
56
|
+
**Returns:** `Promise<R>`
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Getters
|
|
61
|
+
|
|
62
|
+
| Property | Type | Description |
|
|
63
|
+
|----------|------|-------------|
|
|
64
|
+
| `endpoint` | `any` | The GraphQL endpoint path. Defaults to '/graphql'. |
|
|
65
|
+
|
|
26
66
|
## Events (Zod v4 schema)
|
|
27
67
|
|
|
28
|
-
###
|
|
68
|
+
### graphqlError
|
|
29
69
|
|
|
30
|
-
Emitted when
|
|
70
|
+
Emitted when GraphQL-level errors are present in the response
|
|
31
71
|
|
|
32
72
|
**Event Arguments:**
|
|
33
73
|
|
|
34
74
|
| Name | Type | Description |
|
|
35
75
|
|------|------|-------------|
|
|
36
|
-
| `arg0` | `
|
|
76
|
+
| `arg0` | `array` | Array of GraphQL errors |
|
|
37
77
|
|
|
38
78
|
|
|
39
79
|
|
|
40
|
-
###
|
|
80
|
+
### failure
|
|
41
81
|
|
|
42
|
-
Emitted when
|
|
82
|
+
Emitted when a request fails
|
|
43
83
|
|
|
44
84
|
**Event Arguments:**
|
|
45
85
|
|
|
46
86
|
| Name | Type | Description |
|
|
47
87
|
|------|------|-------------|
|
|
48
|
-
| `arg0` | `
|
|
88
|
+
| `arg0` | `any` | The error object |
|
|
49
89
|
|
|
50
90
|
|
|
51
91
|
|
|
@@ -53,4 +93,15 @@ Emitted when GraphQL-level errors are present in the response
|
|
|
53
93
|
|
|
54
94
|
| Property | Type | Description |
|
|
55
95
|
|----------|------|-------------|
|
|
56
|
-
| `connected` | `boolean` | Whether the client is currently connected |
|
|
96
|
+
| `connected` | `boolean` | Whether the client is currently connected |
|
|
97
|
+
|
|
98
|
+
## Examples
|
|
99
|
+
|
|
100
|
+
**clients.graph**
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
const gql = container.client('graph', { baseURL: 'https://api.example.com' })
|
|
104
|
+
const data = await gql.query(`{ users { id name } }`)
|
|
105
|
+
await gql.mutate(`mutation($name: String!) { createUser(name: $name) { id } }`, { name: 'Alice' })
|
|
106
|
+
```
|
|
107
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenAIClient (clients.openai)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
OpenAI client — wraps the OpenAI SDK for chat completions, responses API, embeddings, and image generation. Provides convenience methods for common operations while tracking token usage and request counts. Supports both the Chat Completions API and the newer Responses API.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -41,8 +41,214 @@ container.client('openai', {
|
|
|
41
41
|
| `timeout` | `number` | Request timeout in milliseconds |
|
|
42
42
|
| `maxRetries` | `number` | Maximum number of retries on failure |
|
|
43
43
|
|
|
44
|
+
## Methods
|
|
45
|
+
|
|
46
|
+
### connect
|
|
47
|
+
|
|
48
|
+
Test the API connection by listing models.
|
|
49
|
+
|
|
50
|
+
**Returns:** `Promise<this>`
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
await openai.connect()
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### createChatCompletion
|
|
59
|
+
|
|
60
|
+
Create a chat completion using the Chat Completions API.
|
|
61
|
+
|
|
62
|
+
**Parameters:**
|
|
63
|
+
|
|
64
|
+
| Name | Type | Required | Description |
|
|
65
|
+
|------|------|----------|-------------|
|
|
66
|
+
| `messages` | `OpenAI.Chat.Completions.ChatCompletionMessageParam[]` | ✓ | Array of chat messages |
|
|
67
|
+
| `options` | `Partial<OpenAI.Chat.Completions.ChatCompletionCreateParams>` | | Additional parameters for the completion |
|
|
68
|
+
|
|
69
|
+
**Returns:** `Promise<OpenAI.Chat.Completions.ChatCompletion>`
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
const response = await openai.createChatCompletion([
|
|
73
|
+
{ role: 'system', content: 'You are a helpful assistant.' },
|
|
74
|
+
{ role: 'user', content: 'Hello!' }
|
|
75
|
+
])
|
|
76
|
+
console.log(response.choices[0]?.message?.content)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### createResponse
|
|
82
|
+
|
|
83
|
+
Create a response using the Responses API.
|
|
84
|
+
|
|
85
|
+
**Parameters:**
|
|
86
|
+
|
|
87
|
+
| Name | Type | Required | Description |
|
|
88
|
+
|------|------|----------|-------------|
|
|
89
|
+
| `input` | `OpenAI.Responses.ResponseInput | string` | ✓ | The input prompt or message array |
|
|
90
|
+
| `options` | `Partial<OpenAI.Responses.ResponseCreateParamsNonStreaming>` | | Additional parameters for the response |
|
|
91
|
+
|
|
92
|
+
**Returns:** `Promise<OpenAI.Responses.Response>`
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const response = await openai.createResponse('Explain quantum computing')
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
### streamResponse
|
|
101
|
+
|
|
102
|
+
Stream a response using the Responses API.
|
|
103
|
+
|
|
104
|
+
**Parameters:**
|
|
105
|
+
|
|
106
|
+
| Name | Type | Required | Description |
|
|
107
|
+
|------|------|----------|-------------|
|
|
108
|
+
| `input` | `OpenAI.Responses.ResponseInput | string` | ✓ | The input prompt or message array |
|
|
109
|
+
| `options` | `Partial<OpenAI.Responses.ResponseCreateParamsStreaming>` | | Additional parameters for the streaming response |
|
|
110
|
+
|
|
111
|
+
**Returns:** `Promise<AsyncIterable<OpenAI.Responses.ResponseStreamEvent>>`
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
const stream = await openai.streamResponse('Write a poem')
|
|
115
|
+
for await (const event of stream) {
|
|
116
|
+
if (event.type === 'response.output_text.delta') {
|
|
117
|
+
process.stdout.write(event.delta)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### createCompletion
|
|
125
|
+
|
|
126
|
+
Create a legacy text completion.
|
|
127
|
+
|
|
128
|
+
**Parameters:**
|
|
129
|
+
|
|
130
|
+
| Name | Type | Required | Description |
|
|
131
|
+
|------|------|----------|-------------|
|
|
132
|
+
| `prompt` | `string` | ✓ | The text prompt to complete |
|
|
133
|
+
| `options` | `Partial<OpenAI.Completions.CompletionCreateParams>` | | Additional parameters for the completion |
|
|
134
|
+
|
|
135
|
+
**Returns:** `Promise<OpenAI.Completions.Completion>`
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
const response = await openai.createCompletion('Once upon a time')
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
### createEmbedding
|
|
144
|
+
|
|
145
|
+
Create text embeddings for semantic search or similarity comparisons.
|
|
146
|
+
|
|
147
|
+
**Parameters:**
|
|
148
|
+
|
|
149
|
+
| Name | Type | Required | Description |
|
|
150
|
+
|------|------|----------|-------------|
|
|
151
|
+
| `input` | `string | string[]` | ✓ | A string or array of strings to embed |
|
|
152
|
+
| `options` | `Partial<OpenAI.Embeddings.EmbeddingCreateParams>` | | Additional parameters (model, etc.) |
|
|
153
|
+
|
|
154
|
+
**Returns:** `Promise<OpenAI.Embeddings.CreateEmbeddingResponse>`
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
const response = await openai.createEmbedding('Hello world')
|
|
158
|
+
console.log(response.data[0].embedding.length)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
### createImage
|
|
164
|
+
|
|
165
|
+
Generate an image from a text prompt using DALL-E.
|
|
166
|
+
|
|
167
|
+
**Parameters:**
|
|
168
|
+
|
|
169
|
+
| Name | Type | Required | Description |
|
|
170
|
+
|------|------|----------|-------------|
|
|
171
|
+
| `prompt` | `string` | ✓ | Description of the image to generate |
|
|
172
|
+
| `options` | `Partial<OpenAI.Images.ImageGenerateParams>` | | Additional parameters (size, n, etc.) |
|
|
173
|
+
|
|
174
|
+
**Returns:** `Promise<OpenAI.Images.ImagesResponse>`
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
const response = await openai.createImage('A sunset over mountains')
|
|
178
|
+
console.log(response.data[0].url)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
### listModels
|
|
184
|
+
|
|
185
|
+
List all available models.
|
|
186
|
+
|
|
187
|
+
**Returns:** `Promise<OpenAI.Models.ModelsPage>`
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
const models = await openai.listModels()
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
### ask
|
|
196
|
+
|
|
197
|
+
Ask a single question and get a text response. Convenience wrapper around `createChatCompletion` for simple Q&A.
|
|
198
|
+
|
|
199
|
+
**Parameters:**
|
|
200
|
+
|
|
201
|
+
| Name | Type | Required | Description |
|
|
202
|
+
|------|------|----------|-------------|
|
|
203
|
+
| `question` | `string` | ✓ | The question to ask |
|
|
204
|
+
| `options` | `Partial<OpenAI.Chat.Completions.ChatCompletionCreateParams>` | | Additional completion parameters |
|
|
205
|
+
|
|
206
|
+
**Returns:** `Promise<string>`
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
const answer = await openai.ask('What is 2 + 2?')
|
|
210
|
+
console.log(answer) // '4'
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
### chat
|
|
216
|
+
|
|
217
|
+
Send a multi-turn conversation and get a text response. Convenience wrapper around `createChatCompletion` that returns just the text.
|
|
218
|
+
|
|
219
|
+
**Parameters:**
|
|
220
|
+
|
|
221
|
+
| Name | Type | Required | Description |
|
|
222
|
+
|------|------|----------|-------------|
|
|
223
|
+
| `messages` | `OpenAI.Chat.Completions.ChatCompletionMessageParam[]` | ✓ | Array of chat messages |
|
|
224
|
+
| `options` | `Partial<OpenAI.Chat.Completions.ChatCompletionCreateParams>` | | Additional completion parameters |
|
|
225
|
+
|
|
226
|
+
**Returns:** `Promise<string>`
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
const reply = await openai.chat([
|
|
230
|
+
{ role: 'system', content: 'You are a pirate.' },
|
|
231
|
+
{ role: 'user', content: 'Hello!' }
|
|
232
|
+
])
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
## Getters
|
|
238
|
+
|
|
239
|
+
| Property | Type | Description |
|
|
240
|
+
|----------|------|-------------|
|
|
241
|
+
| `defaultModel` | `string` | The default model used for completions, from options or 'gpt-4o'. |
|
|
242
|
+
| `raw` | `OpenAI` | The underlying OpenAI SDK instance for advanced use cases. |
|
|
243
|
+
|
|
44
244
|
## Events (Zod v4 schema)
|
|
45
245
|
|
|
246
|
+
### connected
|
|
247
|
+
|
|
248
|
+
Emitted when the API connection is verified
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
46
252
|
### failure
|
|
47
253
|
|
|
48
254
|
Emitted when a request fails
|
|
@@ -55,6 +261,54 @@ Emitted when a request fails
|
|
|
55
261
|
|
|
56
262
|
|
|
57
263
|
|
|
264
|
+
### completion
|
|
265
|
+
|
|
266
|
+
Emitted after a chat completion, legacy completion, or response is created
|
|
267
|
+
|
|
268
|
+
**Event Arguments:**
|
|
269
|
+
|
|
270
|
+
| Name | Type | Description |
|
|
271
|
+
|------|------|-------------|
|
|
272
|
+
| `arg0` | `any` | The completion or response object |
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
### embedding
|
|
277
|
+
|
|
278
|
+
Emitted after embeddings are created
|
|
279
|
+
|
|
280
|
+
**Event Arguments:**
|
|
281
|
+
|
|
282
|
+
| Name | Type | Description |
|
|
283
|
+
|------|------|-------------|
|
|
284
|
+
| `arg0` | `any` | The embedding response object |
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
### image
|
|
289
|
+
|
|
290
|
+
Emitted after an image is generated
|
|
291
|
+
|
|
292
|
+
**Event Arguments:**
|
|
293
|
+
|
|
294
|
+
| Name | Type | Description |
|
|
295
|
+
|------|------|-------------|
|
|
296
|
+
| `arg0` | `any` | The image generation response object |
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
### models
|
|
301
|
+
|
|
302
|
+
Emitted after listing available models
|
|
303
|
+
|
|
304
|
+
**Event Arguments:**
|
|
305
|
+
|
|
306
|
+
| Name | Type | Description |
|
|
307
|
+
|------|------|-------------|
|
|
308
|
+
| `arg0` | `any` | The models list response |
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
58
312
|
## State (Zod v4 schema)
|
|
59
313
|
|
|
60
314
|
| Property | Type | Description |
|
|
@@ -66,4 +320,110 @@ Emitted when a request fails
|
|
|
66
320
|
|
|
67
321
|
## Environment Variables
|
|
68
322
|
|
|
69
|
-
- `OPENAI_API_KEY`
|
|
323
|
+
- `OPENAI_API_KEY`
|
|
324
|
+
|
|
325
|
+
## Examples
|
|
326
|
+
|
|
327
|
+
**clients.openai**
|
|
328
|
+
|
|
329
|
+
```ts
|
|
330
|
+
const openai = container.client('openai', { defaultModel: 'gpt-4o' })
|
|
331
|
+
const answer = await openai.ask('What is the meaning of life?')
|
|
332
|
+
console.log(answer)
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
**connect**
|
|
338
|
+
|
|
339
|
+
```ts
|
|
340
|
+
await openai.connect()
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
**createChatCompletion**
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
const response = await openai.createChatCompletion([
|
|
349
|
+
{ role: 'system', content: 'You are a helpful assistant.' },
|
|
350
|
+
{ role: 'user', content: 'Hello!' }
|
|
351
|
+
])
|
|
352
|
+
console.log(response.choices[0]?.message?.content)
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
**createResponse**
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
const response = await openai.createResponse('Explain quantum computing')
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
**streamResponse**
|
|
366
|
+
|
|
367
|
+
```ts
|
|
368
|
+
const stream = await openai.streamResponse('Write a poem')
|
|
369
|
+
for await (const event of stream) {
|
|
370
|
+
if (event.type === 'response.output_text.delta') {
|
|
371
|
+
process.stdout.write(event.delta)
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
**createCompletion**
|
|
379
|
+
|
|
380
|
+
```ts
|
|
381
|
+
const response = await openai.createCompletion('Once upon a time')
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
**createEmbedding**
|
|
387
|
+
|
|
388
|
+
```ts
|
|
389
|
+
const response = await openai.createEmbedding('Hello world')
|
|
390
|
+
console.log(response.data[0].embedding.length)
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
**createImage**
|
|
396
|
+
|
|
397
|
+
```ts
|
|
398
|
+
const response = await openai.createImage('A sunset over mountains')
|
|
399
|
+
console.log(response.data[0].url)
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
**listModels**
|
|
405
|
+
|
|
406
|
+
```ts
|
|
407
|
+
const models = await openai.listModels()
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
**ask**
|
|
413
|
+
|
|
414
|
+
```ts
|
|
415
|
+
const answer = await openai.ask('What is 2 + 2?')
|
|
416
|
+
console.log(answer) // '4'
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
**chat**
|
|
422
|
+
|
|
423
|
+
```ts
|
|
424
|
+
const reply = await openai.chat([
|
|
425
|
+
{ role: 'system', content: 'You are a pirate.' },
|
|
426
|
+
{ role: 'user', content: 'Hello!' }
|
|
427
|
+
])
|
|
428
|
+
```
|
|
429
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# RestClient (clients.rest)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
HTTP REST client built on top of axios. Provides convenience methods for GET, POST, PUT, PATCH, and DELETE requests with automatic JSON handling, configurable base URL, and error event emission.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -20,6 +20,115 @@ container.client('rest', {
|
|
|
20
20
|
| `baseURL` | `string` | Base URL for the client connection |
|
|
21
21
|
| `json` | `boolean` | Whether to automatically parse responses as JSON |
|
|
22
22
|
|
|
23
|
+
## Methods
|
|
24
|
+
|
|
25
|
+
### beforeRequest
|
|
26
|
+
|
|
27
|
+
**Returns:** `void`
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### patch
|
|
32
|
+
|
|
33
|
+
Send a PATCH request.
|
|
34
|
+
|
|
35
|
+
**Parameters:**
|
|
36
|
+
|
|
37
|
+
| Name | Type | Required | Description |
|
|
38
|
+
|------|------|----------|-------------|
|
|
39
|
+
| `url` | `string` | ✓ | Request path relative to baseURL |
|
|
40
|
+
| `data` | `any` | | Request body |
|
|
41
|
+
| `options` | `AxiosRequestConfig` | | Additional axios request config |
|
|
42
|
+
|
|
43
|
+
**Returns:** `void`
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### put
|
|
48
|
+
|
|
49
|
+
Send a PUT request.
|
|
50
|
+
|
|
51
|
+
**Parameters:**
|
|
52
|
+
|
|
53
|
+
| Name | Type | Required | Description |
|
|
54
|
+
|------|------|----------|-------------|
|
|
55
|
+
| `url` | `string` | ✓ | Request path relative to baseURL |
|
|
56
|
+
| `data` | `any` | | Request body |
|
|
57
|
+
| `options` | `AxiosRequestConfig` | | Additional axios request config |
|
|
58
|
+
|
|
59
|
+
**Returns:** `void`
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### post
|
|
64
|
+
|
|
65
|
+
Send a POST request.
|
|
66
|
+
|
|
67
|
+
**Parameters:**
|
|
68
|
+
|
|
69
|
+
| Name | Type | Required | Description |
|
|
70
|
+
|------|------|----------|-------------|
|
|
71
|
+
| `url` | `string` | ✓ | Request path relative to baseURL |
|
|
72
|
+
| `data` | `any` | | Request body |
|
|
73
|
+
| `options` | `AxiosRequestConfig` | | Additional axios request config |
|
|
74
|
+
|
|
75
|
+
**Returns:** `void`
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### delete
|
|
80
|
+
|
|
81
|
+
Send a DELETE request.
|
|
82
|
+
|
|
83
|
+
**Parameters:**
|
|
84
|
+
|
|
85
|
+
| Name | Type | Required | Description |
|
|
86
|
+
|------|------|----------|-------------|
|
|
87
|
+
| `url` | `string` | ✓ | Request path relative to baseURL |
|
|
88
|
+
| `params` | `any` | | Query parameters |
|
|
89
|
+
| `options` | `AxiosRequestConfig` | | Additional axios request config |
|
|
90
|
+
|
|
91
|
+
**Returns:** `void`
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
### get
|
|
96
|
+
|
|
97
|
+
Send a GET request.
|
|
98
|
+
|
|
99
|
+
**Parameters:**
|
|
100
|
+
|
|
101
|
+
| Name | Type | Required | Description |
|
|
102
|
+
|------|------|----------|-------------|
|
|
103
|
+
| `url` | `string` | ✓ | Request path relative to baseURL |
|
|
104
|
+
| `params` | `any` | | Query parameters |
|
|
105
|
+
| `options` | `AxiosRequestConfig` | | Additional axios request config |
|
|
106
|
+
|
|
107
|
+
**Returns:** `void`
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
### handleError
|
|
112
|
+
|
|
113
|
+
Handle an axios error by emitting 'failure' and returning the error as JSON.
|
|
114
|
+
|
|
115
|
+
**Parameters:**
|
|
116
|
+
|
|
117
|
+
| Name | Type | Required | Description |
|
|
118
|
+
|------|------|----------|-------------|
|
|
119
|
+
| `error` | `AxiosError` | ✓ | Parameter error |
|
|
120
|
+
|
|
121
|
+
**Returns:** `void`
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
## Getters
|
|
126
|
+
|
|
127
|
+
| Property | Type | Description |
|
|
128
|
+
|----------|------|-------------|
|
|
129
|
+
| `useJSON` | `any` | Whether JSON content-type headers should be set automatically. |
|
|
130
|
+
| `baseURL` | `any` | |
|
|
131
|
+
|
|
23
132
|
## Events (Zod v4 schema)
|
|
24
133
|
|
|
25
134
|
### failure
|
|
@@ -38,4 +147,15 @@ Emitted when a request fails
|
|
|
38
147
|
|
|
39
148
|
| Property | Type | Description |
|
|
40
149
|
|----------|------|-------------|
|
|
41
|
-
| `connected` | `boolean` | Whether the client is currently connected |
|
|
150
|
+
| `connected` | `boolean` | Whether the client is currently connected |
|
|
151
|
+
|
|
152
|
+
## Examples
|
|
153
|
+
|
|
154
|
+
**clients.rest**
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
const api = container.client('rest', { baseURL: 'https://api.example.com', json: true })
|
|
158
|
+
const users = await api.get('/users')
|
|
159
|
+
await api.post('/users', { name: 'Alice' })
|
|
160
|
+
```
|
|
161
|
+
|