@plurnk/plurnk-service 0.3.0 → 0.4.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/SPEC.md +35 -26
- package/dist/core/ChannelWrite.d.ts +10 -0
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js.map +1 -1
- package/dist/core/Engine.d.ts +9 -1
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +260 -53
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/line-marker.d.ts +23 -0
- package/dist/core/line-marker.d.ts.map +1 -0
- package/dist/core/line-marker.js +321 -0
- package/dist/core/line-marker.js.map +1 -0
- package/dist/core/matcher.d.ts +14 -0
- package/dist/core/matcher.d.ts.map +1 -0
- package/dist/core/matcher.js +195 -0
- package/dist/core/matcher.js.map +1 -0
- package/dist/core/mimetype-binary.d.ts +6 -0
- package/dist/core/mimetype-binary.d.ts.map +1 -0
- package/dist/core/mimetype-binary.js +82 -0
- package/dist/core/mimetype-binary.js.map +1 -0
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +97 -21
- package/dist/core/packet-wire.js.map +1 -1
- package/dist/core/path-mimetype.d.ts +3 -0
- package/dist/core/path-mimetype.d.ts.map +1 -0
- package/dist/core/path-mimetype.js +47 -0
- package/dist/core/path-mimetype.js.map +1 -0
- package/dist/core/scheme-types.d.ts +5 -0
- package/dist/core/scheme-types.d.ts.map +1 -1
- package/dist/core/scheme-types.js.map +1 -1
- package/dist/schemes/Exec.d.ts +30 -1
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +229 -6
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/File.d.ts +4 -0
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +107 -23
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts +2 -0
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +82 -13
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/Plurnk.js +3 -3
- package/dist/schemes/Plurnk.js.map +1 -1
- package/dist/schemes/_entry-crud.d.ts +2 -0
- package/dist/schemes/_entry-crud.d.ts.map +1 -1
- package/dist/schemes/_entry-crud.js +1 -0
- package/dist/schemes/_entry-crud.js.map +1 -1
- package/dist/schemes/_entry-find.d.ts.map +1 -1
- package/dist/schemes/_entry-find.js +64 -15
- package/dist/schemes/_entry-find.js.map +1 -1
- package/dist/schemes/_entry-ops.d.ts +3 -0
- package/dist/schemes/_entry-ops.d.ts.map +1 -1
- package/dist/schemes/_entry-ops.js +268 -55
- package/dist/schemes/_entry-ops.js.map +1 -1
- package/dist/schemes/_entry-send.d.ts.map +1 -1
- package/dist/schemes/_entry-send.js +14 -7
- package/dist/schemes/_entry-send.js.map +1 -1
- package/dist/server/ClientConnection.d.ts +3 -2
- package/dist/server/ClientConnection.d.ts.map +1 -1
- package/dist/server/ClientConnection.js +4 -1
- package/dist/server/ClientConnection.js.map +1 -1
- package/dist/server/Daemon.d.ts +40 -1
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +319 -1
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/MethodRegistry.d.ts +29 -0
- package/dist/server/MethodRegistry.d.ts.map +1 -1
- package/dist/server/MethodRegistry.js.map +1 -1
- package/dist/server/dsl.d.ts +2 -2
- package/dist/server/dsl.d.ts.map +1 -1
- package/dist/server/dsl.js +10 -10
- package/dist/server/dsl.js.map +1 -1
- package/dist/server/methods/entry_read.js +5 -5
- package/dist/server/methods/entry_read.js.map +1 -1
- package/dist/server/methods/loop_cancel.d.ts +3 -0
- package/dist/server/methods/loop_cancel.d.ts.map +1 -0
- package/dist/server/methods/loop_cancel.js +27 -0
- package/dist/server/methods/loop_cancel.js.map +1 -0
- package/dist/server/methods/loop_run.d.ts.map +1 -1
- package/dist/server/methods/loop_run.js +46 -47
- package/dist/server/methods/loop_run.js.map +1 -1
- package/dist/server/methods/op_edit.js +3 -3
- package/dist/server/methods/op_edit.js.map +1 -1
- package/dist/server/methods/op_hide.js +3 -3
- package/dist/server/methods/op_hide.js.map +1 -1
- package/dist/server/methods/op_read.js +3 -3
- package/dist/server/methods/op_read.js.map +1 -1
- package/dist/server/methods/op_show.js +3 -3
- package/dist/server/methods/op_show.js.map +1 -1
- package/migrations/001_schema.sql +1 -1
- package/package.json +5 -4
package/SPEC.md
CHANGED
|
@@ -84,7 +84,7 @@ Three independent axes on entries and channels. Confusion across them is a recur
|
|
|
84
84
|
| Tier | Location | LLM | Substrate |
|
|
85
85
|
|---|---|---|---|
|
|
86
86
|
| **unit** | `src/**/*.test.ts` | No | Isolated logic, mocked boundaries |
|
|
87
|
-
| **intg** | `test/intg/` | No (mock provider) | Real
|
|
87
|
+
| **intg** | `test/intg/` | No (mock provider) | Real file-backed SqlRite (per-test DB under `test/intg/.tmp/`), real engine |
|
|
88
88
|
| **live** | `test/live/` | Real | Wire-level assertions |
|
|
89
89
|
| **demo** | `test/demo/` | Real | Holistic outcome assertions |
|
|
90
90
|
|
|
@@ -400,7 +400,7 @@ Implications for operations:
|
|
|
400
400
|
- **SHOW / HIDE** flip visibility for the resolved channel only — channel-specific visibility is achievable via fragments. Fragment-less SHOW/HIDE flips ALL channels of the entry per §5.2 (existing behavior).
|
|
401
401
|
- **COPY / MOVE** with a fragment is a per-channel operation; deferred design pass needed before specifying (out of scope for v0).
|
|
402
402
|
|
|
403
|
-
The clean-shape RPC params (§13.5) carry the fragment naturally inside the `
|
|
403
|
+
The clean-shape RPC params (§13.5) carry the fragment naturally inside the `target` string: `{ target: "known://x#stderr" }` works as expected. No new RPC parameter needed; the URL surface handles it.
|
|
404
404
|
|
|
405
405
|
**Wire-rendering inverse: default channel is path-only.** When the engine projects entries to the model's view, the heredoc fence omits `#channel` whenever the channel name matches the scheme's `defaultChannel`. Single-channel entries (the channel IS the default) render path-only; multi-channel entries render the default channel path-only and only non-default channels carry `#name` in the fence. {§5.5-wire-omits-suffix-on-default-channel} Examples:
|
|
406
406
|
|
|
@@ -432,7 +432,7 @@ Per-op semantics for `FIND | READ | EDIT | COPY | MOVE | SHOW | HIDE | SEND | EX
|
|
|
432
432
|
|
|
433
433
|
### §6.1 EDIT
|
|
434
434
|
|
|
435
|
-
AST: `{ op: "EDIT",
|
|
435
|
+
AST: `{ op: "EDIT", target: ParsedPath, body: string | null, signal: tags | null, lineMarker?: LineMarker }`.
|
|
436
436
|
|
|
437
437
|
Engine dispatches to `scheme.edit(statement, ctx)`. Scheme:
|
|
438
438
|
- Resolves the target channel from the path's fragment (§5.5). Fragment absent → scheme's `manifest.defaultChannel`. Unknown channel → 400. Channel manifest-undeclared → engine crashes per §5.3.
|
|
@@ -444,7 +444,7 @@ Engine dispatches to `scheme.edit(statement, ctx)`. Scheme:
|
|
|
444
444
|
|
|
445
445
|
### §6.2 READ
|
|
446
446
|
|
|
447
|
-
AST: `{ op: "READ",
|
|
447
|
+
AST: `{ op: "READ", target: ParsedPath, body: MatcherBody | null, signal: tags | null, lineMarker?: LineMarker }`.
|
|
448
448
|
|
|
449
449
|
Engine dispatches to `scheme.read(statement, ctx)`. Scheme:
|
|
450
450
|
- Returns the body channel content + mimetype for `path`, or `{ status: 404 }`.
|
|
@@ -453,7 +453,7 @@ Engine dispatches to `scheme.read(statement, ctx)`. Scheme:
|
|
|
453
453
|
|
|
454
454
|
### §6.3 SHOW / HIDE
|
|
455
455
|
|
|
456
|
-
AST: `{ op: "SHOW"|"HIDE",
|
|
456
|
+
AST: `{ op: "SHOW"|"HIDE", target: ParsedPath, body: MatcherBody | null, signal: tags | null, lineMarker?: LineMarker }`.
|
|
457
457
|
|
|
458
458
|
Engine dispatches to `scheme.show(statement, ctx)` / `scheme.hide(statement, ctx)`. Scheme:
|
|
459
459
|
- Flips `visibility.indexed` for every channel of the targeted entry to 1 (SHOW) or 0 (HIDE).
|
|
@@ -462,7 +462,7 @@ Engine dispatches to `scheme.show(statement, ctx)` / `scheme.hide(statement, ctx
|
|
|
462
462
|
|
|
463
463
|
### §6.4 COPY (engine-orchestrated)
|
|
464
464
|
|
|
465
|
-
AST: `{ op: "COPY",
|
|
465
|
+
AST: `{ op: "COPY", target: ParsedPath (source), body: ParsedPath (destination), signal: tags | null, lineMarker?: LineMarker }`.
|
|
466
466
|
|
|
467
467
|
Engine orchestrates over CRUD primitives (§3.2, §3.4):
|
|
468
468
|
|
|
@@ -479,7 +479,7 @@ Same- and cross-scheme COPY both go through this orchestrator. {§6.4-cross-sche
|
|
|
479
479
|
|
|
480
480
|
### §6.5 MOVE (engine-orchestrated)
|
|
481
481
|
|
|
482
|
-
AST: `{ op: "MOVE",
|
|
482
|
+
AST: `{ op: "MOVE", target: ParsedPath (source), body: ParsedPath | null (destination), signal: tags | null, lineMarker?: LineMarker }`.
|
|
483
483
|
|
|
484
484
|
Two modes:
|
|
485
485
|
|
|
@@ -491,7 +491,7 @@ Log history is preserved through MOVE because `log_entries`' URI-bit columns (`s
|
|
|
491
491
|
|
|
492
492
|
### §6.6 FIND
|
|
493
493
|
|
|
494
|
-
AST: `{ op: "FIND",
|
|
494
|
+
AST: `{ op: "FIND", target: ParsedPath (scope), body: MatcherBody | null (predicate), signal: tags | null (tag filter), lineMarker?: LineMarker }`.
|
|
495
495
|
|
|
496
496
|
Engine dispatches to `scheme.find(statement, ctx)`. Scheme:
|
|
497
497
|
- Filters entries within the path's scope (scheme + pathname prefix). {§6.6-scope-prefix-filter}
|
|
@@ -502,7 +502,7 @@ Engine dispatches to `scheme.find(statement, ctx)`. Scheme:
|
|
|
502
502
|
|
|
503
503
|
### §6.7 SEND
|
|
504
504
|
|
|
505
|
-
AST: `{ op: "SEND",
|
|
505
|
+
AST: `{ op: "SEND", target: ParsedPath | null, body: SendBody | null, signal: number | null }`.
|
|
506
506
|
|
|
507
507
|
Two modes:
|
|
508
508
|
|
|
@@ -516,7 +516,7 @@ Two modes:
|
|
|
516
516
|
|
|
517
517
|
### §6.8 EXEC
|
|
518
518
|
|
|
519
|
-
AST: `{ op: "EXEC",
|
|
519
|
+
AST: `{ op: "EXEC", target: ParsedPath (cwd), body: string | null (command), signal: string | null (runtime tag) }`.
|
|
520
520
|
|
|
521
521
|
Deferred. The `exec` scheme is in §10's bundled set but lacks a working handler; calls return 501. Sandboxing design and process-lifecycle semantics are the substance to figure out, drawing on rummy's exec plugin as prior art.
|
|
522
522
|
|
|
@@ -644,7 +644,7 @@ All real providers are siblings, registered via plugin discovery.
|
|
|
644
644
|
|
|
645
645
|
**Schemes in-tree (`src/schemes/`):**
|
|
646
646
|
- `plurnk` — indexable scheme for internal model-interactions. Current use: `plurnk://prompt/<loop_id>` carries each loop's prompt as a body-channel entry written on loop start. Manifest-level writability is open (any origin); model-origin writes to `plurnk://prompt/*` are rejected in-handler (engine + client own those paths).
|
|
647
|
-
- `log` — coordinate-addressed log entries. Read returns a summary of the action at `log://<loop_seq>/<turn_seq>/<sequence>`; SHOW/HIDE toggle the row's `indexed` flag (log entries are not entries-table entries, but participate in the model's curation surface via URI dispatch).
|
|
647
|
+
- `log` — coordinate-addressed log entries. Read returns a summary of the action at `log://<loop_seq>/<turn_seq>/<sequence>`; SHOW/HIDE toggle the row's `indexed` flag (log entries are not entries-table entries, but participate in the model's curation surface via URI dispatch). Each entry renders in the packet as a single JSON meta line — no fence, no body — with `path` = the log entry's own URI (`log://<L>/<T>/<S>/<op>`) and `target` = the URI the action acted on. Errors mirror to `packet.user.telemetry.errors[]` per §15.1; status ≥ 400 in the meta signals "look in telemetry."
|
|
648
648
|
- `known` — primary narrative entries.
|
|
649
649
|
- `unknown` — decomposition / open questions.
|
|
650
650
|
- `skill` — sibling of known/unknown; semantics provisional.
|
|
@@ -830,7 +830,7 @@ If a client issues a method requiring init (`requiresInit: true`) without first
|
|
|
830
830
|
|
|
831
831
|
| Method | Params | Result | Notes |
|
|
832
832
|
|---------------|-------------------------------------|------------------------|-------|
|
|
833
|
-
| `entry.read` | `
|
|
833
|
+
| `entry.read` | `target: string` | `{ status, entry }` | Read the full entry shape (channels + tags + metadata) at the given URI. |
|
|
834
834
|
| `log.read` | `loopId?: number`, … | `{ entries: LogEntry[] }` | Read recent log entries from the attached session, optionally filtered by loop. |
|
|
835
835
|
|
|
836
836
|
**DSL operations (client-driven, mirror the grammar)**
|
|
@@ -839,15 +839,17 @@ Per the **Speak in DSL, not plumbing** rule (AGENTS.md Standing Rules): RPC meth
|
|
|
839
839
|
|
|
840
840
|
Each `op.*` call creates a turn in the connection's client loop (§13.7) with the constructed statement as a single action, dispatches it, fires a `log/entry` notification to attached clients of the session, returns the dispatch result.
|
|
841
841
|
|
|
842
|
+
Naming follows the uniform principle: `target` is the URI the op acts on (the operand); `scope` for FIND (the search root); `source`/`destination` for COPY/MOVE; `recipient` for SEND (or null = broadcast); `cwd` for EXEC. `path` is never an RPC operand here — that word is reserved for *identity* throughout plurnk (the URI of *this thing*).
|
|
843
|
+
|
|
842
844
|
| Method | Params | Notes |
|
|
843
845
|
|---------------|---------------------------------------------------------|-------|
|
|
844
846
|
| `op.find` | `scope: string`, `matcher?: string`, `tags?: string[]`, `lineRange?: LineMarker` | Mirrors `<<FIND>>`. |
|
|
845
|
-
| `op.read` | `
|
|
846
|
-
| `op.edit` | `
|
|
847
|
+
| `op.read` | `target: string`, `matcher?: string`, `lineRange?: LineMarker`, `tags?: string[]` | Mirrors `<<READ>>`. |
|
|
848
|
+
| `op.edit` | `target: string`, `content?: string`, `tags?: string[]`, `lineRange?: LineMarker` | Mirrors `<<EDIT>>`. |
|
|
847
849
|
| `op.copy` | `source: string`, `destination: string`, `tags?: string[]`, `lineRange?: LineMarker` | Mirrors `<<COPY>>`. |
|
|
848
850
|
| `op.move` | `source: string`, `destination?: string`, `tags?: string[]`, `lineRange?: LineMarker` | Mirrors `<<MOVE>>`. Missing `destination` = delete (null-body MOVE). |
|
|
849
|
-
| `op.show` | `
|
|
850
|
-
| `op.hide` | `
|
|
851
|
+
| `op.show` | `target: string`, `matcher?: string`, `tags?: string[]`, `lineRange?: LineMarker` | Mirrors `<<SHOW>>`. |
|
|
852
|
+
| `op.hide` | `target: string`, `matcher?: string`, `tags?: string[]`, `lineRange?: LineMarker` | Mirrors `<<HIDE>>`. |
|
|
851
853
|
| `op.send` | `status: number`, `recipient?: string`, `body?: string` | Mirrors `<<SEND>>`. |
|
|
852
854
|
| `op.exec` | `cwd?: string`, `runtime?: string`, `command?: string` | Mirrors `<<EXEC>>`. |
|
|
853
855
|
| `op.dispatch` | `statement: PlurnkStatement` | Low-level path for clients that have a parsed AST already (e.g. the TUI when the user types raw HEREDOC at the prompt). |
|
|
@@ -858,7 +860,7 @@ All `op.*` methods return `{ status: number, ...op-specific-extras }`. They are
|
|
|
858
860
|
Future-reserved (post-v0):
|
|
859
861
|
|
|
860
862
|
- `subscription.list` — list active streaming subscriptions (§7).
|
|
861
|
-
- `subscription.cancel` — analog of `SEND[499]` over RPC, though `op.send({status: 499, recipient
|
|
863
|
+
- `subscription.cancel` — analog of `SEND[499]` over RPC, though `op.send({status: 499, recipient})` does the same thing today.
|
|
862
864
|
|
|
863
865
|
### §13.6 Notifications
|
|
864
866
|
|
|
@@ -872,7 +874,7 @@ Server-initiated events streamed to the client over the same WebSocket. Critical
|
|
|
872
874
|
| `session/created` | `{ id, name, projectRoot, persona }` | When a session is created (any client's action; gives multi-client awareness). |
|
|
873
875
|
| `stream/event` | `{ entryId, channel, state, contentLength }` | When a channel's content grows or its state transitions. For clients rendering live; the model only sees state at turn boundaries. {§13.6-stream-event-on-channel-change} |
|
|
874
876
|
|
|
875
|
-
The `stream/event` payload deliberately carries metadata, NOT content. Clients that want the new content call `entry.read({
|
|
877
|
+
The `stream/event` payload deliberately carries metadata, NOT content. Clients that want the new content call `entry.read({target})` to fetch — this avoids large notification payloads and gives the client agency over whether to refresh. Sample-driven (notifications include `contentLength` so clients can dedupe / batch).
|
|
876
878
|
|
|
877
879
|
Notifications are scoped to the connection's attached session — a client attached to session A does NOT receive `log/entry` notifications for actions on session B. (Cross-session observation is a future feature; v0 keeps the scope tight.)
|
|
878
880
|
|
|
@@ -997,7 +999,7 @@ type Packet = {
|
|
|
997
999
|
};
|
|
998
1000
|
```
|
|
999
1001
|
|
|
1000
|
-
**Prompt as a first-class entry.** Each loop's prompt is written on loop start as a system-origin `EDIT` against `plurnk://prompt/<loop_id>` (indexable entry, body channel, text/markdown). The corresponding log row
|
|
1002
|
+
**Prompt as a first-class entry.** Each loop's prompt is written on loop start as a system-origin `EDIT` against `plurnk://prompt/<loop_id>` (indexable entry, body channel, text/markdown). The corresponding log row renders as `* {"op":"EDIT","origin":"system","path":"log://<L>/1/1/EDIT","status":201,"target":"plurnk://prompt/<L>"}` — `path` is the log row's own URI, `target` is the plurnk entry that got written. At render time, the *current* loop's `plurnk://prompt/<loop_id>` entry is foisted out of `packet.system.index` and materialized in `packet.user.prompt` — one section, one mechanism, no duplicate content rendering. Previous loops' prompt entries remain in the index and are addressable for the model to READ or HIDE. {§15-current-prompt-foist}
|
|
1001
1003
|
|
|
1002
1004
|
### §15.1 user.telemetry — model-facing runtime telemetry
|
|
1003
1005
|
|
|
@@ -1011,12 +1013,19 @@ The slot for telemetry the model MUST react to right now: budget pressure and la
|
|
|
1011
1013
|
**Plurnk-service rendering (v0):**
|
|
1012
1014
|
|
|
1013
1015
|
- `budget` is rendered as a short markdown line. Unit follows §14.2 (character count); the exact rendering is engine-internal and may evolve without a schema change.
|
|
1014
|
-
- `errors[]` carries
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1016
|
+
- `errors[]` carries telemetry from the previous turn's dispatch + rail evaluation. Each element has a required `kind` discriminator and a required `message` string (human-readable, model-actionable). Additional kind-specific fields are flat on the element — there is NO nested `detail` envelope; canonical-JSON serialization sorts keys for prefix-cache friendliness.
|
|
1017
|
+
- Wire format: one `* {canonical-JSON}` line per error under `# Plurnk System Errors`, in push order. Buffer drains on read — each error appears in exactly one packet. {§15.1-drain-on-read}
|
|
1018
|
+
|
|
1019
|
+
**Kinds emitted by plurnk-service v0:**
|
|
1020
|
+
|
|
1021
|
+
| `kind` | Source | Required fields | Additional fields |
|
|
1022
|
+
|---|---|---|---|
|
|
1023
|
+
| `action_failure` | Log entry with `status_rx ≥ 400` from previous turn | `kind`, `message`, `coordinate` (`<L>/<T>/<S>`), `op`, `status` | `target` (URI or null) |
|
|
1024
|
+
| `no_ops` | Rail #41 — turn ended with zero ops | `kind`, `message` | — |
|
|
1025
|
+
| `strike` | Rail #38 — strike streak bumped (no_ops / recorded_failure / rail) | `kind`, `message`, `streak`, `maxStrikes`, `reason` | — |
|
|
1026
|
+
| `cycle` | Rail #39 — repeating turn fingerprint pattern detected | `kind`, `message`, `period`, `cycles` | — |
|
|
1027
|
+
| `sudden_death` | Rail #40 — entering the last `maxStrikes`-sized window before `maxTurns` | `kind`, `message`, `remaining` | — |
|
|
1028
|
+
|
|
1029
|
+
Action-bound failures (handler returned 4xx/5xx or threw) are mirrored as the `action_failure` kind on the next packet — same forced-confrontation pattern. Full detail stays queryable via `log://`. {§15.1-no-error-scheme}
|
|
1021
1030
|
|
|
1022
1031
|
**No `error://` scheme.** Actionless failures route to telemetry, not to a queryable scheme namespace.
|
|
@@ -7,6 +7,16 @@ export interface StreamEventPayload {
|
|
|
7
7
|
contentLength: number;
|
|
8
8
|
}
|
|
9
9
|
export type StreamEventNotify = (sessionId: number, event: StreamEventPayload) => void;
|
|
10
|
+
export interface WakeRunPayload {
|
|
11
|
+
sessionId: number;
|
|
12
|
+
runId: number;
|
|
13
|
+
entryId: number;
|
|
14
|
+
subscriptionId: number;
|
|
15
|
+
closeStatus: number;
|
|
16
|
+
scheme: string;
|
|
17
|
+
summary: string;
|
|
18
|
+
}
|
|
19
|
+
export type WakeRunNotify = (payload: WakeRunPayload) => void;
|
|
10
20
|
export declare const appendToChannel: (db: Db, { entryId, channel, chunk, notify }: {
|
|
11
21
|
entryId: number;
|
|
12
22
|
channel: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChannelWrite.d.ts","sourceRoot":"","sources":["../../src/core/ChannelWrite.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEtE,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,YAAY,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ChannelWrite.d.ts","sourceRoot":"","sources":["../../src/core/ChannelWrite.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEtE,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,YAAY,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;AAQvF,MAAM,WAAW,cAAc;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACnB;A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sourceRoot":"","sources":["../../src/core/ChannelWrite.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mEAAmE;AACnE,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,2EAA2E;AAC3E,gCAAgC;
|
|
1
|
+
{"version":3,"file":"ChannelWrite.js","sourceRoot":"","sources":["../../src/core/ChannelWrite.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mEAAmE;AACnE,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,2EAA2E;AAC3E,gCAAgC;AAuChC,MAAM,WAAW,GAAG,CAAC,EAAM,EAAE,EAAE,CAAC,EAAE,CAAC,YAA0B,CAAC;AAC9D,MAAM,UAAU,GAAG,CAAC,EAAM,EAAE,EAAE,CAAC,EAAE,CAAC,iBAA+B,CAAC;AAClE,MAAM,SAAS,GAAG,CAAC,EAAM,EAAE,EAAE,CAAC,EAAE,CAAC,iBAA+B,CAAC;AACjE,MAAM,WAAW,GAAG,CAAC,EAAM,EAAE,EAAE,CAAC,EAAE,CAAC,iBAA+B,CAAC;AACnE,MAAM,YAAY,GAAG,CAAC,EAAM,EAAE,EAAE,CAAC,EAAE,CAAC,kBAAgC,CAAC;AACrE,MAAM,cAAc,GAAG,CAAC,EAAM,EAAE,EAAE,CAAC,EAAE,CAAC,wBAAsC,CAAC;AAE7E,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAChC,EAAM,EACN,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAmF,EACvG,EAAE;IACf,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/E,IAAI,MAAM,CAAC,OAAO,KAAK,CAAC;QAAE,OAAO;IACjC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO;IACjC,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC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AE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5G,IAAI,GAAG,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IACjG,OAAO,GAAG,CAAC,EAAE,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAClC,EAAM,EACN,EAAE,cAAc,EAAE,MAAM,EAA8C,EACzD,EAAE;IACf,MAAM,YAAY,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC,CAAC;AAC5E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EACvC,EAAM,EACN,EAAE,KAAK,EAAE,OAAO,EAAsC,EACQ,EAAE;IAChE,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC,GAAG,CAAiD,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/H,OAAO,GAAG,IAAI,IAAI,CAAC;AACvB,CAAC,CAAC"}
|
package/dist/core/Engine.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type SchemeRegistry from "./SchemeRegistry.ts";
|
|
|
3
3
|
import { Mimetypes } from "@plurnk/plurnk-mimetypes";
|
|
4
4
|
import type { Db } from "./Db.ts";
|
|
5
5
|
import type { LoopFlags } from "./scheme-types.ts";
|
|
6
|
+
import type { StreamEventNotify, WakeRunNotify } from "./ChannelWrite.ts";
|
|
6
7
|
type Origin = "model" | "client" | "system" | "plugin";
|
|
7
8
|
type ChatMessage = {
|
|
8
9
|
role: "system" | "user" | "assistant";
|
|
@@ -55,10 +56,12 @@ export declare const detectCycle: (history: ReadonlyArray<string>, minCycles: nu
|
|
|
55
56
|
};
|
|
56
57
|
export default class Engine {
|
|
57
58
|
#private;
|
|
58
|
-
constructor({ db, schemes, mimetypes }: {
|
|
59
|
+
constructor({ db, schemes, mimetypes, streamEventNotify, wakeRunNotify }: {
|
|
59
60
|
db: Db;
|
|
60
61
|
schemes: SchemeRegistry;
|
|
61
62
|
mimetypes?: Mimetypes;
|
|
63
|
+
streamEventNotify?: StreamEventNotify;
|
|
64
|
+
wakeRunNotify?: WakeRunNotify;
|
|
62
65
|
});
|
|
63
66
|
runLoop({ provider, messages, persona, sessionId, runId, loopId, maxTurns, maxStrikes, minCycles, maxCyclePeriod, origin, signal, onDispatch, }: {
|
|
64
67
|
provider: Provider;
|
|
@@ -101,6 +104,11 @@ export default class Engine {
|
|
|
101
104
|
dispatch(context: DispatchContext): Promise<DispatchResult>;
|
|
102
105
|
resolveProposal(logEntryId: number, resolution: ProposalResolution): void;
|
|
103
106
|
pendingProposalIds(): number[];
|
|
107
|
+
hasActiveLoopForRun(runId: number): Promise<boolean>;
|
|
108
|
+
inject(runId: number, prompt: string): Promise<{
|
|
109
|
+
loopId: number;
|
|
110
|
+
turnSeq: number;
|
|
111
|
+
} | null>;
|
|
104
112
|
onProposalPending(listener: (event: ProposalPendingEvent) => void): void;
|
|
105
113
|
}
|
|
106
114
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Engine.d.ts","sourceRoot":"","sources":["../../src/core/Engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAA4D,MAAM,wBAAwB,CAAC;AACxH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAiB,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Engine.d.ts","sourceRoot":"","sources":["../../src/core/Engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAA4D,MAAM,wBAAwB,CAAC;AACxH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAA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