@agimon-ai/po-session 0.0.0-alpha.134 → 0.0.0-alpha.136
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/dist/apiContracts.cjs +33 -1
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/apiContracts.mjs +34 -1
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/extensions/native.mjs +289 -0
- package/dist/extensions/native.mjs.map +1 -0
- package/dist/extensions/server.cjs +68 -0
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +70 -2
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +279 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/package.json +69 -7
- package/src/prompts/codemode-how-to-session/SKILL.md +1 -0
package/dist/apiContracts.cjs
CHANGED
|
@@ -4,6 +4,28 @@ Object.defineProperties(exports, {
|
|
|
4
4
|
});
|
|
5
5
|
let _agimon_ai_po_core_apiContracts = require("@agimon-ai/po-core/apiContracts");
|
|
6
6
|
let typebox = require("typebox");
|
|
7
|
+
//#region src/schemas/sendToSession.ts
|
|
8
|
+
/** The person's own words, steered into another live session and shown there as "From you, via <from>". */
|
|
9
|
+
const sendToSessionMethod = (0, require("@agimon-ai/po-core/pluginProtocol").definePoPluginMethod)({
|
|
10
|
+
service: "sessions",
|
|
11
|
+
method: "sendToSession",
|
|
12
|
+
scope: "global",
|
|
13
|
+
direction: "client-to-server",
|
|
14
|
+
input: typebox.Type.Object({
|
|
15
|
+
/** The session whose composer the person typed in; it names the message, nothing more. */
|
|
16
|
+
from: typebox.Type.String({ minLength: 1 }),
|
|
17
|
+
to: typebox.Type.String({ minLength: 1 }),
|
|
18
|
+
text: typebox.Type.String({
|
|
19
|
+
minLength: 1,
|
|
20
|
+
maxLength: 1e5
|
|
21
|
+
})
|
|
22
|
+
}, { additionalProperties: false }),
|
|
23
|
+
output: typebox.Type.Object({
|
|
24
|
+
to: typebox.Type.String(),
|
|
25
|
+
name: typebox.Type.String()
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
7
29
|
//#region src/schemas/apiContracts.ts
|
|
8
30
|
/** The endpoint validates its own HMAC peer credential because tunnel device authentication is intentionally bypassed. */
|
|
9
31
|
const http = [{
|
|
@@ -27,7 +49,17 @@ const http = [{
|
|
|
27
49
|
const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
|
|
28
50
|
version: 1,
|
|
29
51
|
http,
|
|
30
|
-
sockets: [
|
|
52
|
+
sockets: [{
|
|
53
|
+
id: "sessions.sendToSession",
|
|
54
|
+
scope: "global",
|
|
55
|
+
service: sendToSessionMethod.service,
|
|
56
|
+
member: sendToSessionMethod.method,
|
|
57
|
+
kind: "method",
|
|
58
|
+
direction: "client-to-server",
|
|
59
|
+
description: "Steer the person's text into another live session, shown there as from them.",
|
|
60
|
+
input: sendToSessionMethod.input,
|
|
61
|
+
output: sendToSessionMethod.output
|
|
62
|
+
}],
|
|
31
63
|
dynamic: []
|
|
32
64
|
});
|
|
33
65
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.cjs","names":["Type","jsonApiResponses","defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\n/** The endpoint validates its own HMAC peer credential because tunnel device authentication is intentionally bypassed. */\nconst http: PoHttpContract[] = [\n {\n id: 'peer-inbox',\n scope: 'global',\n basePath: 'session-peer',\n method: 'POST',\n path: '/inbox',\n authentication: 'none',\n description:\n 'Accept an HMAC-authenticated durable Session delivery envelope from an explicitly configured tunnel peer.',\n body: { contentType: 'application/json', required: true, schema: Type.Unknown() },\n responses: jsonApiResponses(Type.Object({ accepted: Type.Boolean(), state: Type.String() })),\n },\n];\n\nexport const apiContracts = defineApiContract({
|
|
1
|
+
{"version":3,"file":"apiContracts.cjs","names":["definePoPluginMethod","Type","Type","jsonApiResponses","defineApiContract"],"sources":["../src/schemas/sendToSession.ts","../src/schemas/apiContracts.ts"],"sourcesContent":["import { definePoPluginMethod } from '@agimon-ai/po-core/pluginProtocol';\nimport { Type } from 'typebox';\n\n/** The person's own words, steered into another live session and shown there as \"From you, via <from>\". */\nexport const sendToSessionMethod = definePoPluginMethod({\n service: 'sessions',\n method: 'sendToSession',\n scope: 'global',\n direction: 'client-to-server',\n input: Type.Object(\n {\n /** The session whose composer the person typed in; it names the message, nothing more. */\n from: Type.String({ minLength: 1 }),\n to: Type.String({ minLength: 1 }),\n text: Type.String({ minLength: 1, maxLength: 100_000 }),\n },\n { additionalProperties: false },\n ),\n output: Type.Object({ to: Type.String(), name: Type.String() }),\n});\n","import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nimport { sendToSessionMethod } from './sendToSession';\n\n/** The endpoint validates its own HMAC peer credential because tunnel device authentication is intentionally bypassed. */\nconst http: PoHttpContract[] = [\n {\n id: 'peer-inbox',\n scope: 'global',\n basePath: 'session-peer',\n method: 'POST',\n path: '/inbox',\n authentication: 'none',\n description:\n 'Accept an HMAC-authenticated durable Session delivery envelope from an explicitly configured tunnel peer.',\n body: { contentType: 'application/json', required: true, schema: Type.Unknown() },\n responses: jsonApiResponses(Type.Object({ accepted: Type.Boolean(), state: Type.String() })),\n },\n];\n\nexport const apiContracts = defineApiContract({\n version: 1,\n http,\n sockets: [\n {\n id: 'sessions.sendToSession',\n scope: 'global',\n service: sendToSessionMethod.service,\n member: sendToSessionMethod.method,\n kind: 'method',\n direction: 'client-to-server',\n description: \"Steer the person's text into another live session, shown there as from them.\",\n input: sendToSessionMethod.input,\n output: sendToSessionMethod.output,\n },\n ],\n dynamic: [],\n});\nexport default apiContracts;\n"],"mappings":";;;;;;;;AAIA,MAAa,uBAAA,G,2CAAsBA,CAAAA,CAAAA,qBAAAA,CAAqB;CACtD,SAAS;CACT,QAAQ;CACR,OAAO;CACP,WAAW;CACX,OAAOC,QAAAA,KAAK,OACV;;EAEE,MAAMA,QAAAA,KAAK,OAAO,EAAE,WAAW,EAAE,CAAC;EAClC,IAAIA,QAAAA,KAAK,OAAO,EAAE,WAAW,EAAE,CAAC;EAChC,MAAMA,QAAAA,KAAK,OAAO;GAAE,WAAW;GAAG,WAAW;EAAQ,CAAC;CACxD,GACA,EAAE,sBAAsB,MAAM,CAChC;CACA,QAAQA,QAAAA,KAAK,OAAO;EAAE,IAAIA,QAAAA,KAAK,OAAO;EAAG,MAAMA,QAAAA,KAAK,OAAO;CAAE,CAAC;AAChE,CAAC;;;;ACbD,MAAM,OAAyB,CAC7B;CACE,IAAI;CACJ,OAAO;CACP,UAAU;CACV,QAAQ;CACR,MAAM;CACN,gBAAgB;CAChB,aACE;CACF,MAAM;EAAE,aAAa;EAAoB,UAAU;EAAM,QAAQC,QAAAA,KAAK,QAAQ;CAAE;CAChF,YAAA,GAAWC,gCAAAA,iBAAAA,CAAiBD,QAAAA,KAAK,OAAO;EAAE,UAAUA,QAAAA,KAAK,QAAQ;EAAG,OAAOA,QAAAA,KAAK,OAAO;CAAE,CAAC,CAAC;AAC7F,CACF;AAEA,MAAa,gBAAA,GAAeE,gCAAAA,kBAAAA,CAAkB;CAC5C,SAAS;CACT;CACA,SAAS,CACP;EACE,IAAI;EACJ,OAAO;EACP,SAAS,oBAAoB;EAC7B,QAAQ,oBAAoB;EAC5B,MAAM;EACN,WAAW;EACX,aAAa;EACb,OAAO,oBAAoB;EAC3B,QAAQ,oBAAoB;CAC9B,CACF;CACA,SAAS,CAAC;AACZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";qBAqBa"}
|
package/dist/apiContracts.mjs
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
import { defineApiContract, jsonApiResponses } from "@agimon-ai/po-core/apiContracts";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
+
import { definePoPluginMethod } from "@agimon-ai/po-core/pluginProtocol";
|
|
4
|
+
//#region src/schemas/sendToSession.ts
|
|
5
|
+
/** The person's own words, steered into another live session and shown there as "From you, via <from>". */
|
|
6
|
+
const sendToSessionMethod = definePoPluginMethod({
|
|
7
|
+
service: "sessions",
|
|
8
|
+
method: "sendToSession",
|
|
9
|
+
scope: "global",
|
|
10
|
+
direction: "client-to-server",
|
|
11
|
+
input: Type.Object({
|
|
12
|
+
/** The session whose composer the person typed in; it names the message, nothing more. */
|
|
13
|
+
from: Type.String({ minLength: 1 }),
|
|
14
|
+
to: Type.String({ minLength: 1 }),
|
|
15
|
+
text: Type.String({
|
|
16
|
+
minLength: 1,
|
|
17
|
+
maxLength: 1e5
|
|
18
|
+
})
|
|
19
|
+
}, { additionalProperties: false }),
|
|
20
|
+
output: Type.Object({
|
|
21
|
+
to: Type.String(),
|
|
22
|
+
name: Type.String()
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
//#endregion
|
|
3
26
|
//#region src/schemas/apiContracts.ts
|
|
4
27
|
/** The endpoint validates its own HMAC peer credential because tunnel device authentication is intentionally bypassed. */
|
|
5
28
|
const http = [{
|
|
@@ -23,7 +46,17 @@ const http = [{
|
|
|
23
46
|
const apiContracts = defineApiContract({
|
|
24
47
|
version: 1,
|
|
25
48
|
http,
|
|
26
|
-
sockets: [
|
|
49
|
+
sockets: [{
|
|
50
|
+
id: "sessions.sendToSession",
|
|
51
|
+
scope: "global",
|
|
52
|
+
service: sendToSessionMethod.service,
|
|
53
|
+
member: sendToSessionMethod.method,
|
|
54
|
+
kind: "method",
|
|
55
|
+
direction: "client-to-server",
|
|
56
|
+
description: "Steer the person's text into another live session, shown there as from them.",
|
|
57
|
+
input: sendToSessionMethod.input,
|
|
58
|
+
output: sendToSessionMethod.output
|
|
59
|
+
}],
|
|
27
60
|
dynamic: []
|
|
28
61
|
});
|
|
29
62
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\n/** The endpoint validates its own HMAC peer credential because tunnel device authentication is intentionally bypassed. */\nconst http: PoHttpContract[] = [\n {\n id: 'peer-inbox',\n scope: 'global',\n basePath: 'session-peer',\n method: 'POST',\n path: '/inbox',\n authentication: 'none',\n description:\n 'Accept an HMAC-authenticated durable Session delivery envelope from an explicitly configured tunnel peer.',\n body: { contentType: 'application/json', required: true, schema: Type.Unknown() },\n responses: jsonApiResponses(Type.Object({ accepted: Type.Boolean(), state: Type.String() })),\n },\n];\n\nexport const apiContracts = defineApiContract({
|
|
1
|
+
{"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/sendToSession.ts","../src/schemas/apiContracts.ts"],"sourcesContent":["import { definePoPluginMethod } from '@agimon-ai/po-core/pluginProtocol';\nimport { Type } from 'typebox';\n\n/** The person's own words, steered into another live session and shown there as \"From you, via <from>\". */\nexport const sendToSessionMethod = definePoPluginMethod({\n service: 'sessions',\n method: 'sendToSession',\n scope: 'global',\n direction: 'client-to-server',\n input: Type.Object(\n {\n /** The session whose composer the person typed in; it names the message, nothing more. */\n from: Type.String({ minLength: 1 }),\n to: Type.String({ minLength: 1 }),\n text: Type.String({ minLength: 1, maxLength: 100_000 }),\n },\n { additionalProperties: false },\n ),\n output: Type.Object({ to: Type.String(), name: Type.String() }),\n});\n","import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nimport { sendToSessionMethod } from './sendToSession';\n\n/** The endpoint validates its own HMAC peer credential because tunnel device authentication is intentionally bypassed. */\nconst http: PoHttpContract[] = [\n {\n id: 'peer-inbox',\n scope: 'global',\n basePath: 'session-peer',\n method: 'POST',\n path: '/inbox',\n authentication: 'none',\n description:\n 'Accept an HMAC-authenticated durable Session delivery envelope from an explicitly configured tunnel peer.',\n body: { contentType: 'application/json', required: true, schema: Type.Unknown() },\n responses: jsonApiResponses(Type.Object({ accepted: Type.Boolean(), state: Type.String() })),\n },\n];\n\nexport const apiContracts = defineApiContract({\n version: 1,\n http,\n sockets: [\n {\n id: 'sessions.sendToSession',\n scope: 'global',\n service: sendToSessionMethod.service,\n member: sendToSessionMethod.method,\n kind: 'method',\n direction: 'client-to-server',\n description: \"Steer the person's text into another live session, shown there as from them.\",\n input: sendToSessionMethod.input,\n output: sendToSessionMethod.output,\n },\n ],\n dynamic: [],\n});\nexport default apiContracts;\n"],"mappings":";;;;;AAIA,MAAa,sBAAsB,qBAAqB;CACtD,SAAS;CACT,QAAQ;CACR,OAAO;CACP,WAAW;CACX,OAAO,KAAK,OACV;;EAEE,MAAM,KAAK,OAAO,EAAE,WAAW,EAAE,CAAC;EAClC,IAAI,KAAK,OAAO,EAAE,WAAW,EAAE,CAAC;EAChC,MAAM,KAAK,OAAO;GAAE,WAAW;GAAG,WAAW;EAAQ,CAAC;CACxD,GACA,EAAE,sBAAsB,MAAM,CAChC;CACA,QAAQ,KAAK,OAAO;EAAE,IAAI,KAAK,OAAO;EAAG,MAAM,KAAK,OAAO;CAAE,CAAC;AAChE,CAAC;;;;ACbD,MAAM,OAAyB,CAC7B;CACE,IAAI;CACJ,OAAO;CACP,UAAU;CACV,QAAQ;CACR,MAAM;CACN,gBAAgB;CAChB,aACE;CACF,MAAM;EAAE,aAAa;EAAoB,UAAU;EAAM,QAAQ,KAAK,QAAQ;CAAE;CAChF,WAAW,iBAAiB,KAAK,OAAO;EAAE,UAAU,KAAK,QAAQ;EAAG,OAAO,KAAK,OAAO;CAAE,CAAC,CAAC;AAC7F,CACF;AAEA,MAAa,eAAe,kBAAkB;CAC5C,SAAS;CACT;CACA,SAAS,CACP;EACE,IAAI;EACJ,OAAO;EACP,SAAS,oBAAoB;EAC7B,QAAQ,oBAAoB;EAC5B,MAAM;EACN,WAAW;EACX,aAAa;EACb,OAAO,oBAAoB;EAC3B,QAAQ,oBAAoB;CAC9B,CACF;CACA,SAAS,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { defineFill, defineGlobalStore, defineNativePlugin, defineWebLifecycle } from "@agimon-ai/po-core/native";
|
|
2
|
+
import { View } from "react-native-unistyles/components/native/View";
|
|
3
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
4
|
+
import { Button, Dot, Input, ListRow, SheetBody, SheetDescription, SheetFooter, fontOf } from "@agimon-ai/po-native-components";
|
|
5
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_lib/sendToSessionDelivery.ts
|
|
9
|
+
/**
|
|
10
|
+
* Delivers one send through the started runtime that owns the sending session.
|
|
11
|
+
*
|
|
12
|
+
* DESIGN PATTERNS:
|
|
13
|
+
* - Host-neutral and stateless: the web and native request files each keep
|
|
14
|
+
* their own runtime list (from their own po-core entry) and pass it in.
|
|
15
|
+
* The phone starts one runtime per computer; a send goes through the one
|
|
16
|
+
* that owns the sending session, with that computer's local ids.
|
|
17
|
+
*
|
|
18
|
+
* AVOID:
|
|
19
|
+
* - Value imports from a po-core entry here. Native plugins may not import
|
|
20
|
+
* `po-core/web`, and web plugins may not import `po-core/native`.
|
|
21
|
+
*/
|
|
22
|
+
/** The runtime that owns `from`, with both ids as its computer knows them; undefined when none does. */
|
|
23
|
+
function route(runtimes, input) {
|
|
24
|
+
return runtimes.flatMap((runtime) => {
|
|
25
|
+
try {
|
|
26
|
+
const from = runtime.localSessionId?.(input.from) ?? input.from;
|
|
27
|
+
const to = runtime.localSessionId?.(input.to) ?? input.to;
|
|
28
|
+
return from !== input.from || (runtime.qualifySessionId?.(input.from) ?? input.from) === input.from ? [{
|
|
29
|
+
runtime,
|
|
30
|
+
from,
|
|
31
|
+
to
|
|
32
|
+
}] : [];
|
|
33
|
+
} catch {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
}).at(-1);
|
|
37
|
+
}
|
|
38
|
+
/** Steers `text` into session `to`. Resolves to the reason shown when it was refused, or undefined once delivered. */
|
|
39
|
+
async function deliverToSession(runtimes, input) {
|
|
40
|
+
const owner = route(runtimes, input);
|
|
41
|
+
if (!owner) return "Po is not connected. Your text is kept; try again.";
|
|
42
|
+
try {
|
|
43
|
+
await owner.runtime.invokeServerMethod({
|
|
44
|
+
mount: { scope: "global" },
|
|
45
|
+
service: "sessions",
|
|
46
|
+
method: "sendToSession",
|
|
47
|
+
input: {
|
|
48
|
+
from: owner.from,
|
|
49
|
+
to: owner.to,
|
|
50
|
+
text: input.text
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return error instanceof Error && error.message !== "" ? error.message : "The message was not delivered.";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_lib/sendToSessionRequest.native.ts
|
|
60
|
+
/**
|
|
61
|
+
* The phone's started runtimes, one per computer, for the send-to-session panel.
|
|
62
|
+
*
|
|
63
|
+
* DESIGN PATTERNS:
|
|
64
|
+
* - The native twin of sendToSessionRequest.ts: a native plugin may import
|
|
65
|
+
* po-core/native only. The phone has no menu-to-overlay handoff, so only the
|
|
66
|
+
* runtime list and the send live here.
|
|
67
|
+
*/
|
|
68
|
+
const runtimes = defineGlobalStore([]);
|
|
69
|
+
function startSendToSessionRuntime(runtime) {
|
|
70
|
+
runtimes.update((current) => [...current, runtime]);
|
|
71
|
+
return () => runtimes.update((current) => current.filter((entry) => entry !== runtime));
|
|
72
|
+
}
|
|
73
|
+
/** Steers `text` into session `to`. Resolves to the reason shown when it was refused, or undefined once delivered. */
|
|
74
|
+
function sendToSession(input) {
|
|
75
|
+
return deliverToSession(runtimes.store.state, input);
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/extensions/workspaces/sessions/(frontend)/fill/_components/SendToSessionPanel.native.tsx
|
|
79
|
+
/**
|
|
80
|
+
* The phone's "Send to session…" page of the composer's Insert sheet: pick a
|
|
81
|
+
* live session, then Send steers what the person typed into it.
|
|
82
|
+
*
|
|
83
|
+
* DESIGN PATTERNS:
|
|
84
|
+
* - The draft is taken only at Send, so opening and leaving the page never
|
|
85
|
+
* touches it. A refused send keeps the taken text for a retry and hands it
|
|
86
|
+
* back to the composer when the page goes away.
|
|
87
|
+
* - The sheet closes when the page appends to the draft; an empty append
|
|
88
|
+
* closes it and leaves the draft alone.
|
|
89
|
+
*
|
|
90
|
+
* AVOID:
|
|
91
|
+
* - Sending on a row tap. On a phone a mis-tap would send; Send is its own button.
|
|
92
|
+
*/
|
|
93
|
+
const TONE = {
|
|
94
|
+
running: "green",
|
|
95
|
+
waiting: "magenta",
|
|
96
|
+
idle: "neutral"
|
|
97
|
+
};
|
|
98
|
+
/** The Insert sheet page: lists the computer's live sessions and steers the composer's text into one. */
|
|
99
|
+
function SendToSessionPanel({ sessionId, listSessions, takeComposerDraft, appendComposerDraft }) {
|
|
100
|
+
const [sessions] = useState(() => listSessions?.() ?? []);
|
|
101
|
+
const [to, setTo] = useState();
|
|
102
|
+
const [busy, setBusy] = useState(false);
|
|
103
|
+
const [error, setError] = useState("");
|
|
104
|
+
const held = useRef({
|
|
105
|
+
inFlight: false,
|
|
106
|
+
live: true
|
|
107
|
+
});
|
|
108
|
+
const giveBack = useRef(appendComposerDraft);
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
giveBack.current = appendComposerDraft;
|
|
111
|
+
}, [appendComposerDraft]);
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
const state = held.current;
|
|
114
|
+
state.live = true;
|
|
115
|
+
return () => {
|
|
116
|
+
state.live = false;
|
|
117
|
+
if (state.text !== void 0 && !state.inFlight) giveBack.current(state.text);
|
|
118
|
+
};
|
|
119
|
+
}, []);
|
|
120
|
+
const send = async () => {
|
|
121
|
+
if (to === void 0 || sessionId === null) return;
|
|
122
|
+
const state = held.current;
|
|
123
|
+
const text = state.text ?? takeComposerDraft?.() ?? "";
|
|
124
|
+
if (text.trim() === "") {
|
|
125
|
+
setError("Write something to send.");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
state.text = text;
|
|
129
|
+
state.inFlight = true;
|
|
130
|
+
setBusy(true);
|
|
131
|
+
setError("");
|
|
132
|
+
const refusal = await sendToSession({
|
|
133
|
+
from: sessionId,
|
|
134
|
+
to,
|
|
135
|
+
text: text.trim()
|
|
136
|
+
});
|
|
137
|
+
state.inFlight = false;
|
|
138
|
+
if (refusal === void 0) state.text = void 0;
|
|
139
|
+
if (!state.live) {
|
|
140
|
+
if (state.text !== void 0) giveBack.current(state.text);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (refusal === void 0) {
|
|
144
|
+
giveBack.current("");
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
setBusy(false);
|
|
148
|
+
setError(refusal);
|
|
149
|
+
};
|
|
150
|
+
return /* @__PURE__ */ jsx(SendToSessionView, {
|
|
151
|
+
sessions,
|
|
152
|
+
to,
|
|
153
|
+
busy,
|
|
154
|
+
error,
|
|
155
|
+
onPick: setTo,
|
|
156
|
+
onSend: () => void send()
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function SendToSessionView({ sessions, to, busy, error, onPick, onSend }) {
|
|
160
|
+
const [filter, setFilter] = useState("");
|
|
161
|
+
const shown = useMemo(() => {
|
|
162
|
+
const query = filter.trim().toLowerCase();
|
|
163
|
+
return query === "" ? sessions : sessions.filter((session) => `${session.name} ${session.detail}`.toLowerCase().includes(query));
|
|
164
|
+
}, [filter, sessions]);
|
|
165
|
+
const target = sessions.find((session) => session.id === to);
|
|
166
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(SheetBody, { children: [
|
|
167
|
+
/* @__PURE__ */ jsx(SheetDescription, { children: "Send what you typed to another session. It arrives there from you." }),
|
|
168
|
+
error === "" ? null : /* @__PURE__ */ jsx(Text, {
|
|
169
|
+
accessibilityRole: "alert",
|
|
170
|
+
style: styles.alert,
|
|
171
|
+
children: error
|
|
172
|
+
}),
|
|
173
|
+
sessions.length === 0 ? /* @__PURE__ */ jsx(Text, {
|
|
174
|
+
style: styles.empty,
|
|
175
|
+
children: "No other session is running. Open one, then send."
|
|
176
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Input, {
|
|
177
|
+
accessibilityLabel: "Filter sessions",
|
|
178
|
+
placeholder: "Filter sessions",
|
|
179
|
+
value: filter,
|
|
180
|
+
onChangeText: setFilter
|
|
181
|
+
}), shown.length === 0 ? /* @__PURE__ */ jsx(Text, {
|
|
182
|
+
style: styles.empty,
|
|
183
|
+
children: "Nothing matches that filter"
|
|
184
|
+
}) : /* @__PURE__ */ jsx(View, {
|
|
185
|
+
style: styles.rows,
|
|
186
|
+
children: shown.map((session, index) => /* @__PURE__ */ jsxs(View, { children: [index > 0 ? /* @__PURE__ */ jsx(View, { style: styles.separator }) : null, /* @__PURE__ */ jsx(ListRow, {
|
|
187
|
+
accessibilityLabel: `${session.name}, ${session.detail}`,
|
|
188
|
+
selected: session.id === to,
|
|
189
|
+
disabled: busy,
|
|
190
|
+
onPress: () => onPick(session.id),
|
|
191
|
+
disclosure: false,
|
|
192
|
+
style: styles.row,
|
|
193
|
+
leading: /* @__PURE__ */ jsx(Dot, {
|
|
194
|
+
tone: TONE[session.state],
|
|
195
|
+
size: "md"
|
|
196
|
+
}),
|
|
197
|
+
title: session.name,
|
|
198
|
+
description: /* @__PURE__ */ jsx(Text, {
|
|
199
|
+
numberOfLines: 1,
|
|
200
|
+
style: styles.detail,
|
|
201
|
+
children: session.detail
|
|
202
|
+
})
|
|
203
|
+
})] }, session.id))
|
|
204
|
+
})] })
|
|
205
|
+
] }), /* @__PURE__ */ jsx(SheetFooter, { children: /* @__PURE__ */ jsx(Button, {
|
|
206
|
+
variant: "primary",
|
|
207
|
+
disabled: busy || target === void 0,
|
|
208
|
+
onPress: onSend,
|
|
209
|
+
children: busy ? "Sending…" : target === void 0 ? "Pick a session" : `Send to ${target.name}`
|
|
210
|
+
}) })] });
|
|
211
|
+
}
|
|
212
|
+
const styles = StyleSheet.create((theme) => {
|
|
213
|
+
const small = {
|
|
214
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
215
|
+
fontSize: theme.fontSize.sm,
|
|
216
|
+
lineHeight: theme.lineHeight.sm
|
|
217
|
+
};
|
|
218
|
+
return {
|
|
219
|
+
rows: {
|
|
220
|
+
borderTopWidth: StyleSheet.hairlineWidth,
|
|
221
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
222
|
+
borderColor: theme.colors["border-soft"],
|
|
223
|
+
uni__dependencies: [0]
|
|
224
|
+
},
|
|
225
|
+
row: {
|
|
226
|
+
paddingHorizontal: theme.spacing(1),
|
|
227
|
+
uni__dependencies: [0]
|
|
228
|
+
},
|
|
229
|
+
separator: {
|
|
230
|
+
height: StyleSheet.hairlineWidth,
|
|
231
|
+
backgroundColor: theme.colors["border-soft"],
|
|
232
|
+
uni__dependencies: [0]
|
|
233
|
+
},
|
|
234
|
+
detail: {
|
|
235
|
+
...small,
|
|
236
|
+
color: theme.colors.dim,
|
|
237
|
+
uni__dependencies: [0]
|
|
238
|
+
},
|
|
239
|
+
empty: {
|
|
240
|
+
...small,
|
|
241
|
+
paddingVertical: theme.spacing(6),
|
|
242
|
+
textAlign: "center",
|
|
243
|
+
color: theme.colors.dim,
|
|
244
|
+
uni__dependencies: [0]
|
|
245
|
+
},
|
|
246
|
+
alert: {
|
|
247
|
+
...small,
|
|
248
|
+
color: theme.colors.red,
|
|
249
|
+
uni__dependencies: [0]
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region src/extensions/workspaces/sessions/(frontend)/fill/SendToSession.composer-menu.native.tsx
|
|
255
|
+
/** The phone's Insert sheet draws `data` as the row and `component` as the page it opens. */
|
|
256
|
+
var SendToSession_composer_menu_native_default = defineFill({
|
|
257
|
+
data: {
|
|
258
|
+
title: "Send to session…",
|
|
259
|
+
hint: "Steer another session with what you typed"
|
|
260
|
+
},
|
|
261
|
+
component: SendToSessionPanel
|
|
262
|
+
});
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/extensions/workspaces/sessions/(frontend)/lifecycle/start.native.ts
|
|
265
|
+
var start_native_default = defineWebLifecycle(startSendToSessionRuntime);
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region generated/native.ts
|
|
268
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
269
|
+
...identity,
|
|
270
|
+
...value
|
|
271
|
+
};
|
|
272
|
+
const nativePlugin = defineNativePlugin({
|
|
273
|
+
id: "sessions",
|
|
274
|
+
session: {
|
|
275
|
+
get fills() {
|
|
276
|
+
return [via({
|
|
277
|
+
slot: "composer-menu",
|
|
278
|
+
id: "send-to-session"
|
|
279
|
+
}, SendToSession_composer_menu_native_default)];
|
|
280
|
+
},
|
|
281
|
+
get start() {
|
|
282
|
+
return start_native_default;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
//#endregion
|
|
287
|
+
export { nativePlugin };
|
|
288
|
+
|
|
289
|
+
//# sourceMappingURL=native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.mjs","names":["WebPluginSessionOption","WebPluginSlotProps","Button","Dot","fontOf","Input","ListRow","SheetBody","SheetDescription","SheetFooter","useEffect","useMemo","useRef","useState","StyleSheet","sendToSession","TONE","running","waiting","idle","const","SendToSessionPanel","sessionId","listSessions","takeComposerDraft","appendComposerDraft","sessions","to","setTo","busy","setBusy","error","setError","held","text","inFlight","live","giveBack","current","state","undefined","send","Promise","trim","refusal","from","SendToSessionViewProps","onPick","id","onSend","SendToSessionView","filter","setFilter","shown","query","toLowerCase","session","name","detail","includes","target","find","styles","alert","length","empty","rows","map","index","separator","row","create","theme","small","fontFamily","sans","fontSize","sm","lineHeight","borderTopWidth","hairlineWidth","borderBottomWidth","borderColor","colors","uni__dependencies","paddingHorizontal","spacing","height","backgroundColor","color","dim","paddingVertical","textAlign","red","fillSendToSession","lifecycleStart"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/_lib/sendToSessionDelivery.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/sendToSessionRequest.native.ts","../../src/extensions/workspaces/sessions/(frontend)/fill/_components/SendToSessionPanel.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/fill/SendToSession.composer-menu.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/lifecycle/start.native.ts","../../generated/native.ts"],"sourcesContent":["import type { WebPluginRuntime } from '@agimon-ai/po-core/web';\n\n/**\n * Delivers one send through the started runtime that owns the sending session.\n *\n * DESIGN PATTERNS:\n * - Host-neutral and stateless: the web and native request files each keep\n * their own runtime list (from their own po-core entry) and pass it in.\n * The phone starts one runtime per computer; a send goes through the one\n * that owns the sending session, with that computer's local ids.\n *\n * AVOID:\n * - Value imports from a po-core entry here. Native plugins may not import\n * `po-core/web`, and web plugins may not import `po-core/native`.\n */\n\n/** The runtime that owns `from`, with both ids as its computer knows them; undefined when none does. */\nfunction route(runtimes: readonly WebPluginRuntime[], input: { from: string; to: string }) {\n const owners = runtimes.flatMap((runtime) => {\n try {\n const from = runtime.localSessionId?.(input.from) ?? input.from;\n const to = runtime.localSessionId?.(input.to) ?? input.to;\n // An unqualified id belongs to the computer that would leave it unqualified (the local hub).\n const owns = from !== input.from || (runtime.qualifySessionId?.(input.from) ?? input.from) === input.from;\n return owns ? [{ runtime, from, to }] : [];\n } catch {\n // localSessionId refuses an id of another computer: this runtime does not own the send.\n return [];\n }\n });\n return owners.at(-1);\n}\n\n/** Steers `text` into session `to`. Resolves to the reason shown when it was refused, or undefined once delivered. */\nexport async function deliverToSession(\n runtimes: readonly WebPluginRuntime[],\n input: { from: string; to: string; text: string },\n): Promise<string | undefined> {\n const owner = route(runtimes, input);\n if (!owner) return 'Po is not connected. Your text is kept; try again.';\n try {\n await owner.runtime.invokeServerMethod({\n mount: { scope: 'global' },\n service: 'sessions',\n method: 'sendToSession',\n input: { from: owner.from, to: owner.to, text: input.text },\n });\n return undefined;\n } catch (error) {\n return error instanceof Error && error.message !== '' ? error.message : 'The message was not delivered.';\n }\n}\n","import { defineGlobalStore, type WebPluginRuntime } from '@agimon-ai/po-core/native';\n\nimport { deliverToSession } from './sendToSessionDelivery';\n\n/**\n * The phone's started runtimes, one per computer, for the send-to-session panel.\n *\n * DESIGN PATTERNS:\n * - The native twin of sendToSessionRequest.ts: a native plugin may import\n * po-core/native only. The phone has no menu-to-overlay handoff, so only the\n * runtime list and the send live here.\n */\n\nconst runtimes = defineGlobalStore<readonly WebPluginRuntime[]>([]);\n\nexport function startSendToSessionRuntime(runtime: WebPluginRuntime): () => void {\n runtimes.update((current) => [...current, runtime]);\n return () => runtimes.update((current) => current.filter((entry) => entry !== runtime));\n}\n\n/** Steers `text` into session `to`. Resolves to the reason shown when it was refused, or undefined once delivered. */\nexport function sendToSession(input: { from: string; to: string; text: string }): Promise<string | undefined> {\n return deliverToSession(runtimes.store.state, input);\n}\n","import type { WebPluginSessionOption, WebPluginSlotProps } from '@agimon-ai/po-core/native';\nimport {\n Button,\n Dot,\n fontOf,\n Input,\n ListRow,\n SheetBody,\n SheetDescription,\n SheetFooter,\n} from '@agimon-ai/po-native-components';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { sendToSession } from '../../_lib/sendToSessionRequest.native';\n\n/**\n * The phone's \"Send to session…\" page of the composer's Insert sheet: pick a\n * live session, then Send steers what the person typed into it.\n *\n * DESIGN PATTERNS:\n * - The draft is taken only at Send, so opening and leaving the page never\n * touches it. A refused send keeps the taken text for a retry and hands it\n * back to the composer when the page goes away.\n * - The sheet closes when the page appends to the draft; an empty append\n * closes it and leaves the draft alone.\n *\n * AVOID:\n * - Sending on a row tap. On a phone a mis-tap would send; Send is its own button.\n */\n\nconst TONE = { running: 'green', waiting: 'magenta', idle: 'neutral' } as const;\n\n/** The Insert sheet page: lists the computer's live sessions and steers the composer's text into one. */\nexport function SendToSessionPanel({\n sessionId,\n listSessions,\n takeComposerDraft,\n appendComposerDraft,\n}: WebPluginSlotProps) {\n const [sessions] = useState(() => listSessions?.() ?? []);\n const [to, setTo] = useState<string>();\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState('');\n // Text taken from the composer and not yet delivered; `live` is false once the page is gone.\n const held = useRef<{ text?: string; inFlight: boolean; live: boolean }>({ inFlight: false, live: true });\n const giveBack = useRef(appendComposerDraft);\n useEffect(() => {\n giveBack.current = appendComposerDraft;\n }, [appendComposerDraft]);\n useEffect(() => {\n const state = held.current;\n state.live = true;\n return () => {\n state.live = false;\n if (state.text !== undefined && !state.inFlight) giveBack.current(state.text);\n };\n }, []);\n\n const send = async (): Promise<void> => {\n if (to === undefined || sessionId === null) return;\n const state = held.current;\n const text = state.text ?? takeComposerDraft?.() ?? '';\n if (text.trim() === '') {\n setError('Write something to send.');\n return;\n }\n state.text = text;\n state.inFlight = true;\n setBusy(true);\n setError('');\n const refusal = await sendToSession({ from: sessionId, to, text: text.trim() });\n state.inFlight = false;\n if (refusal === undefined) state.text = undefined;\n if (!state.live) {\n if (state.text !== undefined) giveBack.current(state.text);\n return;\n }\n if (refusal === undefined) {\n giveBack.current('');\n return;\n }\n setBusy(false);\n setError(refusal);\n };\n\n return (\n <SendToSessionView\n sessions={sessions}\n to={to}\n busy={busy}\n error={error}\n onPick={setTo}\n onSend={() => void send()}\n />\n );\n}\n\nexport interface SendToSessionViewProps {\n sessions: readonly WebPluginSessionOption[];\n to: string | undefined;\n busy: boolean;\n /** The server's refusal, shown above the list; empty when there is none. */\n error: string;\n onPick: (id: string) => void;\n onSend: () => void;\n}\n\nexport function SendToSessionView({ sessions, to, busy, error, onPick, onSend }: SendToSessionViewProps) {\n const [filter, setFilter] = useState('');\n const shown = useMemo(() => {\n const query = filter.trim().toLowerCase();\n return query === ''\n ? sessions\n : sessions.filter((session) => `${session.name} ${session.detail}`.toLowerCase().includes(query));\n }, [filter, sessions]);\n const target = sessions.find((session) => session.id === to);\n\n return (\n <>\n <SheetBody>\n <SheetDescription>Send what you typed to another session. It arrives there from you.</SheetDescription>\n {error === '' ? null : (\n <Text accessibilityRole=\"alert\" style={styles.alert}>\n {error}\n </Text>\n )}\n {sessions.length === 0 ? (\n <Text style={styles.empty}>No other session is running. Open one, then send.</Text>\n ) : (\n <>\n <Input\n accessibilityLabel=\"Filter sessions\"\n placeholder=\"Filter sessions\"\n value={filter}\n onChangeText={setFilter}\n />\n {shown.length === 0 ? (\n <Text style={styles.empty}>Nothing matches that filter</Text>\n ) : (\n <View style={styles.rows}>\n {shown.map((session, index) => (\n <View key={session.id}>\n {index > 0 ? <View style={styles.separator} /> : null}\n <ListRow\n accessibilityLabel={`${session.name}, ${session.detail}`}\n selected={session.id === to}\n disabled={busy}\n onPress={() => onPick(session.id)}\n disclosure={false}\n style={styles.row}\n leading={<Dot tone={TONE[session.state]} size=\"md\" />}\n title={session.name}\n description={\n <Text numberOfLines={1} style={styles.detail}>\n {session.detail}\n </Text>\n }\n />\n </View>\n ))}\n </View>\n )}\n </>\n )}\n </SheetBody>\n <SheetFooter>\n <Button variant=\"primary\" disabled={busy || target === undefined} onPress={onSend}>\n {busy ? 'Sending…' : target === undefined ? 'Pick a session' : `Send to ${target.name}`}\n </Button>\n </SheetFooter>\n </>\n );\n}\n\nconst styles = StyleSheet.create((theme) => {\n const small = {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n };\n return {\n rows: {\n borderTopWidth: StyleSheet.hairlineWidth,\n borderBottomWidth: StyleSheet.hairlineWidth,\n borderColor: theme.colors['border-soft'],\n },\n row: { paddingHorizontal: theme.spacing(1) },\n separator: { height: StyleSheet.hairlineWidth, backgroundColor: theme.colors['border-soft'] },\n detail: { ...small, color: theme.colors.dim },\n empty: { ...small, paddingVertical: theme.spacing(6), textAlign: 'center', color: theme.colors.dim },\n alert: { ...small, color: theme.colors.red },\n };\n});\n","import { defineFill } from '@agimon-ai/po-core/native';\n\nimport { SendToSessionPanel } from './_components/SendToSessionPanel.native';\n\n/** The phone's Insert sheet draws `data` as the row and `component` as the page it opens. */\nexport default defineFill({\n data: { title: 'Send to session…', hint: 'Steer another session with what you typed' },\n component: SendToSessionPanel,\n});\n","import { defineWebLifecycle } from '@agimon-ai/po-core/native';\n\nimport { startSendToSessionRuntime } from '../_lib/sendToSessionRequest.native';\n\nexport default defineWebLifecycle(startSendToSessionRuntime);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport fillSendToSession from '../src/extensions/workspaces/sessions/(frontend)/fill/SendToSession.composer-menu.native';\nimport lifecycleStart from '../src/extensions/workspaces/sessions/(frontend)/lifecycle/start.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'sessions',\n session: {\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'composer-menu', id: 'send-to-session' }, fillSendToSession)]; },\n get start(): WebPluginContributions['start'] { return lifecycleStart; },\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAS,MAAM,UA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W,OAAOO;GAAGN,mBAAA,CAAA,CAAA;EAAC;EAC5CnB,OAAO;GAAE,GAAGQ;GAAOkB,iBAAiBnB,MAAMc,QAAQ,CAAC;GAAGM,WAAW;GAAUH,OAAOjB,MAAMW,OAAOO;GAAGN,mBAAA,CAAA,CAAA;EAAC;EACnGrB,OAAO;GAAE,GAAGU;GAAOgB,OAAOjB,MAAMW,OAAOU;GAAGT,mBAAA,CAAA,CAAA;EAAC;CAC7C;AACF,CAAC;;;;AC7LD,IAAA,6CAAe,WAAW;CACxB,MAAM;EAAE,OAAO;EAAoB,MAAM;CAA4C;CACrF,WAAW;AACb,CAAC;;;ACJD,IAAA,uBAAe,mBAAmB,yBAAyB;;;ACE3D,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,SAAS;EACP,IAAI,QAAyC;GAAE,OAAO,CAAC,IAAI;IAAE,MAAM;IAAiB,IAAI;GAAkB,GAAGU,0CAAiB,CAAC;EAAG;EAClI,IAAI,QAAyC;GAAE,OAAOC;EAAgB;CACxE;AACF,CAAC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_type = require("../type-Bzv_vxKC.cjs");
|
|
6
|
+
let typebox = require("typebox");
|
|
6
7
|
let _agimon_ai_po_core_hubChannel = require("@agimon-ai/po-core/hubChannel");
|
|
7
8
|
let _agimon_ai_po_core_codemode = require("@agimon-ai/po-core/codemode");
|
|
8
9
|
let node_path = require("node:path");
|
|
@@ -13,6 +14,7 @@ let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile
|
|
|
13
14
|
let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
|
|
14
15
|
let _agimon_ai_po_core_remoteOrigin = require("@agimon-ai/po-core/remoteOrigin");
|
|
15
16
|
let _agimon_ai_po_core_packageApi = require("@agimon-ai/po-core/packageApi");
|
|
17
|
+
let _agimon_ai_po_core_pluginProtocol = require("@agimon-ai/po-core/pluginProtocol");
|
|
16
18
|
//#region src/extensions/(backend)/root.server.ts
|
|
17
19
|
var root_server_default$1 = (0, _agimon_ai_po_core_extensionFile.defineRoot)((plugin) => ({
|
|
18
20
|
value: void 0,
|
|
@@ -495,6 +497,63 @@ var route_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoute)(({
|
|
|
495
497
|
});
|
|
496
498
|
});
|
|
497
499
|
//#endregion
|
|
500
|
+
//#region src/schemas/sendToSession.ts
|
|
501
|
+
/** The person's own words, steered into another live session and shown there as "From you, via <from>". */
|
|
502
|
+
const sendToSessionMethod = (0, _agimon_ai_po_core_pluginProtocol.definePoPluginMethod)({
|
|
503
|
+
service: "sessions",
|
|
504
|
+
method: "sendToSession",
|
|
505
|
+
scope: "global",
|
|
506
|
+
direction: "client-to-server",
|
|
507
|
+
input: typebox.Type.Object({
|
|
508
|
+
/** The session whose composer the person typed in; it names the message, nothing more. */
|
|
509
|
+
from: typebox.Type.String({ minLength: 1 }),
|
|
510
|
+
to: typebox.Type.String({ minLength: 1 }),
|
|
511
|
+
text: typebox.Type.String({
|
|
512
|
+
minLength: 1,
|
|
513
|
+
maxLength: 1e5
|
|
514
|
+
})
|
|
515
|
+
}, { additionalProperties: false }),
|
|
516
|
+
output: typebox.Type.Object({
|
|
517
|
+
to: typebox.Type.String(),
|
|
518
|
+
name: typebox.Type.String()
|
|
519
|
+
})
|
|
520
|
+
});
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region src/extensions/(backend)/_lib/sendToSession.server.ts
|
|
523
|
+
/**
|
|
524
|
+
* Steers the person's text into another live session, attributed to them. Each refusal reads as the
|
|
525
|
+
* reason the dialog shows, because the text stays there for another try.
|
|
526
|
+
*/
|
|
527
|
+
async function sendToSession(service, input) {
|
|
528
|
+
const text = input.text.trim();
|
|
529
|
+
if (text === "") throw new Error("Write something to send.");
|
|
530
|
+
if (input.to === input.from) throw new Error("That is this session. Pick another one.");
|
|
531
|
+
if (!service?.steer || !service.scopes) throw new Error("This host cannot deliver to another session.");
|
|
532
|
+
const scopes = service.scopes();
|
|
533
|
+
const target = scopes.find((scope) => scope.sessionId === input.to);
|
|
534
|
+
if (target === void 0) throw new Error("That session is not running. Open it to wake it, then send again.");
|
|
535
|
+
const name = target.name?.trim() || input.to;
|
|
536
|
+
const via = scopes.find((scope) => scope.sessionId === input.from)?.name?.trim() || "another session";
|
|
537
|
+
try {
|
|
538
|
+
await service.steer(input.to, {
|
|
539
|
+
text,
|
|
540
|
+
sender: {
|
|
541
|
+
kind: "human",
|
|
542
|
+
name: `From you, via ${via}`
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
} catch (error) {
|
|
546
|
+
throw new Error(`${name} could not take the message: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
547
|
+
}
|
|
548
|
+
return {
|
|
549
|
+
to: input.to,
|
|
550
|
+
name
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region src/extensions/(backend)/method/send-to-session.server.ts
|
|
555
|
+
var send_to_session_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)(({ host }) => host.scope === "global" ? (0, _agimon_ai_po_core_serverPlugin.defineServerMethod)(sendToSessionMethod, (input) => sendToSession(host.context.sessionService, input)) : void 0, { cardinality: "optional" });
|
|
556
|
+
//#endregion
|
|
498
557
|
//#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-session.server.ts
|
|
499
558
|
var codemode_how_to_session_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
|
|
500
559
|
name: "codemode-how-to-session",
|
|
@@ -528,6 +587,9 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
|
528
587
|
get api() {
|
|
529
588
|
return [at(route_server_default, contextGlobal)];
|
|
530
589
|
},
|
|
590
|
+
get methods() {
|
|
591
|
+
return defined([at(send_to_session_server_default, contextGlobal)]);
|
|
592
|
+
},
|
|
531
593
|
services: [...scopeGlobal.services ?? []]
|
|
532
594
|
};
|
|
533
595
|
},
|
|
@@ -542,6 +604,9 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
|
542
604
|
get api() {
|
|
543
605
|
return defined([context.hosted("global") ? void 0 : at(route_server_default, contextGlobal)]);
|
|
544
606
|
},
|
|
607
|
+
get methods() {
|
|
608
|
+
return defined([context.hosted("global") ? void 0 : at(send_to_session_server_default, contextGlobal)]);
|
|
609
|
+
},
|
|
545
610
|
services: [...scopeGlobal.services ?? []]
|
|
546
611
|
};
|
|
547
612
|
},
|
|
@@ -561,6 +626,9 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
|
561
626
|
get api() {
|
|
562
627
|
return defined([context.hosted("global") ? void 0 : at(route_server_default, contextGlobal)]);
|
|
563
628
|
},
|
|
629
|
+
get methods() {
|
|
630
|
+
return defined([context.hosted("global") ? void 0 : at(send_to_session_server_default, contextGlobal)]);
|
|
631
|
+
},
|
|
564
632
|
get resources() {
|
|
565
633
|
return [at(codemode_how_to_session_server_default, contextSession)];
|
|
566
634
|
},
|