@truefoundry/trueforge-core 0.2.0-rc.0 → 0.2.0-rc.2

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.
Files changed (63) hide show
  1. package/dist/agent-session/SessionHandle.d.ts +1 -0
  2. package/dist/agent-session/SessionHandle.d.ts.map +1 -1
  3. package/dist/agent-session/SessionHandle.js +3 -0
  4. package/dist/agent-session/SessionHandle.js.map +1 -1
  5. package/dist/agent-session/SessionHandle.mjs +3 -0
  6. package/dist/agent-session/SessionHandle.mjs.map +1 -1
  7. package/dist/agent-session/Sessions.d.ts +21 -6
  8. package/dist/agent-session/Sessions.d.ts.map +1 -1
  9. package/dist/agent-session/Sessions.js +46 -1
  10. package/dist/agent-session/Sessions.js.map +1 -1
  11. package/dist/agent-session/Sessions.mjs +46 -1
  12. package/dist/agent-session/Sessions.mjs.map +1 -1
  13. package/dist/agent-session/index.d.ts +6 -4
  14. package/dist/agent-session/index.d.ts.map +1 -1
  15. package/dist/agent-session/index.js +15 -0
  16. package/dist/agent-session/index.js.map +1 -1
  17. package/dist/agent-session/index.mjs +17 -1
  18. package/dist/agent-session/index.mjs.map +1 -1
  19. package/dist/agent-session/models/SessionRecord.d.ts +14 -2
  20. package/dist/agent-session/models/SessionRecord.d.ts.map +1 -1
  21. package/dist/agent-session/models/SessionRecord.js.map +1 -1
  22. package/dist/agent-session/schemas/session.d.ts +43 -1
  23. package/dist/agent-session/schemas/session.d.ts.map +1 -1
  24. package/dist/agent-session/schemas/session.js +43 -5
  25. package/dist/agent-session/schemas/session.js.map +1 -1
  26. package/dist/agent-session/schemas/session.mjs +37 -4
  27. package/dist/agent-session/schemas/session.mjs.map +1 -1
  28. package/dist/agent-session/schemas/subject.d.ts +9 -0
  29. package/dist/agent-session/schemas/subject.d.ts.map +1 -0
  30. package/dist/agent-session/schemas/subject.js +36 -0
  31. package/dist/agent-session/schemas/subject.js.map +1 -0
  32. package/dist/agent-session/schemas/subject.mjs +11 -0
  33. package/dist/agent-session/schemas/subject.mjs.map +1 -0
  34. package/dist/agent-session/store/ISessionStore.d.ts +44 -20
  35. package/dist/agent-session/store/ISessionStore.d.ts.map +1 -1
  36. package/dist/agent-session/store/ISessionStore.js.map +1 -1
  37. package/dist/agent-session/store/InMemorySessionStore.d.ts +4 -1
  38. package/dist/agent-session/store/InMemorySessionStore.d.ts.map +1 -1
  39. package/dist/agent-session/store/InMemorySessionStore.js +66 -2
  40. package/dist/agent-session/store/InMemorySessionStore.js.map +1 -1
  41. package/dist/agent-session/store/InMemorySessionStore.mjs +67 -2
  42. package/dist/agent-session/store/InMemorySessionStore.mjs.map +1 -1
  43. package/dist/agent-session/store/SessionStoreErrors.d.ts +4 -0
  44. package/dist/agent-session/store/SessionStoreErrors.d.ts.map +1 -1
  45. package/dist/agent-session/store/SessionStoreErrors.js +10 -0
  46. package/dist/agent-session/store/SessionStoreErrors.js.map +1 -1
  47. package/dist/agent-session/store/SessionStoreErrors.mjs +9 -0
  48. package/dist/agent-session/store/SessionStoreErrors.mjs.map +1 -1
  49. package/dist/core/llm/VercelAILLM.d.ts +1 -1
  50. package/dist/core/llm/VercelAILLM.d.ts.map +1 -1
  51. package/dist/core/llm/VercelAILLM.js +4 -2
  52. package/dist/core/llm/VercelAILLM.js.map +1 -1
  53. package/dist/core/llm/VercelAILLM.mjs +4 -2
  54. package/dist/core/llm/VercelAILLM.mjs.map +1 -1
  55. package/dist/core/mcp/remoteMcpClient.js +1 -1
  56. package/dist/core/mcp/remoteMcpClient.js.map +1 -1
  57. package/dist/core/mcp/remoteMcpClient.mjs +1 -1
  58. package/dist/core/mcp/remoteMcpClient.mjs.map +1 -1
  59. package/dist/core/sandbox/Sandbox.js +5 -5
  60. package/dist/core/sandbox/Sandbox.js.map +1 -1
  61. package/dist/core/sandbox/Sandbox.mjs +1 -1
  62. package/dist/core/sandbox/Sandbox.mjs.map +1 -1
  63. package/package.json +1 -1
