@weiliang0121/capix-protocol 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wei.liang (https://github.com/weiliang0121)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # @weiliang0121/capix-protocol
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Explicit Transcript baseline, delta and error wire values, with single-frame admission. The only public entry point is the package root.
4
+
5
+ ```sh
6
+ npm install @weiliang0121/capix-protocol
7
+ ```
8
+
9
+ ```ts
10
+ import { acceptTranscriptUpdate, type TranscriptUpdate } from '@weiliang0121/capix-protocol';
11
+
12
+ const update: TranscriptUpdate = acceptTranscriptUpdate(JSON.parse(payload));
13
+ if (update.type === 'baseline') console.log(update.snapshot.messages);
14
+ ```
15
+
16
+ `acceptTranscriptUpdate` validates one complete value, rejects unknown fields and invalid message/range/segment/revision shapes, and returns fixed data. This does not establish delivery continuity, replace a consumer's source, authorize recovery or implement HTTP. Those responsibilities belong to the consuming application.
17
+
18
+ Public types: `TranscriptWireMessage`, `TranscriptWireSnapshot`, `TranscriptWireEvent`, `TranscriptFrame`, `TranscriptUpdate`. These are explicit transport representations; entity APIs belong to `capix-transcript`. Invocation events belong to `capix-invocation/events`, record data and validation to `capix-records/data`, and shared relation identity to `capix-contracts`.
19
+
20
+ Application DTOs and endpoint admission belong to each host application. This package does not reexport entity implementations or business protocols.
21
+
22
+ ES modules and TypeScript declarations. The npm distribution contains compiled JavaScript, declarations, this README and the MIT license; no HTTP, Node-specific implementation or UI dependency is introduced by this entry point.
23
+
24
+ ## License
25
+
26
+ MIT. Copyright (c) 2026 wei.liang. See [LICENSE](LICENSE).
@@ -0,0 +1,3 @@
1
+ import { type Stable } from '@weiliang0121/capix-contracts';
2
+ import type { TranscriptUpdate } from './transcript.js';
3
+ export declare function acceptTranscriptUpdate(value: unknown): Stable<TranscriptUpdate>;
@@ -0,0 +1,2 @@
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{stableValue}from"@weiliang0121/capix-contracts";function acceptTranscriptUpdate(value){const fixed=stableValue(value),update=record(fixed);if(update.type==="baseline"){keys(update,["type","snapshot"]);const snapshot=record(update.snapshot);keys(snapshot,["id","revision","start","end","starts","messages"]),text(snapshot.id),integer(snapshot.revision),integer(snapshot.end),snapshot.start!==0&&fail(),messages(snapshot.messages),(snapshot.messages.length!==snapshot.end||!Array.isArray(snapshot.starts)||snapshot.starts.length===0||snapshot.starts[0]!==0)&&fail();let previous=-1;for(const start of snapshot.starts)integer(start),(start<=previous||previous>=0&&start>=snapshot.end)&&fail(),previous=start;const minimumRevision=snapshot.messages.length?snapshot.starts.length:0,maximumRevision=snapshot.messages.length+snapshot.starts.length-1;(snapshot.revision<minimumRevision||snapshot.revision>maximumRevision)&&fail()}else if(update.type==="delta"){keys(update,["type","event"]);const event=record(update.event);if(keys(event,["type","transcriptId","revision","occurredAt","change"],["origin"]),event.type!=="transcript"&&fail(),text(event.transcriptId),integer(event.revision,1),text(event.occurredAt),Number.isFinite(Date.parse(event.occurredAt))||fail(),Object.hasOwn(event,"origin")){const origin=record(event.origin);keys(origin,["contextId"]),text(origin.contextId)}const change=record(event.change);change.kind==="messages-appended"?(keys(change,["kind","start","messages"]),integer(change.start),messages(change.messages),(change.messages.length===0||!Number.isSafeInteger(change.start+change.messages.length))&&fail()):change.kind==="segment-started"?(keys(change,["kind","previousStart","start","end"]),integer(change.previousStart),integer(change.start),integer(change.end),(change.previousStart>=change.start||change.start>=change.end)&&fail()):fail()}else update.type==="error"?(keys(update,["type","code","error"]),text(update.code),text(update.error)):fail();return fixed}__name(acceptTranscriptUpdate,"acceptTranscriptUpdate");function fail(){throw new TypeError("Invalid transcript update")}__name(fail,"fail");function record(value){return(value===null||typeof value!="object"||Array.isArray(value))&&fail(),value}__name(record,"record");function keys(value,required,optional=[]){(!required.every(key=>Object.hasOwn(value,key))||Object.keys(value).some(key=>!required.includes(key)&&!optional.includes(key)))&&fail()}__name(keys,"keys");function text(value){(typeof value!="string"||!/\S/u.test(value))&&fail()}__name(text,"text");function integer(value,minimum=0){(!Number.isSafeInteger(value)||value<minimum||Object.is(value,-0))&&fail()}__name(integer,"integer");function messages(value){Array.isArray(value)||fail();for(const raw of value){const message=record(raw);keys(message,["role","content"]),message.role!=="user"&&message.role!=="assistant"&&fail(),text(message.content)}}__name(messages,"messages");export{acceptTranscriptUpdate};
@@ -0,0 +1,2 @@
1
+ export type { TranscriptWireMessage, TranscriptWireSnapshot, TranscriptWireEvent, TranscriptFrame, TranscriptUpdate } from './transcript.js';
2
+ export { acceptTranscriptUpdate } from './acceptance.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! MIT License | Copyright (c) 2026 wei.liang | See LICENSE */
2
+ import{acceptTranscriptUpdate}from"./acceptance.js";export{acceptTranscriptUpdate};
@@ -0,0 +1,43 @@
1
+ export interface TranscriptWireMessage {
2
+ readonly role: 'user' | 'assistant';
3
+ readonly content: string;
4
+ }
5
+ export interface TranscriptWireSnapshot {
6
+ readonly id: string;
7
+ readonly revision: number;
8
+ readonly start: 0;
9
+ readonly end: number;
10
+ readonly starts: readonly number[];
11
+ readonly messages: readonly TranscriptWireMessage[];
12
+ }
13
+ export type TranscriptWireEvent = Readonly<{
14
+ type: 'transcript';
15
+ transcriptId: string;
16
+ revision: number;
17
+ occurredAt: string;
18
+ origin?: Readonly<{
19
+ contextId: string;
20
+ }>;
21
+ change: Readonly<{
22
+ kind: 'messages-appended';
23
+ start: number;
24
+ messages: readonly TranscriptWireMessage[];
25
+ }> | Readonly<{
26
+ kind: 'segment-started';
27
+ previousStart: number;
28
+ start: number;
29
+ end: number;
30
+ }>;
31
+ }>;
32
+ export type TranscriptFrame = {
33
+ readonly type: 'baseline';
34
+ readonly snapshot: TranscriptWireSnapshot;
35
+ } | {
36
+ readonly type: 'delta';
37
+ readonly event: TranscriptWireEvent;
38
+ };
39
+ export type TranscriptUpdate = TranscriptFrame | {
40
+ readonly type: 'error';
41
+ readonly code: string;
42
+ readonly error: string;
43
+ };
@@ -0,0 +1 @@
1
+ /*! MIT License | Copyright (c) 2026 wei.liang | See LICENSE */
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@weiliang0121/capix-protocol",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js"
10
+ }
11
+ },
12
+ "dependencies": {
13
+ "@weiliang0121/capix-contracts": "0.2.0"
14
+ },
15
+ "description": "Explicit transcript baseline and delta wire contracts for CAPiX.",
16
+ "license": "MIT",
17
+ "author": "wei.liang (https://github.com/weiliang0121)",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/weiliang0121/capix.git",
21
+ "directory": "packages/protocol"
22
+ },
23
+ "engines": {
24
+ "node": ">=22.23.2"
25
+ },
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "files": [
29
+ "dist/**/*.js",
30
+ "dist/**/*.d.ts",
31
+ "LICENSE",
32
+ "README.md"
33
+ ],
34
+ "publishConfig": {
35
+ "access": "public",
36
+ "registry": "https://registry.npmjs.org"
37
+ },
38
+ "devDependencies": {
39
+ "@weiliang0121/capix-transcript": "0.2.0"
40
+ },
41
+ "scripts": {
42
+ "build": "tsc -p tsconfig.json",
43
+ "typecheck": "tsc -p tsconfig.json --noEmit",
44
+ "test": "node ../../scripts/test/run.mjs --package ."
45
+ }
6
46
  }