@codenotch/process 0.0.0-dev → 0.1.5
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 +51 -51
- package/dist/types/lib/connectors.d.ts +28 -1
- package/package.json +43 -43
package/README.md
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
# @codenotch/process
|
|
2
|
-
|
|
3
|
-
The standard library and type surface of Codenotch script processes.
|
|
4
|
-
|
|
5
|
-
Script processes execute **on the server only**: the engine embeds this package's
|
|
6
|
-
compiled runtime and serves it to `require('@codenotch/process')` inside the V8 workflow
|
|
7
|
-
sandbox. What the package distributes to process authors is the **type declarations**
|
|
8
|
-
(`dist/types`) — there is no client-side execution, and the runtime never ships in a
|
|
9
|
-
process bundle (the deploy bundler treats the package as external).
|
|
10
|
-
|
|
11
|
-
## Layout
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
src/lib the public library: process()/triggers, ctx (Context), errors,
|
|
15
|
-
Instant, Duration, Decimal, encodings, url, canonicalJson, is, hash.
|
|
16
|
-
Pure TypeScript; talks to the engine only through the EngineBindings
|
|
17
|
-
seam (bindings.ts). dist/types is emitted from here.
|
|
18
|
-
src/runtime the wire-protocol layer: sandbox hardening, the command channel over
|
|
19
|
-
the __host adapter, and the engine entry points (__start, __deliver,
|
|
20
|
-
__cancelDeliver, __deliverChildEvent, __processMetadataJson,
|
|
21
|
-
__concurrencyKey). Engine-internal — never part of the public types.
|
|
22
|
-
src/activity the '@codenotch/process/activity' entry: activity() and the activity-side
|
|
23
|
-
types. Ships as runtime JS (dist/activity.mjs) — the deploy bundler
|
|
24
|
-
inlines it into each activity bundle (activities run on Node).
|
|
25
|
-
src/testing the '@codenotch/process/testing' entry: the process-test facade
|
|
26
|
-
(test/expect/env — see doc/reference/process-tests.md). Its bundle
|
|
27
|
-
(dist/test-prelude.js) is the engine's V8 test-host prelude; the entry
|
|
28
|
-
distributes types only, like the root.
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Build
|
|
32
|
-
|
|
33
|
-
`node build.mjs` — type-checks, emits `dist/types` and bundles the three runtimes:
|
|
34
|
-
`src/runtime/prelude.ts` → `dist/prelude.js` (IIFE), `src/activity/index.ts` →
|
|
35
|
-
`dist/activity.mjs`, `src/testing/main.ts` → `dist/test-prelude.js` (IIFE). Output files
|
|
36
|
-
are rewritten only when content changed. The `Echino.Services.Framework.Processes`
|
|
37
|
-
csproj runs this automatically when sources changed and embeds `dist/prelude.js`
|
|
38
|
-
(`ScriptEngine.WorkflowPrelude.js`) and `dist/test-prelude.js`
|
|
39
|
-
(`ScriptEngine.TestPrelude.js`), so the engine and the types can never drift.
|
|
40
|
-
|
|
41
|
-
`dist/` is committed: a .NET-only checkout builds without running npm as long as the
|
|
42
|
-
TypeScript sources are untouched.
|
|
43
|
-
|
|
44
|
-
## Rules (doc/reference/process-stdlib.md holds the user-facing docs)
|
|
45
|
-
|
|
46
|
-
- Every `ctx` method and library function is documented (JSDoc here, reference doc there)
|
|
47
|
-
and covered by an example-grade fixture in
|
|
48
|
-
`test/Echino.Services.Framework.Processes.Test/testSchemas/StdlibTests`.
|
|
49
|
-
- Strong typing first, dynamic as fallback (`ctx.call(handle)` over `ctx.call<In, Out>('name')`).
|
|
50
|
-
- The library layer stays pure: anything touching the world goes through the bindings
|
|
51
|
-
seam and is journaled by the engine.
|
|
1
|
+
# @codenotch/process
|
|
2
|
+
|
|
3
|
+
The standard library and type surface of Codenotch script processes.
|
|
4
|
+
|
|
5
|
+
Script processes execute **on the server only**: the engine embeds this package's
|
|
6
|
+
compiled runtime and serves it to `require('@codenotch/process')` inside the V8 workflow
|
|
7
|
+
sandbox. What the package distributes to process authors is the **type declarations**
|
|
8
|
+
(`dist/types`) — there is no client-side execution, and the runtime never ships in a
|
|
9
|
+
process bundle (the deploy bundler treats the package as external).
|
|
10
|
+
|
|
11
|
+
## Layout
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
src/lib the public library: process()/triggers, ctx (Context), errors,
|
|
15
|
+
Instant, Duration, Decimal, encodings, url, canonicalJson, is, hash.
|
|
16
|
+
Pure TypeScript; talks to the engine only through the EngineBindings
|
|
17
|
+
seam (bindings.ts). dist/types is emitted from here.
|
|
18
|
+
src/runtime the wire-protocol layer: sandbox hardening, the command channel over
|
|
19
|
+
the __host adapter, and the engine entry points (__start, __deliver,
|
|
20
|
+
__cancelDeliver, __deliverChildEvent, __processMetadataJson,
|
|
21
|
+
__concurrencyKey). Engine-internal — never part of the public types.
|
|
22
|
+
src/activity the '@codenotch/process/activity' entry: activity() and the activity-side
|
|
23
|
+
types. Ships as runtime JS (dist/activity.mjs) — the deploy bundler
|
|
24
|
+
inlines it into each activity bundle (activities run on Node).
|
|
25
|
+
src/testing the '@codenotch/process/testing' entry: the process-test facade
|
|
26
|
+
(test/expect/env — see doc/reference/process-tests.md). Its bundle
|
|
27
|
+
(dist/test-prelude.js) is the engine's V8 test-host prelude; the entry
|
|
28
|
+
distributes types only, like the root.
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Build
|
|
32
|
+
|
|
33
|
+
`node build.mjs` — type-checks, emits `dist/types` and bundles the three runtimes:
|
|
34
|
+
`src/runtime/prelude.ts` → `dist/prelude.js` (IIFE), `src/activity/index.ts` →
|
|
35
|
+
`dist/activity.mjs`, `src/testing/main.ts` → `dist/test-prelude.js` (IIFE). Output files
|
|
36
|
+
are rewritten only when content changed. The `Echino.Services.Framework.Processes`
|
|
37
|
+
csproj runs this automatically when sources changed and embeds `dist/prelude.js`
|
|
38
|
+
(`ScriptEngine.WorkflowPrelude.js`) and `dist/test-prelude.js`
|
|
39
|
+
(`ScriptEngine.TestPrelude.js`), so the engine and the types can never drift.
|
|
40
|
+
|
|
41
|
+
`dist/` is committed: a .NET-only checkout builds without running npm as long as the
|
|
42
|
+
TypeScript sources are untouched.
|
|
43
|
+
|
|
44
|
+
## Rules (doc/reference/process-stdlib.md holds the user-facing docs)
|
|
45
|
+
|
|
46
|
+
- Every `ctx` method and library function is documented (JSDoc here, reference doc there)
|
|
47
|
+
and covered by an example-grade fixture in
|
|
48
|
+
`test/Echino.Services.Framework.Processes.Test/testSchemas/StdlibTests`.
|
|
49
|
+
- Strong typing first, dynamic as fallback (`ctx.call(handle)` over `ctx.call<In, Out>('name')`).
|
|
50
|
+
- The library layer stays pure: anything touching the world goes through the bindings
|
|
51
|
+
seam and is journaled by the engine.
|
|
@@ -234,9 +234,31 @@ export interface PaymentHandle {
|
|
|
234
234
|
*/
|
|
235
235
|
chargeSavedMethod(request: ChargeRequest, opts?: ActivityOptions): Promise<ChargeResult>;
|
|
236
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* A file the model reads: by reference ({ renderingId } — a ctx.render.pdf result works
|
|
239
|
+
* as-is), the server resolves the bytes at call time and they never travel through the
|
|
240
|
+
* process; inline bytes ride the journal base64-encoded — keep them small, big documents
|
|
241
|
+
* belong in renderings. Accepted media types: image/* and application/pdf, each gated on
|
|
242
|
+
* the bound provider's input capabilities.
|
|
243
|
+
*/
|
|
244
|
+
export type LlmFile = {
|
|
245
|
+
renderingId: string;
|
|
246
|
+
} | {
|
|
247
|
+
mediaType: string;
|
|
248
|
+
bytes: Uint8Array;
|
|
249
|
+
fileName?: string;
|
|
250
|
+
};
|
|
251
|
+
/** One piece of a message: text, or a file the model reads alongside it. */
|
|
252
|
+
export type LlmContentPart = {
|
|
253
|
+
type: 'text';
|
|
254
|
+
text: string;
|
|
255
|
+
} | ({
|
|
256
|
+
type: 'file';
|
|
257
|
+
} & LlmFile);
|
|
237
258
|
export interface LlmMessage {
|
|
238
259
|
role: 'user' | 'assistant';
|
|
239
|
-
|
|
260
|
+
/** Plain text, or an ordered part array. File parts belong in user messages. */
|
|
261
|
+
content: string | LlmContentPart[];
|
|
240
262
|
}
|
|
241
263
|
export interface LlmUsage {
|
|
242
264
|
inputTokens: number;
|
|
@@ -246,6 +268,11 @@ export type LlmStopReason = 'end' | 'maxTokens' | 'refusal';
|
|
|
246
268
|
export interface LlmRequest {
|
|
247
269
|
/** One user message — the simple form. Exactly one of prompt and messages. */
|
|
248
270
|
prompt?: string;
|
|
271
|
+
/**
|
|
272
|
+
* Files the model reads with the prompt (they precede it) — prompt-form only; the
|
|
273
|
+
* messages form places files as content parts.
|
|
274
|
+
*/
|
|
275
|
+
files?: LlmFile[];
|
|
249
276
|
/** The full conversation, for multi-turn flows the process assembles itself. */
|
|
250
277
|
messages?: LlmMessage[];
|
|
251
278
|
system?: string;
|
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@codenotch/process",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Types and standard library for Codenotch script processes. Processes execute on the server only: the engine embeds the compiled runtime (dist/prelude.js); this package distributes the type declarations.",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/EchinoHub/service-core.git",
|
|
8
|
-
"directory": "src/codenotch-process"
|
|
9
|
-
},
|
|
10
|
-
"publishConfig": {
|
|
11
|
-
"access": "public"
|
|
12
|
-
},
|
|
13
|
-
"types": "./dist/types/lib/index.d.ts",
|
|
14
|
-
"exports": {
|
|
15
|
-
".": {
|
|
16
|
-
"types": "./dist/types/lib/index.d.ts"
|
|
17
|
-
},
|
|
18
|
-
"./activity": {
|
|
19
|
-
"types": "./dist/types/activity/index.d.ts",
|
|
20
|
-
"default": "./dist/activity.mjs"
|
|
21
|
-
},
|
|
22
|
-
"./template": {
|
|
23
|
-
"types": "./dist/types/template/index.d.ts",
|
|
24
|
-
"default": "./dist/template.mjs"
|
|
25
|
-
},
|
|
26
|
-
"./testing": {
|
|
27
|
-
"types": "./dist/types/testing/index.d.ts"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"files": [
|
|
31
|
-
"dist/types",
|
|
32
|
-
"dist/activity.mjs",
|
|
33
|
-
"dist/template.mjs"
|
|
34
|
-
],
|
|
35
|
-
"scripts": {
|
|
36
|
-
"build": "node build.mjs",
|
|
37
|
-
"check": "tsc -p tsconfig.json --noEmit"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"esbuild": "^0.25.9",
|
|
41
|
-
"typescript": "^5.9.2"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@codenotch/process",
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "Types and standard library for Codenotch script processes. Processes execute on the server only: the engine embeds the compiled runtime (dist/prelude.js); this package distributes the type declarations.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/EchinoHub/service-core.git",
|
|
8
|
+
"directory": "src/codenotch-process"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"types": "./dist/types/lib/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/types/lib/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./activity": {
|
|
19
|
+
"types": "./dist/types/activity/index.d.ts",
|
|
20
|
+
"default": "./dist/activity.mjs"
|
|
21
|
+
},
|
|
22
|
+
"./template": {
|
|
23
|
+
"types": "./dist/types/template/index.d.ts",
|
|
24
|
+
"default": "./dist/template.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./testing": {
|
|
27
|
+
"types": "./dist/types/testing/index.d.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist/types",
|
|
32
|
+
"dist/activity.mjs",
|
|
33
|
+
"dist/template.mjs"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "node build.mjs",
|
|
37
|
+
"check": "tsc -p tsconfig.json --noEmit"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"esbuild": "^0.25.9",
|
|
41
|
+
"typescript": "^5.9.2"
|
|
42
|
+
}
|
|
43
|
+
}
|