@@ -23,6 +23,7 @@ __export(agent_session_exports, {
23
23
  AgentSpecSchema: () => import_agentSpec.AgentSpecSchema,
24
24
  CancellationReason: () => import_turn.CancellationReason,
25
25
  CreateTurnRequestSchema: () => import_turn.CreateTurnRequestSchema,
26
+ CreatedBySubjectSchema: () => import_subject.CreatedBySubjectSchema,
26
27
  DEFAULT_AGENT_CONFIG_ITERATION_LIMIT: () => import_agentSpec.DEFAULT_AGENT_CONFIG_ITERATION_LIMIT,
27
28
  EventType: () => import_events.EventType,
28
29
  InMemorySessionStore: () => import_InMemorySessionStore.InMemorySessionStore,
@@ -33,9 +34,15 @@ __export(agent_session_exports, {
33
34
  SessionAlreadyExistsError: () => import_SessionStoreErrors.SessionAlreadyExistsError,
34
35
  SessionEventItemSchema: () => import_events.SessionEventItemSchema,
35
36
  SessionEventSchema: () => import_events.SessionEventSchema,
37
+ SessionExternalIdConflictError: () => import_SessionStoreErrors.SessionExternalIdConflictError,
36
38
  SessionHandle: () => import_SessionHandle.SessionHandle,
39
+ SessionMetadataSchema: () => import_session.SessionMetadataSchema,
40
+ SessionMetricsSchema: () => import_session.SessionMetricsSchema,
37
41
  SessionNotFoundError: () => import_SessionStoreErrors.SessionNotFoundError,
38
42
  SessionSchema: () => import_session.SessionSchema,
43
+ SessionSourceScheduleSchema: () => import_session.SessionSourceScheduleSchema,
44
+ SessionSourceSchema: () => import_session.SessionSourceSchema,
45
+ SessionSourceTypeSchema: () => import_session.SessionSourceTypeSchema,
39
46
  SessionStoreConflictError: () => import_SessionStoreErrors.SessionStoreConflictError,
40
47
  SessionStoreInvariantError: () => import_SessionStoreErrors.SessionStoreInvariantError,
41
48
  SessionStoreNotFoundError: () => import_SessionStoreErrors.SessionStoreNotFoundError,
@@ -63,6 +70,7 @@ module.exports = __toCommonJS(agent_session_exports);
63
70
  var import_agentSpec = require("./schemas/agentSpec.js");
64
71
  var import_turn = require("./schemas/turn.js");
65
72
  var import_session = require("./schemas/session.js");
73
+ var import_subject = require("./schemas/subject.js");
66
74
  var import_events = require("./schemas/events.js");
67
75
  var import_pagination = require("./schemas/pagination.js");
68
76
  var import_TurnRecord = require("./models/TurnRecord.js");
@@ -78,6 +86,7 @@ var import_TurnHandle = require("./TurnHandle.js");
78
86
  AgentSpecSchema,
79
87
  CancellationReason,
80
88
  CreateTurnRequestSchema,
89
+ CreatedBySubjectSchema,
81
90
  DEFAULT_AGENT_CONFIG_ITERATION_LIMIT,
82
91
  EventType,
83
92
  InMemorySessionStore,
@@ -88,9 +97,15 @@ var import_TurnHandle = require("./TurnHandle.js");
88
97
  SessionAlreadyExistsError,
89
98
  SessionEventItemSchema,
90
99
  SessionEventSchema,
100
+ SessionExternalIdConflictError,
91
101
  SessionHandle,
102
+ SessionMetadataSchema,
103
+ SessionMetricsSchema,
92
104
  SessionNotFoundError,
93
105
  SessionSchema,
106
+ SessionSourceScheduleSchema,
107
+ SessionSourceSchema,
108
+ SessionSourceTypeSchema,
94
109
  SessionStoreConflictError,
95
110
  SessionStoreInvariantError,
96
111
  SessionStoreNotFoundError,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/agent-session/index.ts"],"sourcesContent":["/**\n * Public agent session middle library.\n * Zod product contracts and session/turn runtime.\n */\n\nexport { AgentSpecSchema, DEFAULT_AGENT_CONFIG_ITERATION_LIMIT, RuntimeConfigSchema } from './schemas/agentSpec';\nexport type { AgentSpec, Skill } from './schemas/agentSpec';\n\nexport {\n CancellationReason,\n CreateTurnRequestSchema,\n TurnInputItemSchema,\n TurnMetricsSchema,\n TurnSchema,\n TurnStateCancelledReasonSchema,\n TurnStateCancelledSchema,\n TurnStateDoneSchema,\n TurnStateErrorSchema,\n TurnStateRunningSchema,\n TurnStateSchema,\n} from './schemas/turn';\nexport type { TerminalTurnState, Turn, TurnInputItem, TurnMetrics, TurnState } from './schemas/turn';\n\nexport { SessionSchema } from './schemas/session';\nexport type { Session, SessionAgent } from './schemas/session';\n\nexport {\n EventType,\n SessionEventItemSchema,\n SessionEventSchema,\n TurnCreatedEventSchema,\n TurnDoneEventSchema,\n} from './schemas/events';\nexport type {\n PersistedTurnEvent,\n SessionEvent,\n SessionEventItem,\n TurnCreatedEvent,\n TurnDoneEvent,\n} from './schemas/events';\n\nexport { TokenPaginationSchema } from './schemas/pagination';\nexport type { TokenPagination } from './schemas/pagination';\n\nexport type { SessionRecord } from './models/SessionRecord';\nexport { MAIN_THREAD_ID } from './models/TurnRecord';\nexport type { TurnRecord, TurnSnapshot } from './models/TurnRecord';\n\nexport { assertCreateTurnThreadDelta } from './store/assertCreateTurnThreadDelta';\nexport { InMemorySessionStore } from './store/InMemorySessionStore';\nexport type {\n AddThreadsInput,\n AppendToEventsInput,\n AppendToThreadContextInput,\n CreateSessionInput,\n CreateTurnInput,\n DeleteSessionInput,\n FreezeAndGetTurnInput,\n GetSessionInput,\n GetTurnInput,\n ISessionStore,\n ListSessionEventsInput,\n ListSessionsInput,\n ListTurnEventsInput,\n ListTurnsInput,\n NewThreadInit,\n OverwriteThreadContextInput,\n PatchMCPServersInput,\n PatchSandboxInfoInput,\n PatchThreadCapabilityStateInput,\n RemoveThreadsInput,\n TurnContextAppend,\n TurnRecordWithoutSnapshot,\n UpdateSessionInput,\n UpdateTurnStateInput,\n} from './store/ISessionStore';\nexport {\n InvalidPageTokenError,\n PreviousTurnRunningError,\n SessionAlreadyExistsError,\n SessionNotFoundError,\n SessionStoreConflictError,\n SessionStoreInvariantError,\n SessionStoreNotFoundError,\n TurnAlreadyExistsError,\n TurnNotFoundError,\n TurnNotRunningError,\n} from './store/SessionStoreErrors';\n\nexport type { ITurnResourceResolver } from './ITurnResourceResolver';\nexport { TurnResourceResolver } from './TurnResourceResolver';\nexport type { TurnSandboxFactory } from './TurnResourceResolver';\n\nexport { SessionHandle } from './SessionHandle';\nexport { Sessions } from './Sessions';\nexport { TurnHandle } from './TurnHandle';\nexport type { TurnStreamingEvent } from './TurnHandle';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,uBAA2F;AAG3F,kBAYO;AAGP,qBAA8B;AAG9B,oBAMO;AASP,wBAAsC;AAItC,wBAA+B;AAG/B,yCAA4C;AAC5C,kCAAqC;AA2BrC,gCAWO;AAGP,kCAAqC;AAGrC,2BAA8B;AAC9B,sBAAyB;AACzB,wBAA2B;","names":[]}
1
+ {"version":3,"sources":["../../src/agent-session/index.ts"],"sourcesContent":["/**\n * Public agent session middle library.\n * Zod product contracts and session/turn runtime.\n */\n\nexport { AgentSpecSchema, DEFAULT_AGENT_CONFIG_ITERATION_LIMIT, RuntimeConfigSchema } from './schemas/agentSpec';\nexport type { AgentSpec, Skill } from './schemas/agentSpec';\n\nexport {\n CancellationReason,\n CreateTurnRequestSchema,\n TurnInputItemSchema,\n TurnMetricsSchema,\n TurnSchema,\n TurnStateCancelledReasonSchema,\n TurnStateCancelledSchema,\n TurnStateDoneSchema,\n TurnStateErrorSchema,\n TurnStateRunningSchema,\n TurnStateSchema,\n} from './schemas/turn';\nexport type { TerminalTurnState, Turn, TurnInputItem, TurnMetrics, TurnState } from './schemas/turn';\n\nexport {\n SessionMetadataSchema,\n SessionMetricsSchema,\n SessionSchema,\n SessionSourceScheduleSchema,\n SessionSourceSchema,\n SessionSourceTypeSchema,\n} from './schemas/session';\nexport type {\n Session,\n SessionAgent,\n SessionMetadata,\n SessionMetrics,\n SessionSource,\n SessionSourceType,\n} from './schemas/session';\n\nexport { CreatedBySubjectSchema } from './schemas/subject';\nexport type { CreatedBySubject } from './schemas/subject';\n\nexport {\n EventType,\n SessionEventItemSchema,\n SessionEventSchema,\n TurnCreatedEventSchema,\n TurnDoneEventSchema,\n} from './schemas/events';\nexport type {\n PersistedTurnEvent,\n SessionEvent,\n SessionEventItem,\n TurnCreatedEvent,\n TurnDoneEvent,\n} from './schemas/events';\n\nexport { TokenPaginationSchema } from './schemas/pagination';\nexport type { TokenPagination } from './schemas/pagination';\n\nexport type { SessionRecord } from './models/SessionRecord';\nexport { MAIN_THREAD_ID } from './models/TurnRecord';\nexport type { TurnRecord, TurnSnapshot } from './models/TurnRecord';\n\nexport { assertCreateTurnThreadDelta } from './store/assertCreateTurnThreadDelta';\nexport { InMemorySessionStore } from './store/InMemorySessionStore';\nexport type {\n AddThreadsInput,\n AppendToEventsInput,\n AppendToThreadContextInput,\n CreateSessionInput,\n CreateTurnInput,\n DeleteSessionInput,\n FreezeAndGetTurnInput,\n GetSessionByExternalIdInput,\n GetSessionInput,\n GetTurnInput,\n ISessionStore,\n ListSessionEventsInput,\n ListSessionsInput,\n ListTurnEventsInput,\n ListTurnsInput,\n NewThreadInit,\n OverwriteThreadContextInput,\n PatchMCPServersInput,\n PatchSandboxInfoInput,\n PatchThreadCapabilityStateInput,\n RemoveThreadsInput,\n TurnContextAppend,\n TurnRecordWithoutSnapshot,\n UpdateSessionInput,\n UpdateTurnStateInput,\n} from './store/ISessionStore';\nexport {\n InvalidPageTokenError,\n PreviousTurnRunningError,\n SessionAlreadyExistsError,\n SessionExternalIdConflictError,\n SessionNotFoundError,\n SessionStoreConflictError,\n SessionStoreInvariantError,\n SessionStoreNotFoundError,\n TurnAlreadyExistsError,\n TurnNotFoundError,\n TurnNotRunningError,\n} from './store/SessionStoreErrors';\n\nexport type { ITurnResourceResolver } from './ITurnResourceResolver';\nexport { TurnResourceResolver } from './TurnResourceResolver';\nexport type { TurnSandboxFactory } from './TurnResourceResolver';\n\nexport { SessionHandle } from './SessionHandle';\nexport { Sessions } from './Sessions';\nexport { TurnHandle } from './TurnHandle';\nexport type { TurnStreamingEvent } from './TurnHandle';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,uBAA2F;AAG3F,kBAYO;AAGP,qBAOO;AAUP,qBAAuC;AAGvC,oBAMO;AASP,wBAAsC;AAItC,wBAA+B;AAG/B,yCAA4C;AAC5C,kCAAqC;AA4BrC,gCAYO;AAGP,kCAAqC;AAGrC,2BAA8B;AAC9B,sBAAyB;AACzB,wBAA2B;","names":[]}
@@ -13,7 +13,15 @@ import {
13
13
  TurnStateRunningSchema,
14
14
  TurnStateSchema
15
15
  } from "./schemas/turn.mjs";
16
- import { SessionSchema } from "./schemas/session.mjs";
16
+ import {
17
+ SessionMetadataSchema,
18
+ SessionMetricsSchema,
19
+ SessionSchema,
20
+ SessionSourceScheduleSchema,
21
+ SessionSourceSchema,
22
+ SessionSourceTypeSchema
23
+ } from "./schemas/session.mjs";
24
+ import { CreatedBySubjectSchema } from "./schemas/subject.mjs";
17
25
  import {
18
26
  EventType,
19
27
  SessionEventItemSchema,
@@ -29,6 +37,7 @@ import {
29
37
  InvalidPageTokenError,
30
38
  PreviousTurnRunningError,
31
39
  SessionAlreadyExistsError,
40
+ SessionExternalIdConflictError,
32
41
  SessionNotFoundError,
33
42
  SessionStoreConflictError,
34
43
  SessionStoreInvariantError,
@@ -45,6 +54,7 @@ export {
45
54
  AgentSpecSchema,
46
55
  CancellationReason,
47
56
  CreateTurnRequestSchema,
57
+ CreatedBySubjectSchema,
48
58
  DEFAULT_AGENT_CONFIG_ITERATION_LIMIT,
49
59
  EventType,
50
60
  InMemorySessionStore,
@@ -55,9 +65,15 @@ export {
55
65
  SessionAlreadyExistsError,
56
66
  SessionEventItemSchema,
57
67
  SessionEventSchema,
68
+ SessionExternalIdConflictError,
58
69
  SessionHandle,
70
+ SessionMetadataSchema,
71
+ SessionMetricsSchema,
59
72
  SessionNotFoundError,
60
73
  SessionSchema,
74
+ SessionSourceScheduleSchema,
75
+ SessionSourceSchema,
76
+ SessionSourceTypeSchema,
61
77
  SessionStoreConflictError,
62
78
  SessionStoreInvariantError,
63
79
  SessionStoreNotFoundError,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/agent-session/index.ts"],"sourcesContent":["/**\n * Public agent session middle library.\n * Zod product contracts and session/turn runtime.\n */\n\nexport { AgentSpecSchema, DEFAULT_AGENT_CONFIG_ITERATION_LIMIT, RuntimeConfigSchema } from './schemas/agentSpec';\nexport type { AgentSpec, Skill } from './schemas/agentSpec';\n\nexport {\n CancellationReason,\n CreateTurnRequestSchema,\n TurnInputItemSchema,\n TurnMetricsSchema,\n TurnSchema,\n TurnStateCancelledReasonSchema,\n TurnStateCancelledSchema,\n TurnStateDoneSchema,\n TurnStateErrorSchema,\n TurnStateRunningSchema,\n TurnStateSchema,\n} from './schemas/turn';\nexport type { TerminalTurnState, Turn, TurnInputItem, TurnMetrics, TurnState } from './schemas/turn';\n\nexport { SessionSchema } from './schemas/session';\nexport type { Session, SessionAgent } from './schemas/session';\n\nexport {\n EventType,\n SessionEventItemSchema,\n SessionEventSchema,\n TurnCreatedEventSchema,\n TurnDoneEventSchema,\n} from './schemas/events';\nexport type {\n PersistedTurnEvent,\n SessionEvent,\n SessionEventItem,\n TurnCreatedEvent,\n TurnDoneEvent,\n} from './schemas/events';\n\nexport { TokenPaginationSchema } from './schemas/pagination';\nexport type { TokenPagination } from './schemas/pagination';\n\nexport type { SessionRecord } from './models/SessionRecord';\nexport { MAIN_THREAD_ID } from './models/TurnRecord';\nexport type { TurnRecord, TurnSnapshot } from './models/TurnRecord';\n\nexport { assertCreateTurnThreadDelta } from './store/assertCreateTurnThreadDelta';\nexport { InMemorySessionStore } from './store/InMemorySessionStore';\nexport type {\n AddThreadsInput,\n AppendToEventsInput,\n AppendToThreadContextInput,\n CreateSessionInput,\n CreateTurnInput,\n DeleteSessionInput,\n FreezeAndGetTurnInput,\n GetSessionInput,\n GetTurnInput,\n ISessionStore,\n ListSessionEventsInput,\n ListSessionsInput,\n ListTurnEventsInput,\n ListTurnsInput,\n NewThreadInit,\n OverwriteThreadContextInput,\n PatchMCPServersInput,\n PatchSandboxInfoInput,\n PatchThreadCapabilityStateInput,\n RemoveThreadsInput,\n TurnContextAppend,\n TurnRecordWithoutSnapshot,\n UpdateSessionInput,\n UpdateTurnStateInput,\n} from './store/ISessionStore';\nexport {\n InvalidPageTokenError,\n PreviousTurnRunningError,\n SessionAlreadyExistsError,\n SessionNotFoundError,\n SessionStoreConflictError,\n SessionStoreInvariantError,\n SessionStoreNotFoundError,\n TurnAlreadyExistsError,\n TurnNotFoundError,\n TurnNotRunningError,\n} from './store/SessionStoreErrors';\n\nexport type { ITurnResourceResolver } from './ITurnResourceResolver';\nexport { TurnResourceResolver } from './TurnResourceResolver';\nexport type { TurnSandboxFactory } from './TurnResourceResolver';\n\nexport { SessionHandle } from './SessionHandle';\nexport { Sessions } from './Sessions';\nexport { TurnHandle } from './TurnHandle';\nexport type { TurnStreamingEvent } from './TurnHandle';\n"],"mappings":";AAKA,SAAS,iBAAiB,sCAAsC,2BAA2B;AAG3F;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,qBAAqB;AAG9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,SAAS,6BAA6B;AAItC,SAAS,sBAAsB;AAG/B,SAAS,mCAAmC;AAC5C,SAAS,4BAA4B;AA2BrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,4BAA4B;AAGrC,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;","names":[]}
1
+ {"version":3,"sources":["../../src/agent-session/index.ts"],"sourcesContent":["/**\n * Public agent session middle library.\n * Zod product contracts and session/turn runtime.\n */\n\nexport { AgentSpecSchema, DEFAULT_AGENT_CONFIG_ITERATION_LIMIT, RuntimeConfigSchema } from './schemas/agentSpec';\nexport type { AgentSpec, Skill } from './schemas/agentSpec';\n\nexport {\n CancellationReason,\n CreateTurnRequestSchema,\n TurnInputItemSchema,\n TurnMetricsSchema,\n TurnSchema,\n TurnStateCancelledReasonSchema,\n TurnStateCancelledSchema,\n TurnStateDoneSchema,\n TurnStateErrorSchema,\n TurnStateRunningSchema,\n TurnStateSchema,\n} from './schemas/turn';\nexport type { TerminalTurnState, Turn, TurnInputItem, TurnMetrics, TurnState } from './schemas/turn';\n\nexport {\n SessionMetadataSchema,\n SessionMetricsSchema,\n SessionSchema,\n SessionSourceScheduleSchema,\n SessionSourceSchema,\n SessionSourceTypeSchema,\n} from './schemas/session';\nexport type {\n Session,\n SessionAgent,\n SessionMetadata,\n SessionMetrics,\n SessionSource,\n SessionSourceType,\n} from './schemas/session';\n\nexport { CreatedBySubjectSchema } from './schemas/subject';\nexport type { CreatedBySubject } from './schemas/subject';\n\nexport {\n EventType,\n SessionEventItemSchema,\n SessionEventSchema,\n TurnCreatedEventSchema,\n TurnDoneEventSchema,\n} from './schemas/events';\nexport type {\n PersistedTurnEvent,\n SessionEvent,\n SessionEventItem,\n TurnCreatedEvent,\n TurnDoneEvent,\n} from './schemas/events';\n\nexport { TokenPaginationSchema } from './schemas/pagination';\nexport type { TokenPagination } from './schemas/pagination';\n\nexport type { SessionRecord } from './models/SessionRecord';\nexport { MAIN_THREAD_ID } from './models/TurnRecord';\nexport type { TurnRecord, TurnSnapshot } from './models/TurnRecord';\n\nexport { assertCreateTurnThreadDelta } from './store/assertCreateTurnThreadDelta';\nexport { InMemorySessionStore } from './store/InMemorySessionStore';\nexport type {\n AddThreadsInput,\n AppendToEventsInput,\n AppendToThreadContextInput,\n CreateSessionInput,\n CreateTurnInput,\n DeleteSessionInput,\n FreezeAndGetTurnInput,\n GetSessionByExternalIdInput,\n GetSessionInput,\n GetTurnInput,\n ISessionStore,\n ListSessionEventsInput,\n ListSessionsInput,\n ListTurnEventsInput,\n ListTurnsInput,\n NewThreadInit,\n OverwriteThreadContextInput,\n PatchMCPServersInput,\n PatchSandboxInfoInput,\n PatchThreadCapabilityStateInput,\n RemoveThreadsInput,\n TurnContextAppend,\n TurnRecordWithoutSnapshot,\n UpdateSessionInput,\n UpdateTurnStateInput,\n} from './store/ISessionStore';\nexport {\n InvalidPageTokenError,\n PreviousTurnRunningError,\n SessionAlreadyExistsError,\n SessionExternalIdConflictError,\n SessionNotFoundError,\n SessionStoreConflictError,\n SessionStoreInvariantError,\n SessionStoreNotFoundError,\n TurnAlreadyExistsError,\n TurnNotFoundError,\n TurnNotRunningError,\n} from './store/SessionStoreErrors';\n\nexport type { ITurnResourceResolver } from './ITurnResourceResolver';\nexport { TurnResourceResolver } from './TurnResourceResolver';\nexport type { TurnSandboxFactory } from './TurnResourceResolver';\n\nexport { SessionHandle } from './SessionHandle';\nexport { Sessions } from './Sessions';\nexport { TurnHandle } from './TurnHandle';\nexport type { TurnStreamingEvent } from './TurnHandle';\n"],"mappings":";AAKA,SAAS,iBAAiB,sCAAsC,2BAA2B;AAG3F;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUP,SAAS,8BAA8B;AAGvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,SAAS,6BAA6B;AAItC,SAAS,sBAAsB;AAG/B,SAAS,mCAAmC;AAC5C,SAAS,4BAA4B;AA4BrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,4BAA4B;AAGrC,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;","names":[]}
@@ -1,4 +1,5 @@
1
- import type { SessionAgent } from '../schemas/session';
1
+ import type { SessionAgent, SessionMetadata, SessionMetrics, SessionSource } from '../schemas/session';
2
+ import type { CreatedBySubject } from '../schemas/subject';
2
3
  /**
3
4
  * Session persistence record. Agent binding is a single discriminated `agent`
4
5
  * (`reference` | `inline`). Reference rows carry create-time `name` snapshot
@@ -8,13 +9,22 @@ export interface SessionRecord<TCustom extends object = Record<string, never>> {
8
9
  tenant_id: string;
9
10
  session_id: string;
10
11
  /** Caller identity that created the session (immutable after create). */
11
- created_by: string;
12
+ created_by_subject: CreatedBySubject;
12
13
  agent: SessionAgent;
13
14
  /**
14
15
  * Public session title (nullable). Written via updateSession patch or createTurn's
15
16
  * update_session_title_if_not_exist (first write wins; caller derives).
16
17
  */
17
18
  title: string | null;
19
+ /**
20
+ * Optional caller-supplied key, unique within a tenant when set.
21
+ * Null means the session has no external id.
22
+ */
23
+ external_id: string | null;
24
+ /**
25
+ * How the session was created. Null for interactive sessions.
26
+ */
27
+ source: SessionSource | null;
18
28
  /**
19
29
  * Session tip — used for `previous_turn_id: 'auto'` resolution and turn
20
30
  * listing anchors. Advanced only by `createTurn` (atomic link).
@@ -29,6 +39,8 @@ export interface SessionRecord<TCustom extends object = Record<string, never>> {
29
39
  * updateSession, and createTurn — never on reads.
30
40
  */
31
41
  last_activity_timestamp_ms: number;
42
+ metrics: SessionMetrics;
43
+ metadata: SessionMetadata;
32
44
  custom: TCustom | null;
33
45
  }
34
46
  //# sourceMappingURL=SessionRecord.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SessionRecord.d.ts","sourceRoot":"","sources":["../../../src/agent-session/models/SessionRecord.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,aAAa,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;IACpB;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,sFAAsF;IACtF,UAAU,EAAE,IAAI,CAAC;IACjB,2FAA2F;IAC3F,UAAU,EAAE,IAAI,CAAC;IACjB;;;OAGG;IACH,0BAA0B,EAAE,MAAM,CAAC;IACnC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACxB"}
1
+ {"version":3,"file":"SessionRecord.d.ts","sourceRoot":"","sources":["../../../src/agent-session/models/SessionRecord.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACvG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;GAIG;AACH,MAAM,WAAW,aAAa,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,kBAAkB,EAAE,gBAAgB,CAAC;IACrC,KAAK,EAAE,YAAY,CAAC;IACpB;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;OAGG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;OAEG;IACH,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,sFAAsF;IACtF,UAAU,EAAE,IAAI,CAAC;IACjB,2FAA2F;IAC3F,UAAU,EAAE,IAAI,CAAC;IACjB;;;OAGG;IACH,0BAA0B,EAAE,MAAM,CAAC;IACnC,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACxB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/agent-session/models/SessionRecord.ts"],"sourcesContent":["import type { SessionAgent } from '../schemas/session';\n\n/**\n * Session persistence record. Agent binding is a single discriminated `agent`\n * (`reference` | `inline`). Reference rows carry create-time `name` snapshot\n * (nullable for legacy/orphan). Named agents are not hydrated to inline on read.\n */\nexport interface SessionRecord<TCustom extends object = Record<string, never>> {\n tenant_id: string;\n session_id: string;\n /** Caller identity that created the session (immutable after create). */\n created_by: string;\n agent: SessionAgent;\n /**\n * Public session title (nullable). Written via updateSession patch or createTurn's\n * update_session_title_if_not_exist (first write wins; caller derives).\n */\n title: string | null;\n /**\n * Session tip — used for `previous_turn_id: 'auto'` resolution and turn\n * listing anchors. Advanced only by `createTurn` (atomic link).\n */\n last_turn_id: string | null;\n /** Instant the session was created (store domain). Wire/API serialize as ISO-8601. */\n created_at: Date;\n /** Instant the session was last updated (store domain). Wire/API serialize as ISO-8601. */\n updated_at: Date;\n /**\n * Liveness clock (ms since epoch). The store bumps it on createSession,\n * updateSession, and createTurn — never on reads.\n */\n last_activity_timestamp_ms: number;\n custom: TCustom | null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/agent-session/models/SessionRecord.ts"],"sourcesContent":["import type { SessionAgent, SessionMetadata, SessionMetrics, SessionSource } from '../schemas/session';\nimport type { CreatedBySubject } from '../schemas/subject';\n\n/**\n * Session persistence record. Agent binding is a single discriminated `agent`\n * (`reference` | `inline`). Reference rows carry create-time `name` snapshot\n * (nullable for legacy/orphan). Named agents are not hydrated to inline on read.\n */\nexport interface SessionRecord<TCustom extends object = Record<string, never>> {\n tenant_id: string;\n session_id: string;\n /** Caller identity that created the session (immutable after create). */\n created_by_subject: CreatedBySubject;\n agent: SessionAgent;\n /**\n * Public session title (nullable). Written via updateSession patch or createTurn's\n * update_session_title_if_not_exist (first write wins; caller derives).\n */\n title: string | null;\n /**\n * Optional caller-supplied key, unique within a tenant when set.\n * Null means the session has no external id.\n */\n external_id: string | null;\n /**\n * How the session was created. Null for interactive sessions.\n */\n source: SessionSource | null;\n /**\n * Session tip — used for `previous_turn_id: 'auto'` resolution and turn\n * listing anchors. Advanced only by `createTurn` (atomic link).\n */\n last_turn_id: string | null;\n /** Instant the session was created (store domain). Wire/API serialize as ISO-8601. */\n created_at: Date;\n /** Instant the session was last updated (store domain). Wire/API serialize as ISO-8601. */\n updated_at: Date;\n /**\n * Liveness clock (ms since epoch). The store bumps it on createSession,\n * updateSession, and createTurn — never on reads.\n */\n last_activity_timestamp_ms: number;\n metrics: SessionMetrics;\n metadata: SessionMetadata;\n custom: TCustom | null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -3,6 +3,13 @@
3
3
  * field (`reference` | `inline`). DB stores agent_id / agent_name / agent_spec columns.
4
4
  */
5
5
  import { z } from '@hono/zod-openapi';
6
+ export declare const SessionMetadataSchema: z.ZodRecord<z.ZodString, z.ZodString>;
7
+ export type SessionMetadata = z.infer<typeof SessionMetadataSchema>;
8
+ export declare const SessionMetricsSchema: z.ZodObject<{
9
+ total_cost_in_usd: z.ZodOptional<z.ZodNumber>;
10
+ total_duration_ms: z.ZodNumber;
11
+ total_turns: z.ZodNumber;
12
+ }, z.core.$strict>;
6
13
  export declare const SessionAgentReferenceSchema: z.ZodObject<{
7
14
  type: z.ZodLiteral<"reference">;
8
15
  id: z.ZodString;
@@ -185,6 +192,25 @@ export declare const SessionAgentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
185
192
  }, z.core.$strip>>;
186
193
  }, z.core.$strip>;
187
194
  }, z.core.$strict>], "type">;
195
+ export declare const SessionSourceTypeSchema: z.ZodEnum<{
196
+ schedule: "schedule";
197
+ }>;
198
+ export type SessionSourceType = z.infer<typeof SessionSourceTypeSchema>;
199
+ export declare const SessionSourceScheduleSchema: z.ZodObject<{
200
+ type: z.ZodLiteral<"schedule">;
201
+ id: z.ZodString;
202
+ run_id: z.ZodString;
203
+ }, z.core.$strict>;
204
+ /**
205
+ * How a session was created. Same shape as {@link SessionSourceScheduleSchema} today;
206
+ * switch to `discriminatedUnion('type', …)` when a second source arm lands.
207
+ */
208
+ export declare const SessionSourceSchema: z.ZodObject<{
209
+ type: z.ZodLiteral<"schedule">;
210
+ id: z.ZodString;
211
+ run_id: z.ZodString;
212
+ }, z.core.$strict>;
213
+ export type SessionSource = z.infer<typeof SessionSourceSchema>;
188
214
  export declare const SessionSchema: z.ZodObject<{
189
215
  id: z.ZodString;
190
216
  agent: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -278,12 +304,28 @@ export declare const SessionSchema: z.ZodObject<{
278
304
  }, z.core.$strip>;
279
305
  }, z.core.$strict>], "type">;
280
306
  title: z.ZodNullable<z.ZodString>;
281
- created_by: z.ZodString;
307
+ created_by_subject: z.ZodObject<{
308
+ subject_id: z.ZodString;
309
+ subject_type: z.ZodString;
310
+ subject_display_name: z.ZodString;
311
+ }, z.core.$strict>;
282
312
  created_at: z.ZodString;
283
313
  updated_at: z.ZodString;
314
+ metrics: z.ZodObject<{
315
+ total_cost_in_usd: z.ZodOptional<z.ZodNumber>;
316
+ total_duration_ms: z.ZodNumber;
317
+ total_turns: z.ZodNumber;
318
+ }, z.core.$strict>;
319
+ metadata: z.ZodRecord<z.ZodString, z.ZodString>;
320
+ source: z.ZodNullable<z.ZodObject<{
321
+ type: z.ZodLiteral<"schedule">;
322
+ id: z.ZodString;
323
+ run_id: z.ZodString;
324
+ }, z.core.$strict>>;
284
325
  }, z.core.$strip>;
285
326
  export type SessionAgentReference = z.infer<typeof SessionAgentReferenceSchema>;
286
327
  export type SessionAgentInline = z.infer<typeof SessionAgentInlineSchema>;
287
328
  export type SessionAgent = z.infer<typeof SessionAgentSchema>;
329
+ export type SessionMetrics = z.infer<typeof SessionMetricsSchema>;
288
330
  export type Session = z.infer<typeof SessionSchema>;
289
331
  //# sourceMappingURL=session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/agent-session/schemas/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAGtC,eAAO,MAAM,2BAA2B;;;;kBAWL,CAAC;AAEpC,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAML,CAAC;AAEjC,oEAAoE;AACpE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAEL,CAAC;AAE3B,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAUL,CAAC;AAEtB,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/agent-session/schemas/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAetC,eAAO,MAAM,qBAAqB,uCAiBL,CAAC;AAE9B,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,oBAAoB;;;;kBAQL,CAAC;AAE7B,eAAO,MAAM,2BAA2B;;;;kBAWL,CAAC;AAEpC,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAML,CAAC;AAEjC,oEAAoE;AACpE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAEL,CAAC;AAE3B,eAAO,MAAM,uBAAuB;;EAAoD,CAAC;AAEzF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAYxE,eAAO,MAAM,2BAA2B;;;;kBAAiE,CAAC;AAE1G;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;kBAEL,CAAC;AAE5B,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAYL,CAAC;AAEtB,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -23,11 +23,32 @@ __export(session_exports, {
23
23
  SessionAgentInlineSchema: () => SessionAgentInlineSchema,
24
24
  SessionAgentReferenceSchema: () => SessionAgentReferenceSchema,
25
25
  SessionAgentSchema: () => SessionAgentSchema,
26
- SessionSchema: () => SessionSchema
26
+ SessionMetadataSchema: () => SessionMetadataSchema,
27
+ SessionMetricsSchema: () => SessionMetricsSchema,
28
+ SessionSchema: () => SessionSchema,
29
+ SessionSourceScheduleSchema: () => SessionSourceScheduleSchema,
30
+ SessionSourceSchema: () => SessionSourceSchema,
31
+ SessionSourceTypeSchema: () => SessionSourceTypeSchema
27
32
  });
28
33
  module.exports = __toCommonJS(session_exports);
29
34
  var import_zod_openapi = require("@hono/zod-openapi");
30
35
  var import_agentSpec = require("./agentSpec.js");
36
+ var import_subject = require("./subject.js");
37
+ var SESSION_METADATA_MAX_KEY_LENGTH = 32;
38
+ var SESSION_METADATA_KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,31}$/;
39
+ var SESSION_METADATA_MAX_VALUE_LENGTH = 128;
40
+ var SESSION_METADATA_MAX_KEYS = 50;
41
+ var SessionMetadataSchema = import_zod_openapi.z.record(
42
+ import_zod_openapi.z.string().min(1).max(SESSION_METADATA_MAX_KEY_LENGTH).regex(SESSION_METADATA_KEY_PATTERN).describe(`Metadata key; 1\u2013${String(SESSION_METADATA_MAX_KEY_LENGTH)} characters.`),
43
+ import_zod_openapi.z.string().max(SESSION_METADATA_MAX_VALUE_LENGTH).describe(`Metadata value; at most ${String(SESSION_METADATA_MAX_VALUE_LENGTH)} characters.`)
44
+ ).refine((m) => Object.keys(m).length <= SESSION_METADATA_MAX_KEYS, {
45
+ message: `at most ${String(SESSION_METADATA_MAX_KEYS)} metadata keys`
46
+ }).describe("Caller-owned session metadata").openapi("SessionMetadata");
47
+ var SessionMetricsSchema = import_zod_openapi.z.object({
48
+ total_cost_in_usd: import_zod_openapi.z.number().nonnegative().optional().describe("Estimated total cost in USD for this session"),
49
+ total_duration_ms: import_zod_openapi.z.number().int().nonnegative(),
50
+ total_turns: import_zod_openapi.z.number().int().nonnegative()
51
+ }).strict().describe("Rolled-up cost, duration, and turn counters for a session.").openapi("SessionMetrics");
31
52
  var SessionAgentReferenceSchema = import_zod_openapi.z.object({
32
53
  type: import_zod_openapi.z.literal("reference").describe("Bind the session to a named registry agent."),
33
54
  id: import_zod_openapi.z.string().min(1).describe("Registry agent id."),
@@ -39,20 +60,37 @@ var SessionAgentInlineSchema = import_zod_openapi.z.object({
39
60
  spec: import_agentSpec.AgentSpecSchema
40
61
  }).strict().openapi("SessionAgentInline");
41
62
  var SessionAgentSchema = import_zod_openapi.z.discriminatedUnion("type", [SessionAgentReferenceSchema, SessionAgentInlineSchema]).openapi("SessionAgent");
63
+ var SessionSourceTypeSchema = import_zod_openapi.z.enum(["schedule"]).openapi("SessionSourceType");
64
+ function sessionSourceScheduleObject() {
65
+ return import_zod_openapi.z.object({
66
+ type: import_zod_openapi.z.literal(SessionSourceTypeSchema.enum.schedule).describe("Session was created by a schedule run."),
67
+ id: import_zod_openapi.z.string().min(1).describe("Schedule id."),
68
+ run_id: import_zod_openapi.z.string().min(1).describe("Schedule run id.")
69
+ }).strict();
70
+ }
71
+ var SessionSourceScheduleSchema = sessionSourceScheduleObject().openapi("SessionSourceSchedule");
72
+ var SessionSourceSchema = sessionSourceScheduleObject().describe("How this session was created (e.g. a schedule run). Null for interactive sessions.").openapi("SessionSource");
42
73
  var SessionSchema = import_zod_openapi.z.object({
43
74
  id: import_zod_openapi.z.string().describe("Unique session id."),
44
75
  agent: SessionAgentSchema,
45
76
  title: import_zod_openapi.z.string().nullable().describe("Optional human-readable title; null until set."),
46
- /** Caller identity that created the session (immutable). */
47
- created_by: import_zod_openapi.z.string().describe("Caller identity that created the session (immutable)."),
77
+ created_by_subject: import_subject.CreatedBySubjectSchema,
48
78
  created_at: import_zod_openapi.z.string().describe("ISO 8601 creation timestamp."),
49
- updated_at: import_zod_openapi.z.string().describe("ISO 8601 last-update timestamp.")
79
+ updated_at: import_zod_openapi.z.string().describe("ISO 8601 last-update timestamp."),
80
+ metrics: SessionMetricsSchema,
81
+ metadata: SessionMetadataSchema,
82
+ source: SessionSourceSchema.nullable()
50
83
  }).openapi("Session");
51
84
  // Annotate the CommonJS export names for ESM import in node:
52
85
  0 && (module.exports = {
53
86
  SessionAgentInlineSchema,
54
87
  SessionAgentReferenceSchema,
55
88
  SessionAgentSchema,
56
- SessionSchema
89
+ SessionMetadataSchema,
90
+ SessionMetricsSchema,
91
+ SessionSchema,
92
+ SessionSourceScheduleSchema,
93
+ SessionSourceSchema,
94
+ SessionSourceTypeSchema
57
95
  });
58
96
  //# sourceMappingURL=session.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/agent-session/schemas/session.ts"],"sourcesContent":["/**\n * Session product schemas. Agent binding is a single discriminated `agent`\n * field (`reference` | `inline`). DB stores agent_id / agent_name / agent_spec columns.\n */\nimport { z } from '@hono/zod-openapi';\nimport { AgentSpecSchema } from './agentSpec';\n\nexport const SessionAgentReferenceSchema = z\n .object({\n type: z.literal('reference').describe('Bind the session to a named registry agent.'),\n id: z.string().min(1).describe('Registry agent id.'),\n /** Create-time snapshot of the registry agent name; null for legacy/orphan rows. */\n name: z\n .string()\n .nullable()\n .describe('Create-time snapshot of the registry agent name; null for legacy or orphan rows.'),\n })\n .strict()\n .openapi('SessionAgentReference');\n\nexport const SessionAgentInlineSchema = z\n .object({\n type: z.literal('inline').describe('Bind the session to an inline AgentSpec (not a registry id).'),\n spec: AgentSpecSchema,\n })\n .strict()\n .openapi('SessionAgentInline');\n\n/** Named registry binding or inline AgentSpec — exactly one arm. */\nexport const SessionAgentSchema = z\n .discriminatedUnion('type', [SessionAgentReferenceSchema, SessionAgentInlineSchema])\n .openapi('SessionAgent');\n\nexport const SessionSchema = z\n .object({\n id: z.string().describe('Unique session id.'),\n agent: SessionAgentSchema,\n title: z.string().nullable().describe('Optional human-readable title; null until set.'),\n /** Caller identity that created the session (immutable). */\n created_by: z.string().describe('Caller identity that created the session (immutable).'),\n created_at: z.string().describe('ISO 8601 creation timestamp.'),\n updated_at: z.string().describe('ISO 8601 last-update timestamp.'),\n })\n .openapi('Session');\n\nexport type SessionAgentReference = z.infer<typeof SessionAgentReferenceSchema>;\nexport type SessionAgentInline = z.infer<typeof SessionAgentInlineSchema>;\nexport type SessionAgent = z.infer<typeof SessionAgentSchema>;\nexport type Session = z.infer<typeof SessionSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,yBAAkB;AAClB,uBAAgC;AAEzB,IAAM,8BAA8B,qBACxC,OAAO;AAAA,EACN,MAAM,qBAAE,QAAQ,WAAW,EAAE,SAAS,6CAA6C;AAAA,EACnF,IAAI,qBAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,oBAAoB;AAAA;AAAA,EAEnD,MAAM,qBACH,OAAO,EACP,SAAS,EACT,SAAS,kFAAkF;AAChG,CAAC,EACA,OAAO,EACP,QAAQ,uBAAuB;AAE3B,IAAM,2BAA2B,qBACrC,OAAO;AAAA,EACN,MAAM,qBAAE,QAAQ,QAAQ,EAAE,SAAS,8DAA8D;AAAA,EACjG,MAAM;AACR,CAAC,EACA,OAAO,EACP,QAAQ,oBAAoB;AAGxB,IAAM,qBAAqB,qBAC/B,mBAAmB,QAAQ,CAAC,6BAA6B,wBAAwB,CAAC,EAClF,QAAQ,cAAc;AAElB,IAAM,gBAAgB,qBAC1B,OAAO;AAAA,EACN,IAAI,qBAAE,OAAO,EAAE,SAAS,oBAAoB;AAAA,EAC5C,OAAO;AAAA,EACP,OAAO,qBAAE,OAAO,EAAE,SAAS,EAAE,SAAS,gDAAgD;AAAA;AAAA,EAEtF,YAAY,qBAAE,OAAO,EAAE,SAAS,uDAAuD;AAAA,EACvF,YAAY,qBAAE,OAAO,EAAE,SAAS,8BAA8B;AAAA,EAC9D,YAAY,qBAAE,OAAO,EAAE,SAAS,iCAAiC;AACnE,CAAC,EACA,QAAQ,SAAS;","names":[]}
1
+ {"version":3,"sources":["../../../src/agent-session/schemas/session.ts"],"sourcesContent":["/**\n * Session product schemas. Agent binding is a single discriminated `agent`\n * field (`reference` | `inline`). DB stores agent_id / agent_name / agent_spec columns.\n */\nimport { z } from '@hono/zod-openapi';\nimport { AgentSpecSchema } from './agentSpec';\nimport { CreatedBySubjectSchema } from './subject';\n\nconst SESSION_METADATA_MAX_KEY_LENGTH = 32;\n/**\n * Metadata keys: alphanumeric start; then alphanumeric, `.`, `_`, `:`, `-`.\n * Bans `[]` (collide with deepObject / reserved `metadata[key][op]`) and whitespace.\n */\nconst SESSION_METADATA_KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,31}$/;\n/** Max value length for session metadata */\nconst SESSION_METADATA_MAX_VALUE_LENGTH = 128;\n/** Max number of keys in session metadata. */\nconst SESSION_METADATA_MAX_KEYS = 50;\n\nexport const SessionMetadataSchema = z\n .record(\n z\n .string()\n .min(1)\n .max(SESSION_METADATA_MAX_KEY_LENGTH)\n .regex(SESSION_METADATA_KEY_PATTERN)\n .describe(`Metadata key; 1–${String(SESSION_METADATA_MAX_KEY_LENGTH)} characters.`),\n z\n .string()\n .max(SESSION_METADATA_MAX_VALUE_LENGTH)\n .describe(`Metadata value; at most ${String(SESSION_METADATA_MAX_VALUE_LENGTH)} characters.`),\n )\n .refine(m => Object.keys(m).length <= SESSION_METADATA_MAX_KEYS, {\n message: `at most ${String(SESSION_METADATA_MAX_KEYS)} metadata keys`,\n })\n .describe('Caller-owned session metadata')\n .openapi('SessionMetadata');\n\nexport type SessionMetadata = z.infer<typeof SessionMetadataSchema>;\n\nexport const SessionMetricsSchema = z\n .object({\n total_cost_in_usd: z.number().nonnegative().optional().describe('Estimated total cost in USD for this session'),\n total_duration_ms: z.number().int().nonnegative(),\n total_turns: z.number().int().nonnegative(),\n })\n .strict()\n .describe('Rolled-up cost, duration, and turn counters for a session.')\n .openapi('SessionMetrics');\n\nexport const SessionAgentReferenceSchema = z\n .object({\n type: z.literal('reference').describe('Bind the session to a named registry agent.'),\n id: z.string().min(1).describe('Registry agent id.'),\n /** Create-time snapshot of the registry agent name; null for legacy/orphan rows. */\n name: z\n .string()\n .nullable()\n .describe('Create-time snapshot of the registry agent name; null for legacy or orphan rows.'),\n })\n .strict()\n .openapi('SessionAgentReference');\n\nexport const SessionAgentInlineSchema = z\n .object({\n type: z.literal('inline').describe('Bind the session to an inline AgentSpec (not a registry id).'),\n spec: AgentSpecSchema,\n })\n .strict()\n .openapi('SessionAgentInline');\n\n/** Named registry binding or inline AgentSpec — exactly one arm. */\nexport const SessionAgentSchema = z\n .discriminatedUnion('type', [SessionAgentReferenceSchema, SessionAgentInlineSchema])\n .openapi('SessionAgent');\n\nexport const SessionSourceTypeSchema = z.enum(['schedule']).openapi('SessionSourceType');\n\nexport type SessionSourceType = z.infer<typeof SessionSourceTypeSchema>;\n\nfunction sessionSourceScheduleObject() {\n return z\n .object({\n type: z.literal(SessionSourceTypeSchema.enum.schedule).describe('Session was created by a schedule run.'),\n id: z.string().min(1).describe('Schedule id.'),\n run_id: z.string().min(1).describe('Schedule run id.'),\n })\n .strict();\n}\n\nexport const SessionSourceScheduleSchema = sessionSourceScheduleObject().openapi('SessionSourceSchedule');\n\n/**\n * How a session was created. Same shape as {@link SessionSourceScheduleSchema} today;\n * switch to `discriminatedUnion('type', …)` when a second source arm lands.\n */\nexport const SessionSourceSchema = sessionSourceScheduleObject()\n .describe('How this session was created (e.g. a schedule run). Null for interactive sessions.')\n .openapi('SessionSource');\n\nexport type SessionSource = z.infer<typeof SessionSourceSchema>;\n\nexport const SessionSchema = z\n .object({\n id: z.string().describe('Unique session id.'),\n agent: SessionAgentSchema,\n title: z.string().nullable().describe('Optional human-readable title; null until set.'),\n created_by_subject: CreatedBySubjectSchema,\n created_at: z.string().describe('ISO 8601 creation timestamp.'),\n updated_at: z.string().describe('ISO 8601 last-update timestamp.'),\n metrics: SessionMetricsSchema,\n metadata: SessionMetadataSchema,\n source: SessionSourceSchema.nullable(),\n })\n .openapi('Session');\n\nexport type SessionAgentReference = z.infer<typeof SessionAgentReferenceSchema>;\nexport type SessionAgentInline = z.infer<typeof SessionAgentInlineSchema>;\nexport type SessionAgent = z.infer<typeof SessionAgentSchema>;\nexport type SessionMetrics = z.infer<typeof SessionMetricsSchema>;\nexport type Session = z.infer<typeof SessionSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,yBAAkB;AAClB,uBAAgC;AAChC,qBAAuC;AAEvC,IAAM,kCAAkC;AAKxC,IAAM,+BAA+B;AAErC,IAAM,oCAAoC;AAE1C,IAAM,4BAA4B;AAE3B,IAAM,wBAAwB,qBAClC;AAAA,EACC,qBACG,OAAO,EACP,IAAI,CAAC,EACL,IAAI,+BAA+B,EACnC,MAAM,4BAA4B,EAClC,SAAS,wBAAmB,OAAO,+BAA+B,CAAC,cAAc;AAAA,EACpF,qBACG,OAAO,EACP,IAAI,iCAAiC,EACrC,SAAS,2BAA2B,OAAO,iCAAiC,CAAC,cAAc;AAChG,EACC,OAAO,OAAK,OAAO,KAAK,CAAC,EAAE,UAAU,2BAA2B;AAAA,EAC/D,SAAS,WAAW,OAAO,yBAAyB,CAAC;AACvD,CAAC,EACA,SAAS,+BAA+B,EACxC,QAAQ,iBAAiB;AAIrB,IAAM,uBAAuB,qBACjC,OAAO;AAAA,EACN,mBAAmB,qBAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,8CAA8C;AAAA,EAC9G,mBAAmB,qBAAE,OAAO,EAAE,IAAI,EAAE,YAAY;AAAA,EAChD,aAAa,qBAAE,OAAO,EAAE,IAAI,EAAE,YAAY;AAC5C,CAAC,EACA,OAAO,EACP,SAAS,4DAA4D,EACrE,QAAQ,gBAAgB;AAEpB,IAAM,8BAA8B,qBACxC,OAAO;AAAA,EACN,MAAM,qBAAE,QAAQ,WAAW,EAAE,SAAS,6CAA6C;AAAA,EACnF,IAAI,qBAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,oBAAoB;AAAA;AAAA,EAEnD,MAAM,qBACH,OAAO,EACP,SAAS,EACT,SAAS,kFAAkF;AAChG,CAAC,EACA,OAAO,EACP,QAAQ,uBAAuB;AAE3B,IAAM,2BAA2B,qBACrC,OAAO;AAAA,EACN,MAAM,qBAAE,QAAQ,QAAQ,EAAE,SAAS,8DAA8D;AAAA,EACjG,MAAM;AACR,CAAC,EACA,OAAO,EACP,QAAQ,oBAAoB;AAGxB,IAAM,qBAAqB,qBAC/B,mBAAmB,QAAQ,CAAC,6BAA6B,wBAAwB,CAAC,EAClF,QAAQ,cAAc;AAElB,IAAM,0BAA0B,qBAAE,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,mBAAmB;AAIvF,SAAS,8BAA8B;AACrC,SAAO,qBACJ,OAAO;AAAA,IACN,MAAM,qBAAE,QAAQ,wBAAwB,KAAK,QAAQ,EAAE,SAAS,wCAAwC;AAAA,IACxG,IAAI,qBAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,cAAc;AAAA,IAC7C,QAAQ,qBAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,kBAAkB;AAAA,EACvD,CAAC,EACA,OAAO;AACZ;AAEO,IAAM,8BAA8B,4BAA4B,EAAE,QAAQ,uBAAuB;AAMjG,IAAM,sBAAsB,4BAA4B,EAC5D,SAAS,oFAAoF,EAC7F,QAAQ,eAAe;AAInB,IAAM,gBAAgB,qBAC1B,OAAO;AAAA,EACN,IAAI,qBAAE,OAAO,EAAE,SAAS,oBAAoB;AAAA,EAC5C,OAAO;AAAA,EACP,OAAO,qBAAE,OAAO,EAAE,SAAS,EAAE,SAAS,gDAAgD;AAAA,EACtF,oBAAoB;AAAA,EACpB,YAAY,qBAAE,OAAO,EAAE,SAAS,8BAA8B;AAAA,EAC9D,YAAY,qBAAE,OAAO,EAAE,SAAS,iCAAiC;AAAA,EACjE,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ,oBAAoB,SAAS;AACvC,CAAC,EACA,QAAQ,SAAS;","names":[]}
@@ -1,6 +1,22 @@
1
1
  // src/agent-session/schemas/session.ts
2
2
  import { z } from "@hono/zod-openapi";
3
3
  import { AgentSpecSchema } from "./agentSpec.mjs";
4
+ import { CreatedBySubjectSchema } from "./subject.mjs";
5
+ var SESSION_METADATA_MAX_KEY_LENGTH = 32;
6
+ var SESSION_METADATA_KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,31}$/;
7
+ var SESSION_METADATA_MAX_VALUE_LENGTH = 128;
8
+ var SESSION_METADATA_MAX_KEYS = 50;
9
+ var SessionMetadataSchema = z.record(
10
+ z.string().min(1).max(SESSION_METADATA_MAX_KEY_LENGTH).regex(SESSION_METADATA_KEY_PATTERN).describe(`Metadata key; 1\u2013${String(SESSION_METADATA_MAX_KEY_LENGTH)} characters.`),
11
+ z.string().max(SESSION_METADATA_MAX_VALUE_LENGTH).describe(`Metadata value; at most ${String(SESSION_METADATA_MAX_VALUE_LENGTH)} characters.`)
12
+ ).refine((m) => Object.keys(m).length <= SESSION_METADATA_MAX_KEYS, {
13
+ message: `at most ${String(SESSION_METADATA_MAX_KEYS)} metadata keys`
14
+ }).describe("Caller-owned session metadata").openapi("SessionMetadata");
15
+ var SessionMetricsSchema = z.object({
16
+ total_cost_in_usd: z.number().nonnegative().optional().describe("Estimated total cost in USD for this session"),
17
+ total_duration_ms: z.number().int().nonnegative(),
18
+ total_turns: z.number().int().nonnegative()
19
+ }).strict().describe("Rolled-up cost, duration, and turn counters for a session.").openapi("SessionMetrics");
4
20
  var SessionAgentReferenceSchema = z.object({
5
21
  type: z.literal("reference").describe("Bind the session to a named registry agent."),
6
22
  id: z.string().min(1).describe("Registry agent id."),
@@ -12,19 +28,36 @@ var SessionAgentInlineSchema = z.object({
12
28
  spec: AgentSpecSchema
13
29
  }).strict().openapi("SessionAgentInline");
14
30
  var SessionAgentSchema = z.discriminatedUnion("type", [SessionAgentReferenceSchema, SessionAgentInlineSchema]).openapi("SessionAgent");
31
+ var SessionSourceTypeSchema = z.enum(["schedule"]).openapi("SessionSourceType");
32
+ function sessionSourceScheduleObject() {
33
+ return z.object({
34
+ type: z.literal(SessionSourceTypeSchema.enum.schedule).describe("Session was created by a schedule run."),
35
+ id: z.string().min(1).describe("Schedule id."),
36
+ run_id: z.string().min(1).describe("Schedule run id.")
37
+ }).strict();
38
+ }
39
+ var SessionSourceScheduleSchema = sessionSourceScheduleObject().openapi("SessionSourceSchedule");
40
+ var SessionSourceSchema = sessionSourceScheduleObject().describe("How this session was created (e.g. a schedule run). Null for interactive sessions.").openapi("SessionSource");
15
41
  var SessionSchema = z.object({
16
42
  id: z.string().describe("Unique session id."),
17
43
  agent: SessionAgentSchema,
18
44
  title: z.string().nullable().describe("Optional human-readable title; null until set."),
19
- /** Caller identity that created the session (immutable). */
20
- created_by: z.string().describe("Caller identity that created the session (immutable)."),
45
+ created_by_subject: CreatedBySubjectSchema,
21
46
  created_at: z.string().describe("ISO 8601 creation timestamp."),
22
- updated_at: z.string().describe("ISO 8601 last-update timestamp.")
47
+ updated_at: z.string().describe("ISO 8601 last-update timestamp."),
48
+ metrics: SessionMetricsSchema,
49
+ metadata: SessionMetadataSchema,
50
+ source: SessionSourceSchema.nullable()
23
51
  }).openapi("Session");
24
52
  export {
25
53
  SessionAgentInlineSchema,
26
54
  SessionAgentReferenceSchema,
27
55
  SessionAgentSchema,
28
- SessionSchema
56
+ SessionMetadataSchema,
57
+ SessionMetricsSchema,
58
+ SessionSchema,
59
+ SessionSourceScheduleSchema,
60
+ SessionSourceSchema,
61
+ SessionSourceTypeSchema
29
62
  };
30
63
  //# sourceMappingURL=session.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/agent-session/schemas/session.ts"],"sourcesContent":["/**\n * Session product schemas. Agent binding is a single discriminated `agent`\n * field (`reference` | `inline`). DB stores agent_id / agent_name / agent_spec columns.\n */\nimport { z } from '@hono/zod-openapi';\nimport { AgentSpecSchema } from './agentSpec';\n\nexport const SessionAgentReferenceSchema = z\n .object({\n type: z.literal('reference').describe('Bind the session to a named registry agent.'),\n id: z.string().min(1).describe('Registry agent id.'),\n /** Create-time snapshot of the registry agent name; null for legacy/orphan rows. */\n name: z\n .string()\n .nullable()\n .describe('Create-time snapshot of the registry agent name; null for legacy or orphan rows.'),\n })\n .strict()\n .openapi('SessionAgentReference');\n\nexport const SessionAgentInlineSchema = z\n .object({\n type: z.literal('inline').describe('Bind the session to an inline AgentSpec (not a registry id).'),\n spec: AgentSpecSchema,\n })\n .strict()\n .openapi('SessionAgentInline');\n\n/** Named registry binding or inline AgentSpec — exactly one arm. */\nexport const SessionAgentSchema = z\n .discriminatedUnion('type', [SessionAgentReferenceSchema, SessionAgentInlineSchema])\n .openapi('SessionAgent');\n\nexport const SessionSchema = z\n .object({\n id: z.string().describe('Unique session id.'),\n agent: SessionAgentSchema,\n title: z.string().nullable().describe('Optional human-readable title; null until set.'),\n /** Caller identity that created the session (immutable). */\n created_by: z.string().describe('Caller identity that created the session (immutable).'),\n created_at: z.string().describe('ISO 8601 creation timestamp.'),\n updated_at: z.string().describe('ISO 8601 last-update timestamp.'),\n })\n .openapi('Session');\n\nexport type SessionAgentReference = z.infer<typeof SessionAgentReferenceSchema>;\nexport type SessionAgentInline = z.infer<typeof SessionAgentInlineSchema>;\nexport type SessionAgent = z.infer<typeof SessionAgentSchema>;\nexport type Session = z.infer<typeof SessionSchema>;\n"],"mappings":";AAIA,SAAS,SAAS;AAClB,SAAS,uBAAuB;AAEzB,IAAM,8BAA8B,EACxC,OAAO;AAAA,EACN,MAAM,EAAE,QAAQ,WAAW,EAAE,SAAS,6CAA6C;AAAA,EACnF,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,oBAAoB;AAAA;AAAA,EAEnD,MAAM,EACH,OAAO,EACP,SAAS,EACT,SAAS,kFAAkF;AAChG,CAAC,EACA,OAAO,EACP,QAAQ,uBAAuB;AAE3B,IAAM,2BAA2B,EACrC,OAAO;AAAA,EACN,MAAM,EAAE,QAAQ,QAAQ,EAAE,SAAS,8DAA8D;AAAA,EACjG,MAAM;AACR,CAAC,EACA,OAAO,EACP,QAAQ,oBAAoB;AAGxB,IAAM,qBAAqB,EAC/B,mBAAmB,QAAQ,CAAC,6BAA6B,wBAAwB,CAAC,EAClF,QAAQ,cAAc;AAElB,IAAM,gBAAgB,EAC1B,OAAO;AAAA,EACN,IAAI,EAAE,OAAO,EAAE,SAAS,oBAAoB;AAAA,EAC5C,OAAO;AAAA,EACP,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,gDAAgD;AAAA;AAAA,EAEtF,YAAY,EAAE,OAAO,EAAE,SAAS,uDAAuD;AAAA,EACvF,YAAY,EAAE,OAAO,EAAE,SAAS,8BAA8B;AAAA,EAC9D,YAAY,EAAE,OAAO,EAAE,SAAS,iCAAiC;AACnE,CAAC,EACA,QAAQ,SAAS;","names":[]}
1
+ {"version":3,"sources":["../../../src/agent-session/schemas/session.ts"],"sourcesContent":["/**\n * Session product schemas. Agent binding is a single discriminated `agent`\n * field (`reference` | `inline`). DB stores agent_id / agent_name / agent_spec columns.\n */\nimport { z } from '@hono/zod-openapi';\nimport { AgentSpecSchema } from './agentSpec';\nimport { CreatedBySubjectSchema } from './subject';\n\nconst SESSION_METADATA_MAX_KEY_LENGTH = 32;\n/**\n * Metadata keys: alphanumeric start; then alphanumeric, `.`, `_`, `:`, `-`.\n * Bans `[]` (collide with deepObject / reserved `metadata[key][op]`) and whitespace.\n */\nconst SESSION_METADATA_KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,31}$/;\n/** Max value length for session metadata */\nconst SESSION_METADATA_MAX_VALUE_LENGTH = 128;\n/** Max number of keys in session metadata. */\nconst SESSION_METADATA_MAX_KEYS = 50;\n\nexport const SessionMetadataSchema = z\n .record(\n z\n .string()\n .min(1)\n .max(SESSION_METADATA_MAX_KEY_LENGTH)\n .regex(SESSION_METADATA_KEY_PATTERN)\n .describe(`Metadata key; 1–${String(SESSION_METADATA_MAX_KEY_LENGTH)} characters.`),\n z\n .string()\n .max(SESSION_METADATA_MAX_VALUE_LENGTH)\n .describe(`Metadata value; at most ${String(SESSION_METADATA_MAX_VALUE_LENGTH)} characters.`),\n )\n .refine(m => Object.keys(m).length <= SESSION_METADATA_MAX_KEYS, {\n message: `at most ${String(SESSION_METADATA_MAX_KEYS)} metadata keys`,\n })\n .describe('Caller-owned session metadata')\n .openapi('SessionMetadata');\n\nexport type SessionMetadata = z.infer<typeof SessionMetadataSchema>;\n\nexport const SessionMetricsSchema = z\n .object({\n total_cost_in_usd: z.number().nonnegative().optional().describe('Estimated total cost in USD for this session'),\n total_duration_ms: z.number().int().nonnegative(),\n total_turns: z.number().int().nonnegative(),\n })\n .strict()\n .describe('Rolled-up cost, duration, and turn counters for a session.')\n .openapi('SessionMetrics');\n\nexport const SessionAgentReferenceSchema = z\n .object({\n type: z.literal('reference').describe('Bind the session to a named registry agent.'),\n id: z.string().min(1).describe('Registry agent id.'),\n /** Create-time snapshot of the registry agent name; null for legacy/orphan rows. */\n name: z\n .string()\n .nullable()\n .describe('Create-time snapshot of the registry agent name; null for legacy or orphan rows.'),\n })\n .strict()\n .openapi('SessionAgentReference');\n\nexport const SessionAgentInlineSchema = z\n .object({\n type: z.literal('inline').describe('Bind the session to an inline AgentSpec (not a registry id).'),\n spec: AgentSpecSchema,\n })\n .strict()\n .openapi('SessionAgentInline');\n\n/** Named registry binding or inline AgentSpec — exactly one arm. */\nexport const SessionAgentSchema = z\n .discriminatedUnion('type', [SessionAgentReferenceSchema, SessionAgentInlineSchema])\n .openapi('SessionAgent');\n\nexport const SessionSourceTypeSchema = z.enum(['schedule']).openapi('SessionSourceType');\n\nexport type SessionSourceType = z.infer<typeof SessionSourceTypeSchema>;\n\nfunction sessionSourceScheduleObject() {\n return z\n .object({\n type: z.literal(SessionSourceTypeSchema.enum.schedule).describe('Session was created by a schedule run.'),\n id: z.string().min(1).describe('Schedule id.'),\n run_id: z.string().min(1).describe('Schedule run id.'),\n })\n .strict();\n}\n\nexport const SessionSourceScheduleSchema = sessionSourceScheduleObject().openapi('SessionSourceSchedule');\n\n/**\n * How a session was created. Same shape as {@link SessionSourceScheduleSchema} today;\n * switch to `discriminatedUnion('type', …)` when a second source arm lands.\n */\nexport const SessionSourceSchema = sessionSourceScheduleObject()\n .describe('How this session was created (e.g. a schedule run). Null for interactive sessions.')\n .openapi('SessionSource');\n\nexport type SessionSource = z.infer<typeof SessionSourceSchema>;\n\nexport const SessionSchema = z\n .object({\n id: z.string().describe('Unique session id.'),\n agent: SessionAgentSchema,\n title: z.string().nullable().describe('Optional human-readable title; null until set.'),\n created_by_subject: CreatedBySubjectSchema,\n created_at: z.string().describe('ISO 8601 creation timestamp.'),\n updated_at: z.string().describe('ISO 8601 last-update timestamp.'),\n metrics: SessionMetricsSchema,\n metadata: SessionMetadataSchema,\n source: SessionSourceSchema.nullable(),\n })\n .openapi('Session');\n\nexport type SessionAgentReference = z.infer<typeof SessionAgentReferenceSchema>;\nexport type SessionAgentInline = z.infer<typeof SessionAgentInlineSchema>;\nexport type SessionAgent = z.infer<typeof SessionAgentSchema>;\nexport type SessionMetrics = z.infer<typeof SessionMetricsSchema>;\nexport type Session = z.infer<typeof SessionSchema>;\n"],"mappings":";AAIA,SAAS,SAAS;AAClB,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AAEvC,IAAM,kCAAkC;AAKxC,IAAM,+BAA+B;AAErC,IAAM,oCAAoC;AAE1C,IAAM,4BAA4B;AAE3B,IAAM,wBAAwB,EAClC;AAAA,EACC,EACG,OAAO,EACP,IAAI,CAAC,EACL,IAAI,+BAA+B,EACnC,MAAM,4BAA4B,EAClC,SAAS,wBAAmB,OAAO,+BAA+B,CAAC,cAAc;AAAA,EACpF,EACG,OAAO,EACP,IAAI,iCAAiC,EACrC,SAAS,2BAA2B,OAAO,iCAAiC,CAAC,cAAc;AAChG,EACC,OAAO,OAAK,OAAO,KAAK,CAAC,EAAE,UAAU,2BAA2B;AAAA,EAC/D,SAAS,WAAW,OAAO,yBAAyB,CAAC;AACvD,CAAC,EACA,SAAS,+BAA+B,EACxC,QAAQ,iBAAiB;AAIrB,IAAM,uBAAuB,EACjC,OAAO;AAAA,EACN,mBAAmB,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,8CAA8C;AAAA,EAC9G,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY;AAAA,EAChD,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY;AAC5C,CAAC,EACA,OAAO,EACP,SAAS,4DAA4D,EACrE,QAAQ,gBAAgB;AAEpB,IAAM,8BAA8B,EACxC,OAAO;AAAA,EACN,MAAM,EAAE,QAAQ,WAAW,EAAE,SAAS,6CAA6C;AAAA,EACnF,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,oBAAoB;AAAA;AAAA,EAEnD,MAAM,EACH,OAAO,EACP,SAAS,EACT,SAAS,kFAAkF;AAChG,CAAC,EACA,OAAO,EACP,QAAQ,uBAAuB;AAE3B,IAAM,2BAA2B,EACrC,OAAO;AAAA,EACN,MAAM,EAAE,QAAQ,QAAQ,EAAE,SAAS,8DAA8D;AAAA,EACjG,MAAM;AACR,CAAC,EACA,OAAO,EACP,QAAQ,oBAAoB;AAGxB,IAAM,qBAAqB,EAC/B,mBAAmB,QAAQ,CAAC,6BAA6B,wBAAwB,CAAC,EAClF,QAAQ,cAAc;AAElB,IAAM,0BAA0B,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,mBAAmB;AAIvF,SAAS,8BAA8B;AACrC,SAAO,EACJ,OAAO;AAAA,IACN,MAAM,EAAE,QAAQ,wBAAwB,KAAK,QAAQ,EAAE,SAAS,wCAAwC;AAAA,IACxG,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,cAAc;AAAA,IAC7C,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,kBAAkB;AAAA,EACvD,CAAC,EACA,OAAO;AACZ;AAEO,IAAM,8BAA8B,4BAA4B,EAAE,QAAQ,uBAAuB;AAMjG,IAAM,sBAAsB,4BAA4B,EAC5D,SAAS,oFAAoF,EAC7F,QAAQ,eAAe;AAInB,IAAM,gBAAgB,EAC1B,OAAO;AAAA,EACN,IAAI,EAAE,OAAO,EAAE,SAAS,oBAAoB;AAAA,EAC5C,OAAO;AAAA,EACP,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,gDAAgD;AAAA,EACtF,oBAAoB;AAAA,EACpB,YAAY,EAAE,OAAO,EAAE,SAAS,8BAA8B;AAAA,EAC9D,YAAY,EAAE,OAAO,EAAE,SAAS,iCAAiC;AAAA,EACjE,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ,oBAAoB,SAAS;AACvC,CAAC,EACA,QAAQ,SAAS;","names":[]}
@@ -0,0 +1,9 @@
1
+ import { z } from '@hono/zod-openapi';
2
+ /** Persisted creator identity on agent, session, schedule, and schedule_run rows. */
3
+ export declare const CreatedBySubjectSchema: z.ZodObject<{
4
+ subject_id: z.ZodString;
5
+ subject_type: z.ZodString;
6
+ subject_display_name: z.ZodString;
7
+ }, z.core.$strict>;
8
+ export type CreatedBySubject = z.infer<typeof CreatedBySubjectSchema>;
9
+ //# sourceMappingURL=subject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subject.d.ts","sourceRoot":"","sources":["../../../src/agent-session/schemas/subject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,qFAAqF;AACrF,eAAO,MAAM,sBAAsB;;;;kBAQL,CAAC;AAE/B,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/agent-session/schemas/subject.ts
21
+ var subject_exports = {};
22
+ __export(subject_exports, {
23
+ CreatedBySubjectSchema: () => CreatedBySubjectSchema
24
+ });
25
+ module.exports = __toCommonJS(subject_exports);
26
+ var import_zod_openapi = require("@hono/zod-openapi");
27
+ var CreatedBySubjectSchema = import_zod_openapi.z.object({
28
+ subject_id: import_zod_openapi.z.string().min(1).describe("Subject id."),
29
+ subject_type: import_zod_openapi.z.string().min(1).describe("Subject type."),
30
+ subject_display_name: import_zod_openapi.z.string().min(1).describe("Display name.")
31
+ }).strict().describe("Who created this resource.").openapi("CreatedBySubject");
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ CreatedBySubjectSchema
35
+ });
36
+ //# sourceMappingURL=subject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/agent-session/schemas/subject.ts"],"sourcesContent":["import { z } from '@hono/zod-openapi';\n\n/** Persisted creator identity on agent, session, schedule, and schedule_run rows. */\nexport const CreatedBySubjectSchema = z\n .object({\n subject_id: z.string().min(1).describe('Subject id.'),\n subject_type: z.string().min(1).describe('Subject type.'),\n subject_display_name: z.string().min(1).describe('Display name.'),\n })\n .strict()\n .describe('Who created this resource.')\n .openapi('CreatedBySubject');\n\nexport type CreatedBySubject = z.infer<typeof CreatedBySubjectSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAkB;AAGX,IAAM,yBAAyB,qBACnC,OAAO;AAAA,EACN,YAAY,qBAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,aAAa;AAAA,EACpD,cAAc,qBAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,eAAe;AAAA,EACxD,sBAAsB,qBAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,eAAe;AAClE,CAAC,EACA,OAAO,EACP,SAAS,4BAA4B,EACrC,QAAQ,kBAAkB;","names":[]}
@@ -0,0 +1,11 @@
1
+ // src/agent-session/schemas/subject.ts
2
+ import { z } from "@hono/zod-openapi";
3
+ var CreatedBySubjectSchema = z.object({
4
+ subject_id: z.string().min(1).describe("Subject id."),
5
+ subject_type: z.string().min(1).describe("Subject type."),
6
+ subject_display_name: z.string().min(1).describe("Display name.")
7
+ }).strict().describe("Who created this resource.").openapi("CreatedBySubject");
8
+ export {
9
+ CreatedBySubjectSchema
10
+ };
11
+ //# sourceMappingURL=subject.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/agent-session/schemas/subject.ts"],"sourcesContent":["import { z } from '@hono/zod-openapi';\n\n/** Persisted creator identity on agent, session, schedule, and schedule_run rows. */\nexport const CreatedBySubjectSchema = z\n .object({\n subject_id: z.string().min(1).describe('Subject id.'),\n subject_type: z.string().min(1).describe('Subject type.'),\n subject_display_name: z.string().min(1).describe('Display name.'),\n })\n .strict()\n .describe('Who created this resource.')\n .openapi('CreatedBySubject');\n\nexport type CreatedBySubject = z.infer<typeof CreatedBySubjectSchema>;\n"],"mappings":";AAAA,SAAS,SAAS;AAGX,IAAM,yBAAyB,EACnC,OAAO;AAAA,EACN,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,aAAa;AAAA,EACpD,cAAc,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,eAAe;AAAA,EACxD,sBAAsB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,eAAe;AAClE,CAAC,EACA,OAAO,EACP,SAAS,4BAA4B,EACrC,QAAQ,kBAAkB;","names":[]}