@sudobility/screenwriter_types 0.1.2 → 0.1.4

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.
@@ -69,6 +69,10 @@ export declare const API_ROUTES: {
69
69
  readonly apiKeyUpdate: RouteSpec;
70
70
  readonly apiKeyRevoke: RouteSpec;
71
71
  readonly aiStatus: RouteSpec;
72
+ readonly aiGenerateCharacterSkeleton: RouteSpec;
73
+ readonly aiGenerateScript: RouteSpec;
74
+ readonly aiPolishCharacterDialogue: RouteSpec;
75
+ readonly aiPolishScene: RouteSpec;
72
76
  readonly aiJobCreate: RouteSpec;
73
77
  readonly aiJobsList: RouteSpec;
74
78
  readonly aiJobGet: RouteSpec;
package/dist/index.d.ts CHANGED
@@ -20,6 +20,7 @@ export * from './formats/index.js';
20
20
  export * from './io/index.js';
21
21
  export * from './keys/index.js';
22
22
  export * from './ai/index.js';
23
+ export * from './ai/actions.js';
23
24
  export * from './jobs/index.js';
24
25
  export * from './reads/index.js';
25
26
  export * from './reports/index.js';
package/dist/index.js CHANGED
@@ -337,6 +337,15 @@ const API_ROUTES = {
337
337
  // B7 AI: script review and polish. Keys need the `ai` flag (403 AI_KEY_NOT_PERMITTED) and, to start
338
338
  // jobs or decide suggestions, read_write scope.
339
339
  aiStatus: r("GET", "/ai/status", "U,Kr"),
340
+ // Synchronous AI actions (`ai/actions.ts`): user principals only, gated by AI consent, a daily limit and credits.
341
+ aiGenerateCharacterSkeleton: r(
342
+ "POST",
343
+ "/ai/generate-character-skeleton",
344
+ "U"
345
+ ),
346
+ aiGenerateScript: r("POST", "/ai/generate-script", "U"),
347
+ aiPolishCharacterDialogue: r("POST", "/ai/polish-character-dialogue", "U"),
348
+ aiPolishScene: r("POST", "/ai/polish-scene", "U"),
340
349
  aiJobCreate: r("POST", "/documents/:did/ai/jobs", "U,Krw", "ai.run"),
341
350
  aiJobsList: r("GET", "/documents/:did/ai/jobs", "U,Kr", "document.read"),
342
351
  aiJobGet: r("GET", "/ai/jobs/:jobId", "U,Kr", "document.read"),
@@ -1451,7 +1460,8 @@ const documentViewStatePutSchema = documentViewStateSchema.extend({
1451
1460
  const templateListQuerySchema = z.object({
1452
1461
  category: z.string().optional(),
1453
1462
  workspaceId: z.string().optional(),
1454
- scope: z.enum(["builtin", "user", "workspace"]).optional()
1463
+ scope: z.enum(["builtin", "user", "workspace"]).optional(),
1464
+ locale: z.string().optional()
1455
1465
  });
1456
1466
  const templateGetQuerySchema = z.object({
1457
1467
  version: z.coerce.number().int().min(1).optional()
@@ -1988,6 +1998,200 @@ const suggestionDecideSchema = z.object({
1988
1998
  expectedHashes: z.record(z.string(), z.string()).optional(),
1989
1999
  dryRun: z.boolean().optional()
1990
2000
  });
2001
+ const AI_ACTIONS = [
2002
+ "generate-character-skeleton",
2003
+ "generate-script",
2004
+ "polish-character-dialogue",
2005
+ "polish-scene"
2006
+ ];
2007
+ const aiActionSchema = z.enum(AI_ACTIONS);
2008
+ const AI_ACTION_LIMITS = {
2009
+ /** Free-form text a writer pastes in: a character description, or the story to turn into a script. */
2010
+ descriptionMax: 8e3,
2011
+ storyMax: 3e4,
2012
+ skeletonFieldMax: 1e3,
2013
+ characterNameMax: 80,
2014
+ languageMax: 35,
2015
+ /** Dialogue polish: one character's lines. */
2016
+ dialoguesMax: 100,
2017
+ dialogueTextMax: 2e3,
2018
+ /** Scene polish. */
2019
+ sceneElementsMax: 300,
2020
+ sceneElementTextMax: 2e3,
2021
+ sceneCharactersMax: 20,
2022
+ /** Script generation output. */
2023
+ scenesMax: 40,
2024
+ elementsPerSceneMax: 200,
2025
+ elementTextMax: 2e3,
2026
+ titleMax: 120,
2027
+ locationMax: 120,
2028
+ timeMax: 40,
2029
+ idMax: 64
2030
+ };
2031
+ const CHARACTER_SKELETON_FIELDS = {
2032
+ physical: [
2033
+ "age",
2034
+ "race",
2035
+ "height",
2036
+ "weight",
2037
+ "appearance",
2038
+ "sexOrientationExperience",
2039
+ "posture",
2040
+ "unusualCharacteristics",
2041
+ "health"
2042
+ ],
2043
+ social: [
2044
+ "occupationAndAttitude",
2045
+ "education",
2046
+ "money",
2047
+ "class",
2048
+ "relationships",
2049
+ "homeLife",
2050
+ "religion",
2051
+ "placeInCommunity",
2052
+ "politics",
2053
+ "interests"
2054
+ ],
2055
+ psychological: [
2056
+ "attitudeTowardLife",
2057
+ "moralStandard",
2058
+ "intelligence",
2059
+ "ambitions",
2060
+ "frustrations",
2061
+ "fearsAndObsessions",
2062
+ "extrovertOrIntrovert",
2063
+ "specialQualities",
2064
+ "proudestAchievement",
2065
+ "greatestSorrow",
2066
+ "greatestShame",
2067
+ "noticedFirst",
2068
+ "secret",
2069
+ "noticedLast",
2070
+ "coreContradictions",
2071
+ "deepestDesire"
2072
+ ]
2073
+ };
2074
+ const CHARACTER_SKELETON_KEYS = [
2075
+ ...CHARACTER_SKELETON_FIELDS.physical,
2076
+ ...CHARACTER_SKELETON_FIELDS.social,
2077
+ ...CHARACTER_SKELETON_FIELDS.psychological
2078
+ ];
2079
+ const skeletonText = z.string().max(AI_ACTION_LIMITS.skeletonFieldMax);
2080
+ const characterSkeletonSchema = z.object({
2081
+ age: skeletonText.min(1),
2082
+ ...Object.fromEntries(
2083
+ CHARACTER_SKELETON_KEYS.filter((k) => k !== "age").map((k) => [
2084
+ k,
2085
+ skeletonText.optional()
2086
+ ])
2087
+ )
2088
+ });
2089
+ const characterSkeletonModelSchema = z.strictObject({
2090
+ age: skeletonText.min(1),
2091
+ ...Object.fromEntries(
2092
+ CHARACTER_SKELETON_KEYS.filter((k) => k !== "age").map((k) => [
2093
+ k,
2094
+ skeletonText.nullable()
2095
+ ])
2096
+ )
2097
+ });
2098
+ const SCRIPT_ELEMENT_TYPES = [
2099
+ "action",
2100
+ "character",
2101
+ "parenthetical",
2102
+ "dialogue",
2103
+ "transition"
2104
+ ];
2105
+ const scriptElementSchema = z.strictObject({
2106
+ type: z.enum(SCRIPT_ELEMENT_TYPES),
2107
+ text: z.string().min(1).max(AI_ACTION_LIMITS.elementTextMax)
2108
+ });
2109
+ const SCENE_SETTINGS = ["int", "ext", "intExt"];
2110
+ const sceneHeadingSchema = z.strictObject({
2111
+ setting: z.enum(SCENE_SETTINGS),
2112
+ location: z.string().min(1).max(AI_ACTION_LIMITS.locationMax),
2113
+ /** "DAY", "NIGHT", "LATER" … as it would follow the dash in a heading. */
2114
+ time: z.string().min(1).max(AI_ACTION_LIMITS.timeMax)
2115
+ });
2116
+ const generatedSceneSchema = z.strictObject({
2117
+ heading: sceneHeadingSchema,
2118
+ elements: z.array(scriptElementSchema).min(1).max(AI_ACTION_LIMITS.elementsPerSceneMax)
2119
+ });
2120
+ const generateCharacterSkeletonRequestSchema = z.strictObject({
2121
+ /** A free-form paragraph describing the character. */
2122
+ text: z.string().trim().min(1).max(AI_ACTION_LIMITS.descriptionMax),
2123
+ /** BCP 47 tag the skeleton values are written in. Default: the language of `text`. */
2124
+ language: z.string().max(AI_ACTION_LIMITS.languageMax).optional()
2125
+ });
2126
+ const generateCharacterSkeletonModelSchema = z.strictObject({
2127
+ skeleton: characterSkeletonModelSchema
2128
+ });
2129
+ const generateCharacterSkeletonResultSchema = z.strictObject({
2130
+ skeleton: characterSkeletonSchema
2131
+ });
2132
+ const generateScriptRequestSchema = z.strictObject({
2133
+ /** The story in common language: a premise, a synopsis or a full retelling. */
2134
+ story: z.string().trim().min(1).max(AI_ACTION_LIMITS.storyMax),
2135
+ title: z.string().trim().max(AI_ACTION_LIMITS.titleMax).optional(),
2136
+ /** BCP 47 tag the script is written in. Default: the language of `story`. */
2137
+ language: z.string().max(AI_ACTION_LIMITS.languageMax).optional()
2138
+ });
2139
+ const generateScriptModelSchema = z.strictObject({
2140
+ title: z.string().max(AI_ACTION_LIMITS.titleMax).nullable(),
2141
+ scenes: z.array(generatedSceneSchema).min(1).max(AI_ACTION_LIMITS.scenesMax)
2142
+ });
2143
+ const generateScriptResultSchema = generateScriptModelSchema;
2144
+ const dialogueLineSchema = z.strictObject({
2145
+ /** The caller's own id for the line, echoed back so the result maps onto it. */
2146
+ id: z.string().min(1).max(AI_ACTION_LIMITS.idMax),
2147
+ text: z.string().min(1).max(AI_ACTION_LIMITS.dialogueTextMax)
2148
+ });
2149
+ const polishCharacterDialogueRequestSchema = z.strictObject({
2150
+ character: z.string().trim().min(1).max(AI_ACTION_LIMITS.characterNameMax),
2151
+ skeleton: characterSkeletonSchema,
2152
+ /** One character's lines, in script order. */
2153
+ dialogues: z.array(dialogueLineSchema).min(1).max(AI_ACTION_LIMITS.dialoguesMax),
2154
+ /** How much to change; default `medium`. */
2155
+ intensity: z.enum(["light", "medium", "bold"]).optional(),
2156
+ language: z.string().max(AI_ACTION_LIMITS.languageMax).optional()
2157
+ });
2158
+ const polishCharacterDialogueModelSchema = z.strictObject({
2159
+ /** The same ids in the same order, each with the polished line. */
2160
+ dialogues: z.array(dialogueLineSchema).min(1).max(AI_ACTION_LIMITS.dialoguesMax)
2161
+ });
2162
+ const polishCharacterDialogueResultSchema = polishCharacterDialogueModelSchema;
2163
+ const sceneCharacterSchema = z.strictObject({
2164
+ /** The name as it appears in the script's character cues. */
2165
+ name: z.string().trim().min(1).max(AI_ACTION_LIMITS.characterNameMax),
2166
+ skeleton: characterSkeletonSchema
2167
+ });
2168
+ const polishSceneRequestSchema = z.strictObject({
2169
+ scene: z.strictObject({
2170
+ /** The scene heading as text, e.g. "INT. LAB - DAY". Context only: it is not rewritten. */
2171
+ heading: z.string().max(AI_ACTION_LIMITS.locationMax + AI_ACTION_LIMITS.timeMax + 16).optional(),
2172
+ elements: z.array(scriptElementSchema).min(1).max(AI_ACTION_LIMITS.sceneElementsMax)
2173
+ }),
2174
+ /** A skeleton for every character involved in the scene. */
2175
+ characters: z.array(sceneCharacterSchema).min(1).max(AI_ACTION_LIMITS.sceneCharactersMax),
2176
+ intensity: z.enum(["light", "medium", "bold"]).optional(),
2177
+ language: z.string().max(AI_ACTION_LIMITS.languageMax).optional()
2178
+ });
2179
+ const polishSceneModelSchema = z.strictObject({
2180
+ elements: z.array(scriptElementSchema).min(1).max(AI_ACTION_LIMITS.sceneElementsMax)
2181
+ });
2182
+ const polishSceneResultSchema = polishSceneModelSchema;
2183
+ const AI_ACTION_MODEL_SCHEMAS = {
2184
+ "generate-character-skeleton": generateCharacterSkeletonModelSchema,
2185
+ "generate-script": generateScriptModelSchema,
2186
+ "polish-character-dialogue": polishCharacterDialogueModelSchema,
2187
+ "polish-scene": polishSceneModelSchema
2188
+ };
2189
+ const AI_ACTION_REQUEST_SCHEMAS = {
2190
+ "generate-character-skeleton": generateCharacterSkeletonRequestSchema,
2191
+ "generate-script": generateScriptRequestSchema,
2192
+ "polish-character-dialogue": polishCharacterDialogueRequestSchema,
2193
+ "polish-scene": polishSceneRequestSchema
2194
+ };
1991
2195
  const JOB_STATUSES = [
1992
2196
  "queued",
1993
2197
  "running",
@@ -3999,6 +4203,10 @@ export {
3999
4203
  ACCOUNT_EXPORT_FILENAME,
4000
4204
  ACTIVITY_KINDS,
4001
4205
  ACTOR_KINDS,
4206
+ AI_ACTIONS,
4207
+ AI_ACTION_LIMITS,
4208
+ AI_ACTION_MODEL_SCHEMAS,
4209
+ AI_ACTION_REQUEST_SCHEMAS,
4002
4210
  AI_CONSENT_VERSION,
4003
4211
  AI_ENDPOINTS,
4004
4212
  AI_ENDPOINT_OUTPUT_SCHEMAS,
@@ -4030,6 +4238,8 @@ export {
4030
4238
  AUDIT_MAX_RANGE_DAYS,
4031
4239
  AUTOCORRECT_MAX_PAIRS,
4032
4240
  BATCH_WATERMARK_MAX_RECIPIENTS,
4241
+ CHARACTER_SKELETON_FIELDS,
4242
+ CHARACTER_SKELETON_KEYS,
4033
4243
  CHAT_BODY_MAX,
4034
4244
  CHAT_EDIT_WINDOW_MINUTES,
4035
4245
  CLIENT_AUTO_REASONS,
@@ -4100,6 +4310,8 @@ export {
4100
4310
  ROLES,
4101
4311
  ROLE_PERMISSIONS,
4102
4312
  SCENE_BATCH_MAX,
4313
+ SCENE_SETTINGS,
4314
+ SCRIPT_ELEMENT_TYPES,
4103
4315
  SEARCH_HIT_TYPES,
4104
4316
  SEVERITIES,
4105
4317
  SHARE_LINK_ACCESS,
@@ -4157,6 +4369,7 @@ export {
4157
4369
  adminJobKindPatchSchema,
4158
4370
  adminJobListQuerySchema,
4159
4371
  adminJobRefundSchema,
4372
+ aiActionSchema,
4160
4373
  aiConsentAcceptSchema,
4161
4374
  aiEndpointInputSchema,
4162
4375
  aiEstimateRequestSchema,
@@ -4195,6 +4408,7 @@ export {
4195
4408
  changesQuerySchema,
4196
4409
  characterPacketBodySchema,
4197
4410
  characterPacketSchema,
4411
+ characterSkeletonSchema,
4198
4412
  chatMessageCreateSchema,
4199
4413
  chatMessageUpdateSchema,
4200
4414
  chatQuerySchema,
@@ -4210,6 +4424,7 @@ export {
4210
4424
  defaultNotificationPrefs,
4211
4425
  deviceCreateSchema,
4212
4426
  deviceUpdateSchema,
4427
+ dialogueLineSchema,
4213
4428
  dictionaryUpdateSchema,
4214
4429
  docSourceSchema,
4215
4430
  documentApplyTemplateSchema,
@@ -4241,6 +4456,13 @@ export {
4241
4456
  exportJobInputSchema,
4242
4457
  exportOptionsSchema,
4243
4458
  fountainQuerySchema,
4459
+ generateCharacterSkeletonModelSchema,
4460
+ generateCharacterSkeletonRequestSchema,
4461
+ generateCharacterSkeletonResultSchema,
4462
+ generateScriptModelSchema,
4463
+ generateScriptRequestSchema,
4464
+ generateScriptResultSchema,
4465
+ generatedSceneSchema,
4244
4466
  grantUpdateSchema,
4245
4467
  hasPermission,
4246
4468
  idKind,
@@ -4282,7 +4504,13 @@ export {
4282
4504
  packetQuerySchema,
4283
4505
  parseReportOptions,
4284
4506
  pingPayloadSchema,
4507
+ polishCharacterDialogueModelSchema,
4508
+ polishCharacterDialogueRequestSchema,
4509
+ polishCharacterDialogueResultSchema,
4285
4510
  polishResponseSchema,
4511
+ polishSceneModelSchema,
4512
+ polishSceneRequestSchema,
4513
+ polishSceneResultSchema,
4286
4514
  projectBinCreateSchema,
4287
4515
  projectCreateSchema,
4288
4516
  projectDuplicateJobInputSchema,
@@ -4311,9 +4539,12 @@ export {
4311
4539
  roleAtLeast,
4312
4540
  roleChangedPayloadSchema,
4313
4541
  roleSchema,
4542
+ sceneCharacterSchema,
4543
+ sceneHeadingSchema,
4314
4544
  scenePacketBodySchema,
4315
4545
  scenePacketSchema,
4316
4546
  scenesBatchRequestSchema,
4547
+ scriptElementSchema,
4317
4548
  searchQuerySchema,
4318
4549
  serverShutdownPayloadSchema,
4319
4550
  shareLinkCreateSchema,