@weiliang0121/capix-transcript 0.1.0 → 0.3.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 +3 -1
- package/dist/append.d.ts +1 -1
- package/dist/event.d.ts +37 -2
- package/dist/event.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/persistence.d.ts +1 -1
- package/dist/presets.d.ts +1 -1
- package/dist/progress.d.ts +1 -1
- package/dist/ref.d.ts +2 -2
- package/dist/resource.d.ts +2 -2
- package/dist/resource.js +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/types.d.ts +22 -0
- package/dist/types.js +1 -0
- package/dist/view.d.ts +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Append-only conversation messages and resource contracts for CAPiX.
|
|
4
4
|
|
|
5
|
+
The public root owns `Message`, `MessageLocator`, `TranscriptRangeLocator`, `TranscriptSnapshot`, and `TranscriptEvent`. Locators identify fixed positions without retaining an entity; snapshots and events describe one source revision, including segment changes. Transport framing and wire acceptance belong to the protocol adapter and are not entity recovery authority.
|
|
6
|
+
|
|
5
7
|
ES modules and TypeScript declarations. Requires Node.js 22.23.2 or newer.
|
|
6
8
|
|
|
7
9
|
```sh
|
|
@@ -17,4 +19,4 @@ This package is part of CAPiX. The npm distribution contains compiled JavaScript
|
|
|
17
19
|
|
|
18
20
|
## License
|
|
19
21
|
|
|
20
|
-
MIT. Copyright (c) 2026 wei.liang. See [LICENSE](
|
|
22
|
+
MIT. Copyright (c) 2026 wei.liang. See [LICENSE](LICENSE).
|
package/dist/append.d.ts
CHANGED
package/dist/event.d.ts
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { FactType } from '@weiliang0121/capix-changes';
|
|
2
|
+
import type { InvocationOrigin } from '@weiliang0121/capix-contracts';
|
|
3
|
+
import type { Message } from './types.js';
|
|
4
|
+
export type TranscriptEvent = Readonly<{
|
|
5
|
+
type: 'transcript';
|
|
6
|
+
transcriptId: string;
|
|
7
|
+
revision: number;
|
|
8
|
+
occurredAt: string;
|
|
9
|
+
origin?: InvocationOrigin;
|
|
10
|
+
change: Readonly<{
|
|
11
|
+
kind: 'messages-appended';
|
|
12
|
+
start: number;
|
|
13
|
+
messages: readonly Readonly<Message>[];
|
|
14
|
+
}> | Readonly<{
|
|
15
|
+
kind: 'segment-started';
|
|
16
|
+
previousStart: number;
|
|
17
|
+
start: number;
|
|
18
|
+
end: number;
|
|
19
|
+
}>;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const TranscriptFacts: FactType<Readonly<{
|
|
22
|
+
type: "transcript";
|
|
23
|
+
transcriptId: string;
|
|
24
|
+
revision: number;
|
|
25
|
+
occurredAt: string;
|
|
26
|
+
origin?: InvocationOrigin;
|
|
27
|
+
change: Readonly<{
|
|
28
|
+
kind: "messages-appended";
|
|
29
|
+
start: number;
|
|
30
|
+
messages: readonly Readonly<Message>[];
|
|
31
|
+
}> | Readonly<{
|
|
32
|
+
kind: "segment-started";
|
|
33
|
+
previousStart: number;
|
|
34
|
+
start: number;
|
|
35
|
+
end: number;
|
|
36
|
+
}>;
|
|
37
|
+
}>>;
|
|
3
38
|
export declare function createTranscriptEvent(transcriptId: string, revision: number, change: TranscriptEvent['change'], origin?: {
|
|
4
39
|
readonly contextId: string;
|
|
5
40
|
}): TranscriptEvent;
|
package/dist/event.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! MIT License | Copyright (c) 2026 wei.liang | See LICENSE */
|
|
2
|
-
var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});function createTranscriptEvent(transcriptId,revision,change,origin){const body=change.kind==="messages-appended"?Object.freeze({...change,messages:Object.freeze([...change.messages])}):Object.freeze({...change});return Object.freeze({type:"transcript",transcriptId,revision,occurredAt:new Date().toISOString(),...origin?{origin:Object.freeze({...origin})}:{},change:body})}__name(createTranscriptEvent,"createTranscriptEvent");export{createTranscriptEvent};
|
|
2
|
+
var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});import{FactType}from"@weiliang0121/capix-changes";const TranscriptFacts=new FactType("transcript");function createTranscriptEvent(transcriptId,revision,change,origin){const body=change.kind==="messages-appended"?Object.freeze({...change,messages:Object.freeze([...change.messages])}):Object.freeze({...change});return Object.freeze({type:"transcript",transcriptId,revision,occurredAt:new Date().toISOString(),...origin?{origin:Object.freeze({...origin})}:{},change:body})}__name(createTranscriptEvent,"createTranscriptEvent");export{TranscriptFacts,createTranscriptEvent};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { MessageRef, TranscriptRangeRef } from './ref.js';
|
|
|
3
3
|
export type { TranscriptAppendOperation, TranscriptFixedAppend, TranscriptAppendReceipt, TranscriptAppendState } from './append.js';
|
|
4
4
|
export type { TranscriptState, TranscriptCommit, TranscriptPersistence } from './persistence.js';
|
|
5
5
|
export type { TranscriptAppendProgress } from './progress.js';
|
|
6
|
-
export type
|
|
6
|
+
export { TranscriptFacts, type TranscriptEvent } from './event.js';
|
|
7
7
|
export { TranscriptResource, TranscriptRangeReader, type TranscriptAppendSource } from './resource.js';
|
|
8
8
|
export { TranscriptViewSource, type TranscriptViewSummary } from './view.js';
|
|
9
|
+
export type { Message, MessageLocator, TranscriptRangeLocator, TranscriptSnapshot } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! MIT License | Copyright (c) 2026 wei.liang | See LICENSE */
|
|
2
|
-
import{Transcript}from"./transcript.js";import{MessageRef,TranscriptRangeRef}from"./ref.js";import{TranscriptResource,TranscriptRangeReader}from"./resource.js";import{TranscriptViewSource}from"./view.js";export{MessageRef,Transcript,TranscriptRangeReader,TranscriptRangeRef,TranscriptResource,TranscriptViewSource};
|
|
2
|
+
import{Transcript}from"./transcript.js";import{MessageRef,TranscriptRangeRef}from"./ref.js";import{TranscriptFacts}from"./event.js";import{TranscriptResource,TranscriptRangeReader}from"./resource.js";import{TranscriptViewSource}from"./view.js";export{MessageRef,Transcript,TranscriptFacts,TranscriptRangeReader,TranscriptRangeRef,TranscriptResource,TranscriptViewSource};
|
package/dist/persistence.d.ts
CHANGED
package/dist/presets.d.ts
CHANGED
package/dist/progress.d.ts
CHANGED
package/dist/ref.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare class MessageRef {
|
|
|
3
3
|
readonly transcript: Transcript;
|
|
4
4
|
readonly index: number;
|
|
5
5
|
constructor(transcript: Transcript, index: number);
|
|
6
|
-
read(): Readonly<import("
|
|
6
|
+
read(): Readonly<import("./types.js").Message>;
|
|
7
7
|
}
|
|
8
8
|
export declare class TranscriptRangeRef {
|
|
9
9
|
readonly transcript: Transcript;
|
|
@@ -12,6 +12,6 @@ export declare class TranscriptRangeRef {
|
|
|
12
12
|
constructor(transcript: Transcript, start: number, end: number);
|
|
13
13
|
get length(): number;
|
|
14
14
|
ref(index: number): MessageRef;
|
|
15
|
-
read(index: number): Readonly<import("
|
|
15
|
+
read(index: number): Readonly<import("./types.js").Message>;
|
|
16
16
|
refs(): readonly MessageRef[];
|
|
17
17
|
}
|
package/dist/resource.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transcript } from './transcript.js';
|
|
2
|
-
import type { Message, TranscriptRangeLocator } from '
|
|
2
|
+
import type { Message, TranscriptRangeLocator } from './types.js';
|
|
3
3
|
import { ResourceOffer } from '@weiliang0121/capix-resources';
|
|
4
4
|
import type { ResourceEndpointActivity } from '@weiliang0121/capix-resources';
|
|
5
5
|
import { TranscriptRangeRef } from './ref.js';
|
|
@@ -30,7 +30,7 @@ export declare const TranscriptResource: Readonly<{
|
|
|
30
30
|
applyFixed(input: {
|
|
31
31
|
readonly position: string;
|
|
32
32
|
readonly messages: readonly Message[];
|
|
33
|
-
}):
|
|
33
|
+
}): unknown;
|
|
34
34
|
append(messages: readonly Message[]): readonly Readonly<{
|
|
35
35
|
transcriptId: string;
|
|
36
36
|
index: number;
|
package/dist/resource.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! MIT License | Copyright (c) 2026 wei.liang | See LICENSE */
|
|
2
|
-
var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});import{Transcript}from"./transcript.js";import{ResourceOffer}from"@weiliang0121/capix-resources";import{TranscriptRangeRef}from"./ref.js";import{ProgressChannel}from"@weiliang0121/capix-changes";class TranscriptRangeReader{static{__name(this,"TranscriptRangeReader")}#range;#activity;start;end;transcriptId;revision;constructor(range,activity,revision=range.transcript.revision){this.#range=range,this.#activity=activity,this.start=range.start,this.end=range.end,this.transcriptId=range.transcript.id,this.revision=revision,Object.freeze(this)}get length(){return this.end-this.start}locate(){return Object.freeze({transcriptId:this.transcriptId,start:this.start,end:this.end,revision:this.revision})}read(index){const read=__name(()=>this.#range.read(index),"read");return this.#activity?this.#activity.runSync("read",{input:__name(()=>({transcriptId:this.transcriptId,index}),"input"),output:__name(()=>({transcriptId:this.transcriptId,index}),"output")},read):read()}slice(start,end=this.end){if(this.#activity?.validate(),start<this.start||end>this.end)throw new RangeError("Requested range exceeds available messages");return new TranscriptRangeReader(new TranscriptRangeRef(this.#range.transcript,start,end),this.#activity,this.revision)}entries(){const read=__name(()=>Object.freeze(Array.from({length:this.length},(_,offset)=>{const index=this.start+offset;return Object.freeze({index,message:this.#range.read(index)})})),"read");return this.#activity?this.#activity.runSync("entries",{input:__name(()=>this.locate(),"input"),output:__name(()=>this.locate(),"output")},read):read()}}const TranscriptResource=Object.freeze({append:new ResourceOffer({name:"transcript.append",expose:__name((source,activity)=>{const transcript=source instanceof Transcript?source:source.transcript,progress=source instanceof Transcript||!source.progress?void 0:new ProgressChannel(source.progress);return Object.freeze({applyFixed(input){return activity.runSync("applyFixed",{input:__name(()=>({position:input.position,count:input.messages.length}),"input"),output:__name(receipt=>receipt,"output")},
|
|
2
|
+
var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});import{TranscriptFacts}from"./event.js";import{Transcript}from"./transcript.js";import{ResourceOffer}from"@weiliang0121/capix-resources";import{TranscriptRangeRef}from"./ref.js";import{ProgressChannel}from"@weiliang0121/capix-changes";class TranscriptRangeReader{static{__name(this,"TranscriptRangeReader")}#range;#activity;start;end;transcriptId;revision;constructor(range,activity,revision=range.transcript.revision){this.#range=range,this.#activity=activity,this.start=range.start,this.end=range.end,this.transcriptId=range.transcript.id,this.revision=revision,Object.freeze(this)}get length(){return this.end-this.start}locate(){return Object.freeze({transcriptId:this.transcriptId,start:this.start,end:this.end,revision:this.revision})}read(index){const read=__name(()=>this.#range.read(index),"read");return this.#activity?this.#activity.runSync("read",{input:__name(()=>({transcriptId:this.transcriptId,index}),"input"),output:__name(()=>({transcriptId:this.transcriptId,index}),"output")},read):read()}slice(start,end=this.end){if(this.#activity?.validate(),start<this.start||end>this.end)throw new RangeError("Requested range exceeds available messages");return new TranscriptRangeReader(new TranscriptRangeRef(this.#range.transcript,start,end),this.#activity,this.revision)}entries(){const read=__name(()=>Object.freeze(Array.from({length:this.length},(_,offset)=>{const index=this.start+offset;return Object.freeze({index,message:this.#range.read(index)})})),"read");return this.#activity?this.#activity.runSync("entries",{input:__name(()=>this.locate(),"input"),output:__name(()=>this.locate(),"output")},read):read()}}const TranscriptResource=Object.freeze({append:new ResourceOffer({name:"transcript.append",expose:__name((source,activity)=>{const transcript=source instanceof Transcript?source:source.transcript,progress=source instanceof Transcript||!source.progress?void 0:new ProgressChannel(source.progress);return Object.freeze({applyFixed(input){return activity.runSync("applyFixed",{input:__name(()=>({position:input.position,count:input.messages.length}),"input"),output:__name(receipt=>receipt,"output")},operation=>transcript.applyFixed({contract:{key:"transcript.append",version:1},operation:{...activity.reception(),position:input.position},transcriptId:transcript.id,messages:input.messages},{origin:operation.origin,observation:operation.facts(TranscriptFacts),progress}))},append(messages){return activity.runSync("append",{input:__name(()=>({count:messages.length}),"input"),output:__name(result=>({transcriptId:transcript.id,indexes:result.map(item=>item.index),revision:transcript.revision}),"output")},operation=>{const start=transcript.length;return transcript.appendFrom(messages,{origin:operation.origin,observation:operation.facts(TranscriptFacts),progress}),Object.freeze(messages.map((_,offset)=>Object.freeze({transcriptId:transcript.id,index:start+offset,message:transcript.get(start+offset)})))})}})},"expose"),timing:"access",describe:__name(source=>({transcriptId:(source instanceof Transcript?source:source.transcript).id}),"describe")}),segmentation:new ResourceOffer({name:"transcript.segmentation",expose:__name((transcript,activity)=>Object.freeze({current:__name(()=>activity.runSync("current",{output:__name(reader=>reader.locate(),"output")},()=>new TranscriptRangeReader(new TranscriptRangeRef(transcript,transcript.activeStart,transcript.length),activity)),"current"),start:__name(index=>activity.runSync("start",{input:__name(()=>({start:index}),"input"),output:__name(()=>({transcriptId:transcript.id,start:transcript.activeStart,end:transcript.length,revision:transcript.revision}),"output")},operation=>transcript.startSegment(index,{origin:operation.origin,observation:operation.facts(TranscriptFacts)})),"start")}),"expose"),timing:"access",describe:__name(transcript=>({transcriptId:transcript.id}),"describe")}),fixedRange:new ResourceOffer({name:"transcript.fixedRange",expose:__name((captured,activity)=>new TranscriptRangeReader(captured.range,activity,captured.revision),"expose"),timing:"binding",capture:__name(range=>({range,revision:range.transcript.revision}),"capture"),describe:__name(({range,revision})=>({transcriptId:range.transcript.id,start:range.start,end:range.end,revision}),"describe")})});export{TranscriptRangeReader,TranscriptResource};
|
package/dist/transcript.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ChangeProvenance } from '@weiliang0121/capix-changes';
|
|
2
2
|
import type { EventConsumer } from '@weiliang0121/capix-changes';
|
|
3
3
|
import { MessageRef, TranscriptRangeRef } from './ref.js';
|
|
4
|
-
import type { Message } from '
|
|
4
|
+
import type { Message } from './types.js';
|
|
5
5
|
import type { ChangeCapture } from '@weiliang0121/capix-changes';
|
|
6
6
|
import { type TranscriptEvent } from './event.js';
|
|
7
7
|
import type { ProgressChannel } from '@weiliang0121/capix-changes';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Message {
|
|
2
|
+
role: 'user' | 'assistant';
|
|
3
|
+
content: string;
|
|
4
|
+
}
|
|
5
|
+
export interface MessageLocator {
|
|
6
|
+
readonly transcriptId: string;
|
|
7
|
+
readonly index: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TranscriptRangeLocator {
|
|
10
|
+
readonly transcriptId: string;
|
|
11
|
+
readonly start: number;
|
|
12
|
+
readonly end: number;
|
|
13
|
+
readonly revision?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface TranscriptSnapshot {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly revision: number;
|
|
18
|
+
readonly start: 0;
|
|
19
|
+
readonly end: number;
|
|
20
|
+
readonly starts: readonly number[];
|
|
21
|
+
readonly messages: readonly Readonly<Message>[];
|
|
22
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! MIT License | Copyright (c) 2026 wei.liang | See LICENSE */
|
package/dist/view.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weiliang0121/capix-transcript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -15,12 +15,11 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"es-toolkit": "1.52.0",
|
|
18
|
-
"@weiliang0121/capix-contracts": "0.
|
|
19
|
-
"@weiliang0121/capix-
|
|
20
|
-
"@weiliang0121/capix-
|
|
21
|
-
"@weiliang0121/capix-resources": "0.
|
|
22
|
-
"@weiliang0121/capix-view": "0.
|
|
23
|
-
"@weiliang0121/capix-diagnostics": "0.1.0"
|
|
18
|
+
"@weiliang0121/capix-contracts": "0.3.0",
|
|
19
|
+
"@weiliang0121/capix-diagnostics": "0.3.0",
|
|
20
|
+
"@weiliang0121/capix-changes": "0.3.0",
|
|
21
|
+
"@weiliang0121/capix-resources": "0.3.0",
|
|
22
|
+
"@weiliang0121/capix-view": "0.3.0"
|
|
24
23
|
},
|
|
25
24
|
"description": "Append-only conversation messages and resource contracts for CAPiX.",
|
|
26
25
|
"license": "MIT",
|
|
@@ -28,7 +27,7 @@
|
|
|
28
27
|
"repository": {
|
|
29
28
|
"type": "git",
|
|
30
29
|
"url": "git+https://github.com/weiliang0121/capix.git",
|
|
31
|
-
"directory": "
|
|
30
|
+
"directory": "packages/transcript"
|
|
32
31
|
},
|
|
33
32
|
"engines": {
|
|
34
33
|
"node": ">=22.23.2"
|
|
@@ -47,6 +46,7 @@
|
|
|
47
46
|
},
|
|
48
47
|
"scripts": {
|
|
49
48
|
"build": "tsc -p tsconfig.json",
|
|
50
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
49
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
50
|
+
"test": "node ../../scripts/test/run.mjs --package ."
|
|
51
51
|
}
|
|
52
52
|
}
|